%%ItemTitle%%

CSharpTest.Net
Welcome
Send Feedback Download Help File

Glossary Item Box

Welcome to CSharpTest.Net

As you may have already guessed, this repository is a collection of numerous and disassociated classes and utilities that I've built over past few years. It's neither the best, nor the worst code I've ever written but I keep it fairly well tested. There is a percentage of this library that was built as a proof-of-concept rather than to be placed into immediate use; However, most everything here has (or had) a specific purpose in mind that it was built for. Because of this 'build what you need' approach some of the classes here may prove incomplete for your needs.

On the Web

http://csharptest.net | Project home and development blog
http://csharptest.net/browse/src | Browse the current source repository
http://code.google.com/p/csharptest-net | View current and historical release notes
http://code.google.com/p/csharptest-net/downloads/list | Source and compiled binary downloads
http://code.google.com/p/csharptest-net/issues/list | Defect tracking

Getting acquainted with things

CSharpTest.Net.Library Assembly | The primary code-base of this library, various utility classes and other miscellaneous garbage ;)
CSharpTest.Net.BPlusTree Assembly | A fully-concurrent in-memory or disk-based IDictionary<K,V> implementation based on a B+Tree
CSharpTest.Net.RpcLibrary Assembly | A thin wrapper around Win32/PInvoke calls to the Windows RPC API (Remote Procedure Call)
SslTunnel.Library Assembly | A library that is used by the SslTunnel.Server to provide a fully managed secure tcp/ip port tunnel
Command-Line Tools | A collection of command-line utilities that are used by or build upon these libraries

Featured Content

CommandInterpreter Class | A fairly well fully functional command-line interpreter
ProcessRunner Class | The de-facto-standard wrapper class for redirecting std/io with the System.Diagnostics.Process Class
RpcClientApi Class / RpcServerApi Class | By far the fastest and most reliable Windows communications protocol out there
CmdTool.exe Overview | Simply the "Can't live without it" tool. Visual Studio multi-file code generator that supports any command-line right from Visual Studio 2005-2010.

Copyright 2007-2011 by Roger Knapp, Licensed under the Apache License, Version 2.0


$$INTRODUCTION$$ - %%projecttitle%%

Introduction
Send Feedback Download Help File

Glossary Item Box


%%phrase%%

CSharpTest.Net.BPlusTree Assembly
See Also Send Feedback Download Help File

Glossary Item Box

Namespaces

Namespace | Description
CSharpTest.Net |
CSharpTest.Net.Collections |


$$GETTING_STARTED$$ - %%projecttitle%%

Getting Started
Send Feedback Download Help File

Glossary Item Box


%%ItemTitle%%

CSharpTest.Net Namespace (CSharpTest.Net.BPlusTree)
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly : CSharpTest.Net Namespace

Glossary Item Box

Classes

 | Class | Description
Class | AssertionFailedException | Exception class: AssertionFailedException A runtime assertion failed while performing the operation.
Class | BaseAssertionException | The base class for BPlutTree runtime assertions
Class | DeadlockException | Exception class: DeadlockException A lock timeout has expired due to a possible deadlock.
Class | DuplicateKeyException | Exception class: DuplicateKeyException The specified key already exists in the collection.
Class | InvalidConfigurationValueException | Exception class: InvalidConfigurationValueException The configuration value '{0}' is invalid.
Class | InvalidNodeHandleException | Exception class: InvalidNodeHandleException A storage handle was invalid or has been corrupted.

See Also

Reference

CSharpTest.Net.BPlusTree Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
AssertionFailedException Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : AssertionFailedException Class

Glossary Item Box

Exception class: AssertionFailedException A runtime assertion failed while performing the operation.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class AssertionFailedException
   Inherits BaseAssertionException
C#
[SerializableAttribute()]
public class AssertionFailedException : BaseAssertionException

Inheritance Hierarchy

System.Object
System.Exception
System.ApplicationException
CSharpTest.Net.BaseAssertionException
CSharpTest.Net.AssertionFailedException

Requirements

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

See Also

Reference

AssertionFailedException Members
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AssertionFailedException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : AssertionFailedException Class

Glossary Item Box

The following tables list the members exposed by AssertionFailedException.

Public Constructors

 | Name | Description
Public Constructor | AssertionFailedException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | Overloaded. if(condition == false) throws A runtime assertion failed: {0}
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

AssertionFailedException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AssertionFailedException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class : AssertionFailedException Constructor

Glossary Item Box

Overload List

Overload | Description
AssertionFailedException Constructor(SerializationInfo,StreamingContext) | Serialization constructor
AssertionFailedException Constructor(Exception,Int32,String) | Constructs the exception from an hresult and message bypassing the message formatting
AssertionFailedException Constructor() | A runtime assertion failed while performing the operation.
AssertionFailedException Constructor(Exception) | A runtime assertion failed while performing the operation.
AssertionFailedException Constructor(String) | A runtime assertion failed: {0}
AssertionFailedException Constructor(String,Exception) | A runtime assertion failed: {0}

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AssertionFailedException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > AssertionFailedException Constructor : AssertionFailedException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Serialization constructor

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected AssertionFailedException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
AssertionFailedException Constructor(Exception,Int32,String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > AssertionFailedException Constructor : AssertionFailedException Constructor(Exception,Int32,String)

innerException
hResult
message

Glossary Item Box

Constructs the exception from an hresult and message bypassing the message formatting

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal innerException As Exception, _
   ByVal hResult As Integer, _
   ByVal message As String _
)
C#
protected AssertionFailedException(
   Exception innerException,
   int hResult,
   string message
)

Parameters

innerException
hResult
message

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
AssertionFailedException Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > AssertionFailedException Constructor : AssertionFailedException Constructor()

Glossary Item Box

A runtime assertion failed while performing the operation.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public AssertionFailedException()

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List

Used By

AssertionFailedException.Assert(Boolean)

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AssertionFailedException Constructor(Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > AssertionFailedException Constructor : AssertionFailedException Constructor(Exception)

innerException

Glossary Item Box

A runtime assertion failed while performing the operation.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal innerException As Exception _
)
C#
public AssertionFailedException(
   Exception innerException
)

Parameters

innerException

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AssertionFailedException Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > AssertionFailedException Constructor : AssertionFailedException Constructor(String)

message

Glossary Item Box

A runtime assertion failed: {0}

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal message As String _
)
C#
public AssertionFailedException(
   string message
)

Parameters

message

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List

Used By

AssertionFailedException.Assert(Boolean,String,Object[])
AssertionFailedException.Assert(Boolean,String)

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AssertionFailedException Constructor(String,Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > AssertionFailedException Constructor : AssertionFailedException Constructor(String,Exception)

message
innerException

Glossary Item Box

A runtime assertion failed: {0}

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal message As String, _
   ByVal innerException As Exception _
)
C#
public AssertionFailedException(
   string message,
   Exception innerException
)

Parameters

message
innerException

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AssertionFailedException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : AssertionFailedException Class

Glossary Item Box

For a list of all members of this type, see AssertionFailedException members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | Overloaded. if(condition == false) throws A runtime assertion failed: {0}
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

AssertionFailedException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class : Assert Method

Glossary Item Box

if(condition == false) throws A runtime assertion failed: {0}

Overload List

Overload | Description
Assert(Boolean,String,Object[]) | if(condition == false) throws A runtime assertion failed: {0}
Assert(Boolean) | if(condition == false) throws A runtime assertion failed while performing the operation.
Assert(Boolean,String) | if(condition == false) throws A runtime assertion failed: {0}

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(Boolean,String,Object[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > Assert Method : Assert(Boolean,String,Object[]) Method

condition
format
args

Glossary Item Box

if(condition == false) throws A runtime assertion failed: {0}

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal condition As Boolean, _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Assert(
   bool condition,
   string format,
   params object[] args
)

Parameters

condition
format
args

Exceptions

Exception | Description
AssertionFailedException | Exception class: AssertionFailedException A runtime assertion failed while performing the operation.

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List

Source Code

BPlusTree/Exceptions.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > Assert Method : Assert(Boolean) Method

condition

Glossary Item Box

if(condition == false) throws A runtime assertion failed while performing the operation.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal condition As Boolean _
)
C#
public static void Assert(
   bool condition
)

Parameters

condition

Exceptions

Exception | Description
AssertionFailedException | Exception class: AssertionFailedException A runtime assertion failed while performing the operation.

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List

Used By

TransactionLog.CommitTransaction(TransactionToken)
TransactionLog.RollbackTransaction(TransactionToken)

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(Boolean,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > AssertionFailedException Class > Assert Method : Assert(Boolean,String) Method

condition
message

Glossary Item Box

if(condition == false) throws A runtime assertion failed: {0}

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal condition As Boolean, _
   ByVal message As String _
)
C#
public static void Assert(
   bool condition,
   string message
)

Parameters

condition
message

Exceptions

Exception | Description
AssertionFailedException | Exception class: AssertionFailedException A runtime assertion failed while performing the operation.

Requirements

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

See Also

Reference

AssertionFailedException Class
AssertionFailedException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BaseAssertionException Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : BaseAssertionException Class

Glossary Item Box

The base class for BPlutTree runtime assertions

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public MustInherit Class BaseAssertionException
   Inherits System.ApplicationException
C#
[SerializableAttribute()]
public abstract class BaseAssertionException : System.ApplicationException

Inheritance Hierarchy

System.Object
System.Exception
System.ApplicationException
CSharpTest.Net.BaseAssertionException
CSharpTest.Net.AssertionFailedException
CSharpTest.Net.DeadlockException
CSharpTest.Net.InvalidNodeHandleException

Requirements

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

See Also

Reference

BaseAssertionException Members
CSharpTest.Net Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BaseAssertionException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : BaseAssertionException Class

Glossary Item Box

The following tables list the members exposed by BaseAssertionException.

Protected Constructors

 | Name | Description
Protected Constructor | BaseAssertionException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

BaseAssertionException Class
CSharpTest.Net Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
BaseAssertionException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > BaseAssertionException Class : BaseAssertionException Constructor

Glossary Item Box

Overload List

Overload | Description
BaseAssertionException Constructor(SerializationInfo,StreamingContext) | The base class for BPlutTree runtime assertions
BaseAssertionException Constructor(String) | The base class for BPlutTree runtime assertions
BaseAssertionException Constructor(String,Exception) | The base class for BPlutTree runtime assertions

Requirements

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

See Also

Reference

BaseAssertionException Class
BaseAssertionException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BaseAssertionException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > BaseAssertionException Class > BaseAssertionException Constructor : BaseAssertionException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

The base class for BPlutTree runtime assertions

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected BaseAssertionException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

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

See Also

Reference

BaseAssertionException Class
BaseAssertionException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
BaseAssertionException Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > BaseAssertionException Class > BaseAssertionException Constructor : BaseAssertionException Constructor(String)

text

Glossary Item Box

The base class for BPlutTree runtime assertions

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal text As String _
)
C#
protected BaseAssertionException(
   string text
)

Parameters

text

Requirements

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

See Also

Reference

BaseAssertionException Class
BaseAssertionException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
BaseAssertionException Constructor(String,Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > BaseAssertionException Class > BaseAssertionException Constructor : BaseAssertionException Constructor(String,Exception)

text
innerException

Glossary Item Box

The base class for BPlutTree runtime assertions

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal text As String, _
   ByVal innerException As Exception _
)
C#
protected BaseAssertionException(
   string text,
   Exception innerException
)

Parameters

text
innerException

Requirements

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

See Also

Reference

BaseAssertionException Class
BaseAssertionException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
DeadlockException Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : DeadlockException Class

Glossary Item Box

Exception class: DeadlockException A lock timeout has expired due to a possible deadlock.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class DeadlockException
   Inherits BaseAssertionException
C#
[SerializableAttribute()]
public class DeadlockException : BaseAssertionException

Inheritance Hierarchy

System.Object
System.Exception
System.ApplicationException
CSharpTest.Net.BaseAssertionException
CSharpTest.Net.DeadlockException

Requirements

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

See Also

Reference

DeadlockException Members
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DeadlockException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : DeadlockException Class

Glossary Item Box

The following tables list the members exposed by DeadlockException.

Public Constructors

 | Name | Description
Public Constructor | DeadlockException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws A lock timeout has expired due to a possible deadlock.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

DeadlockException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DeadlockException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DeadlockException Class : DeadlockException Constructor

Glossary Item Box

Overload List

Overload | Description
DeadlockException Constructor(SerializationInfo,StreamingContext) | Serialization constructor
DeadlockException Constructor(Exception,Int32,String) | Constructs the exception from an hresult and message bypassing the message formatting
DeadlockException Constructor() | A lock timeout has expired due to a possible deadlock.
DeadlockException Constructor(Exception) | A lock timeout has expired due to a possible deadlock.

Requirements

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

See Also

Reference

DeadlockException Class
DeadlockException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DeadlockException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DeadlockException Class > DeadlockException Constructor : DeadlockException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Serialization constructor

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected DeadlockException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

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

See Also

Reference

DeadlockException Class
DeadlockException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
DeadlockException Constructor(Exception,Int32,String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DeadlockException Class > DeadlockException Constructor : DeadlockException Constructor(Exception,Int32,String)

innerException
hResult
message

Glossary Item Box

Constructs the exception from an hresult and message bypassing the message formatting

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal innerException As Exception, _
   ByVal hResult As Integer, _
   ByVal message As String _
)
C#
protected DeadlockException(
   Exception innerException,
   int hResult,
   string message
)

Parameters

innerException
hResult
message

Requirements

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

See Also

Reference

DeadlockException Class
DeadlockException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
DeadlockException Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DeadlockException Class > DeadlockException Constructor : DeadlockException Constructor()

Glossary Item Box

A lock timeout has expired due to a possible deadlock.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public DeadlockException()

Requirements

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

See Also

Reference

DeadlockException Class
DeadlockException Members
Overload List

Used By

DeadlockException.Assert(Boolean)

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DeadlockException Constructor(Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DeadlockException Class > DeadlockException Constructor : DeadlockException Constructor(Exception)

innerException

Glossary Item Box

A lock timeout has expired due to a possible deadlock.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal innerException As Exception _
)
C#
public DeadlockException(
   Exception innerException
)

Parameters

innerException

Requirements

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

See Also

Reference

DeadlockException Class
DeadlockException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DeadlockException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : DeadlockException Class

Glossary Item Box

For a list of all members of this type, see DeadlockException members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws A lock timeout has expired due to a possible deadlock.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

DeadlockException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DeadlockException Class : Assert Method

condition

Glossary Item Box

if(condition == false) throws A lock timeout has expired due to a possible deadlock.

Syntax

Visual Basic (Declaration)
Public Shared Sub Assert( _
   ByVal condition As Boolean _
)
C#
public static void Assert(
   bool condition
)

Parameters

condition

Exceptions

Exception | Description
DeadlockException | Exception class: DeadlockException A lock timeout has expired due to a possible deadlock.

Requirements

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

See Also

Reference

DeadlockException Class
DeadlockException Members

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateKeyException Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : DuplicateKeyException Class

Glossary Item Box

Exception class: DuplicateKeyException The specified key already exists in the collection.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class DuplicateKeyException
   Inherits System.ApplicationException
C#
[SerializableAttribute()]
public class DuplicateKeyException : System.ApplicationException

Inheritance Hierarchy

System.Object
System.Exception
System.ApplicationException
CSharpTest.Net.DuplicateKeyException

Requirements

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

See Also

Reference

DuplicateKeyException Members
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DuplicateKeyException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : DuplicateKeyException Class

Glossary Item Box

The following tables list the members exposed by DuplicateKeyException.

Public Constructors

 | Name | Description
Public Constructor | DuplicateKeyException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws The specified key already exists in the collection.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

DuplicateKeyException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateKeyException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DuplicateKeyException Class : DuplicateKeyException Constructor

Glossary Item Box

Overload List

Overload | Description
DuplicateKeyException Constructor(SerializationInfo,StreamingContext) | Serialization constructor
DuplicateKeyException Constructor(Exception,Int32,String) | Constructs the exception from an hresult and message bypassing the message formatting
DuplicateKeyException Constructor() | The specified key already exists in the collection.
DuplicateKeyException Constructor(Exception) | The specified key already exists in the collection.

Requirements

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

See Also

Reference

DuplicateKeyException Class
DuplicateKeyException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateKeyException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DuplicateKeyException Class > DuplicateKeyException Constructor : DuplicateKeyException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Serialization constructor

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected DuplicateKeyException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

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

See Also

Reference

DuplicateKeyException Class
DuplicateKeyException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateKeyException Constructor(Exception,Int32,String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DuplicateKeyException Class > DuplicateKeyException Constructor : DuplicateKeyException Constructor(Exception,Int32,String)

innerException
hResult
message

Glossary Item Box

Constructs the exception from an hresult and message bypassing the message formatting

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal innerException As Exception, _
   ByVal hResult As Integer, _
   ByVal message As String _
)
C#
protected DuplicateKeyException(
   Exception innerException,
   int hResult,
   string message
)

Parameters

innerException
hResult
message

Requirements

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

See Also

Reference

DuplicateKeyException Class
DuplicateKeyException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateKeyException Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DuplicateKeyException Class > DuplicateKeyException Constructor : DuplicateKeyException Constructor()

Glossary Item Box

The specified key already exists in the collection.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public DuplicateKeyException()

Requirements

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

See Also

Reference

DuplicateKeyException Class
DuplicateKeyException Members
Overload List

Used By

DuplicateKeyException.Assert(Boolean)

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateKeyException Constructor(Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DuplicateKeyException Class > DuplicateKeyException Constructor : DuplicateKeyException Constructor(Exception)

innerException

Glossary Item Box

The specified key already exists in the collection.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal innerException As Exception _
)
C#
public DuplicateKeyException(
   Exception innerException
)

Parameters

innerException

Requirements

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

See Also

Reference

DuplicateKeyException Class
DuplicateKeyException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DuplicateKeyException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : DuplicateKeyException Class

Glossary Item Box

For a list of all members of this type, see DuplicateKeyException members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws The specified key already exists in the collection.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

DuplicateKeyException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > DuplicateKeyException Class : Assert Method

condition

Glossary Item Box

if(condition == false) throws The specified key already exists in the collection.

Syntax

Visual Basic (Declaration)
Public Shared Sub Assert( _
   ByVal condition As Boolean _
)
C#
public static void Assert(
   bool condition
)

Parameters

condition

Exceptions

Exception | Description
DuplicateKeyException | Exception class: DuplicateKeyException The specified key already exists in the collection.

Requirements

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

See Also

Reference

DuplicateKeyException Class
DuplicateKeyException Members

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidConfigurationValueException Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : InvalidConfigurationValueException Class

Glossary Item Box

Exception class: InvalidConfigurationValueException The configuration value '{0}' is invalid.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class InvalidConfigurationValueException
   Inherits System.ArgumentException
C#
[SerializableAttribute()]
public class InvalidConfigurationValueException : System.ArgumentException

Inheritance Hierarchy

System.Object
System.Exception
System.SystemException
System.ArgumentException
CSharpTest.Net.InvalidConfigurationValueException

Requirements

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

See Also

Reference

InvalidConfigurationValueException Members
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
InvalidConfigurationValueException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : InvalidConfigurationValueException Class

Glossary Item Box

The following tables list the members exposed by InvalidConfigurationValueException.

Public Constructors

 | Name | Description
Public Constructor | InvalidConfigurationValueException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | ParamName | Gets the name of the parameter that causes this exception. (Inherited from System.ArgumentException)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | Overloaded. if(condition == false) throws The configuration value '{0}' is invalid.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

InvalidConfigurationValueException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidConfigurationValueException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class : InvalidConfigurationValueException Constructor

Glossary Item Box

Overload List

Overload | Description
InvalidConfigurationValueException Constructor(SerializationInfo,StreamingContext) | Serialization constructor
InvalidConfigurationValueException Constructor(Exception,Int32,String) | Constructs the exception from an hresult and message bypassing the message formatting
InvalidConfigurationValueException Constructor(String) | The configuration value '{0}' is invalid.
InvalidConfigurationValueException Constructor(String,Exception) | The configuration value '{0}' is invalid.
InvalidConfigurationValueException Constructor(String,String) | The configuration value '{0}' is invalid. {1}
InvalidConfigurationValueException Constructor(String,String,Exception) | The configuration value '{0}' is invalid. {1}

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidConfigurationValueException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class > InvalidConfigurationValueException Constructor : InvalidConfigurationValueException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Serialization constructor

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected InvalidConfigurationValueException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidConfigurationValueException Constructor(Exception,Int32,String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class > InvalidConfigurationValueException Constructor : InvalidConfigurationValueException Constructor(Exception,Int32,String)

innerException
hResult
message

Glossary Item Box

Constructs the exception from an hresult and message bypassing the message formatting

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal innerException As Exception, _
   ByVal hResult As Integer, _
   ByVal message As String _
)
C#
protected InvalidConfigurationValueException(
   Exception innerException,
   int hResult,
   string message
)

Parameters

innerException
hResult
message

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidConfigurationValueException Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class > InvalidConfigurationValueException Constructor : InvalidConfigurationValueException Constructor(String)

property

Glossary Item Box

The configuration value '{0}' is invalid.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal property As String _
)
C#
public InvalidConfigurationValueException(
   string property
)

Parameters

property

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members
Overload List

Used By

InvalidConfigurationValueException.Assert(Boolean,String)

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidConfigurationValueException Constructor(String,Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class > InvalidConfigurationValueException Constructor : InvalidConfigurationValueException Constructor(String,Exception)

property
innerException

Glossary Item Box

The configuration value '{0}' is invalid.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal property As String, _
   ByVal innerException As Exception _
)
C#
public InvalidConfigurationValueException(
   string property,
   Exception innerException
)

Parameters

property
innerException

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidConfigurationValueException Constructor(String,String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class > InvalidConfigurationValueException Constructor : InvalidConfigurationValueException Constructor(String,String)

property
message

Glossary Item Box

The configuration value '{0}' is invalid. {1}

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal property As String, _
   ByVal message As String _
)
C#
public InvalidConfigurationValueException(
   string property,
   string message
)

Parameters

property
message

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members
Overload List

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)
InvalidConfigurationValueException.Assert(Boolean,String,String)

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidConfigurationValueException Constructor(String,String,Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class > InvalidConfigurationValueException Constructor : InvalidConfigurationValueException Constructor(String,String,Exception)

property
message
innerException

Glossary Item Box

The configuration value '{0}' is invalid. {1}

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal property As String, _
   ByVal message As String, _
   ByVal innerException As Exception _
)
C#
public InvalidConfigurationValueException(
   string property,
   string message,
   Exception innerException
)

Parameters

property
message
innerException

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
InvalidConfigurationValueException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : InvalidConfigurationValueException Class

Glossary Item Box

For a list of all members of this type, see InvalidConfigurationValueException members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | Overloaded. if(condition == false) throws The configuration value '{0}' is invalid.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

InvalidConfigurationValueException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class : Assert Method

Glossary Item Box

if(condition == false) throws The configuration value '{0}' is invalid.

Overload List

Overload | Description
Assert(Boolean,String) | if(condition == false) throws The configuration value '{0}' is invalid.
Assert(Boolean,String,String) | if(condition == false) throws The configuration value '{0}' is invalid. {1}

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(Boolean,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class > Assert Method : Assert(Boolean,String) Method

condition
property

Glossary Item Box

if(condition == false) throws The configuration value '{0}' is invalid.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal condition As Boolean, _
   ByVal property As String _
)
C#
public static void Assert(
   bool condition,
   string property
)

Parameters

condition
property

Exceptions

Exception | Description
InvalidConfigurationValueException | Exception class: InvalidConfigurationValueException The configuration value '{0}' is invalid.

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(Boolean,String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidConfigurationValueException Class > Assert Method : Assert(Boolean,String,String) Method

condition
property
message

Glossary Item Box

if(condition == false) throws The configuration value '{0}' is invalid. {1}

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal condition As Boolean, _
   ByVal property As String, _
   ByVal message As String _
)
C#
public static void Assert(
   bool condition,
   string property,
   string message
)

Parameters

condition
property
message

Exceptions

Exception | Description
InvalidConfigurationValueException | Exception class: InvalidConfigurationValueException The configuration value '{0}' is invalid.

Requirements

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

See Also

Reference

InvalidConfigurationValueException Class
InvalidConfigurationValueException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidNodeHandleException Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : InvalidNodeHandleException Class

Glossary Item Box

Exception class: InvalidNodeHandleException A storage handle was invalid or has been corrupted.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class InvalidNodeHandleException
   Inherits BaseAssertionException
C#
[SerializableAttribute()]
public class InvalidNodeHandleException : BaseAssertionException

Inheritance Hierarchy

System.Object
System.Exception
System.ApplicationException
CSharpTest.Net.BaseAssertionException
CSharpTest.Net.InvalidNodeHandleException

Requirements

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

See Also

Reference

InvalidNodeHandleException Members
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
InvalidNodeHandleException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : InvalidNodeHandleException Class

Glossary Item Box

The following tables list the members exposed by InvalidNodeHandleException.

Public Constructors

 | Name | Description
Public Constructor | InvalidNodeHandleException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws A storage handle was invalid or has been corrupted.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

InvalidNodeHandleException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidNodeHandleException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidNodeHandleException Class : InvalidNodeHandleException Constructor

Glossary Item Box

Overload List

Overload | Description
InvalidNodeHandleException Constructor(SerializationInfo,StreamingContext) | Serialization constructor
InvalidNodeHandleException Constructor(Exception,Int32,String) | Constructs the exception from an hresult and message bypassing the message formatting
InvalidNodeHandleException Constructor() | A storage handle was invalid or has been corrupted.
InvalidNodeHandleException Constructor(Exception) | A storage handle was invalid or has been corrupted.

Requirements

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

See Also

Reference

InvalidNodeHandleException Class
InvalidNodeHandleException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidNodeHandleException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidNodeHandleException Class > InvalidNodeHandleException Constructor : InvalidNodeHandleException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Serialization constructor

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected InvalidNodeHandleException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

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

See Also

Reference

InvalidNodeHandleException Class
InvalidNodeHandleException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidNodeHandleException Constructor(Exception,Int32,String)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidNodeHandleException Class > InvalidNodeHandleException Constructor : InvalidNodeHandleException Constructor(Exception,Int32,String)

innerException
hResult
message

Glossary Item Box

Constructs the exception from an hresult and message bypassing the message formatting

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal innerException As Exception, _
   ByVal hResult As Integer, _
   ByVal message As String _
)
C#
protected InvalidNodeHandleException(
   Exception innerException,
   int hResult,
   string message
)

Parameters

innerException
hResult
message

Requirements

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

See Also

Reference

InvalidNodeHandleException Class
InvalidNodeHandleException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidNodeHandleException Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidNodeHandleException Class > InvalidNodeHandleException Constructor : InvalidNodeHandleException Constructor()

Glossary Item Box

A storage handle was invalid or has been corrupted.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public InvalidNodeHandleException()

Requirements

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

See Also

Reference

InvalidNodeHandleException Class
InvalidNodeHandleException Members
Overload List

Used By

InvalidNodeHandleException.Assert(Boolean)

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InvalidNodeHandleException Constructor(Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidNodeHandleException Class > InvalidNodeHandleException Constructor : InvalidNodeHandleException Constructor(Exception)

innerException

Glossary Item Box

A storage handle was invalid or has been corrupted.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal innerException As Exception _
)
C#
public InvalidNodeHandleException(
   Exception innerException
)

Parameters

innerException

Requirements

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

See Also

Reference

InvalidNodeHandleException Class
InvalidNodeHandleException Members
Overload List

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
InvalidNodeHandleException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : InvalidNodeHandleException Class

Glossary Item Box

For a list of all members of this type, see InvalidNodeHandleException members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws A storage handle was invalid or has been corrupted.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

InvalidNodeHandleException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace > InvalidNodeHandleException Class : Assert Method

condition

Glossary Item Box

if(condition == false) throws A storage handle was invalid or has been corrupted.

Syntax

Visual Basic (Declaration)
Public Shared Sub Assert( _
   ByVal condition As Boolean _
)
C#
public static void Assert(
   bool condition
)

Parameters

condition

Exceptions

Exception | Description
InvalidNodeHandleException | Exception class: InvalidNodeHandleException A storage handle was invalid or has been corrupted.

Requirements

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

See Also

Reference

InvalidNodeHandleException Class
InvalidNodeHandleException Members

Source Code

BPlusTree/Resources.Designer.cs


%%ItemTitle%%

CSharpTest.Net.Collections Namespace (CSharpTest.Net.BPlusTree)
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly : CSharpTest.Net.Collections Namespace

Glossary Item Box

Classes

 | Class | Description
Class | BPlusTree<TKey,TValue> | Implements an IDictionary interface for a simple file-based database
Class | BPlusTree.Options<TKey,TValue> | Defines the options nessessary to construct a BPlusTree implementation
Class | BPlusTree.OptionsV2<TKey,TValue> | Defines the options nessessary to construct a BPlusTree implementation
Class | BPlusTreeOptions<TKey,TValue> | Defines the options nessessary to construct a BPlusTree implementation
Class | BulkInsertOptions | Options for bulk insertion
Class | TransactionLog<TKey,TValue> | The default transaction log for a BPlusTree instance to provide backup+log recovery
Class | TransactionLogOptions<TKey,TValue> | Options used to initialize a TransactionLog

Interfaces

 | Interface | Description
Interface | INodeStorage | Represents a persistance mechanic for node data
Interface | INodeStoreWithCount | An optional interface that allows storage provides to persist the record count
Interface | IStorageHandle | Identifies a class as a reference to a node instance
Interface | ITransactionLog<TKey,TValue> | Represents a transaction log of writes to a dictionary.

Structures

 | Structure | Description
Structure | TransactionToken | A value representing the state/identifer/object of a single transaction. The field's meaning is defined by the ITrasactionLog implementation and is otherwise treated as an opaque token identifier of the transaction.

Enumerations

 | Enumeration | Description
Enumeration | BPlusTree.DebugFormat<TKey,TValue> | Print formatting for nodes
Enumeration | CachePolicy | Determines the type of node caching used in the tree
Enumeration | CreatePolicy | Determines if the file specified should be created
Enumeration | ExistingLogAction | Defines the action to perform when opening a BPlusTree with an existing log file.
Enumeration | FileVersion | Determines the binary file format and backwards compatibility
Enumeration | StoragePerformance | Defines the levels of durability the store will try to achieve. 'Uncommitted changes' in the descriptions below refers to all changes made to the tree since the last call to CommitChanges() on the BPlusTree class.
Enumeration | StorageType | Defines the storage type to use

See Also

Reference

CSharpTest.Net.BPlusTree Assembly


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
BPlusTree<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree<TKey,TValue> Class

Glossary Item Box

Implements an IDictionary interface for a simple file-based database

Object Model

BPlusTree<TKey,TValue> ClassTValue Class

Syntax

Visual Basic (Declaration)
Public Class BPlusTree
    (Of TKey,TValue)
   Implements IConcurrentDictionary(Of TKey,TValue), IDictionaryEx(Of TKey,TValue), CSharpTest.Net.Interfaces.ITransactable
C#
public class BPlusTree<TKey,TValue> : IConcurrentDictionary<TKey,TValue>, IDictionaryEx<TKey,TValue>, CSharpTest.Net.Interfaces.ITransactable

Type Parameters

TKey
TValue

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BPlusTree<TKey,TValue>

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BPlusTree<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by BPlusTree<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | BPlusTree<TKey,TValue> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | CallLevelLock | Defines the lock used to provide tree-level exclusive operations. This should be set at the time of construction, or not at all since operations depending on this (Clear, EnableCount, and UnloadCache) may behave poorly if operations that started prior to setting this value are still being processed. Out of the locks I've tested the ReaderWriterLocking implementation performs best here since it is a highly read-intensive lock. All public APIs that access tree content will aquire this lock as a reader except the tree exclusive operations. This also allows you, by way of aquiring a write lock, to gain exclusive access and perform mass updates, atomic enumeration, etc.
Public Property | Count | See comments on EnableCount() for usage of this property
Public Property | IsReadOnly | Returns true if the file was opened in ReadOnly mode.
Public Property | Item | Gets or sets the element with the specified key.
Public Property | Keys | Gets an ICollection containing the keys of the IDictionary.
Public Property | Values | Gets an ICollection containing the values in the IDictionary.
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an element with the provided key and value to the IDictionary.
Public Method | AddRange | Overloaded. Presorts the provided enumeration in batches and then performs an optimized insert on the resulting set(s).
Public Method | AddRangeSorted | Overloaded. Optimized insert of presorted key/value pairs. If the input is not presorted, please use AddRange() instead.
Public Method | BulkInsert | Overloaded. Rewrite the entire BTree as a transaction to include the provided items. This method is Thread safe. If the input is already sorted, use BulkInsertOptions overload to specify InputIsSorted = true.
Public Method | Clear | Removes all items from the collection and permanently destroys all storage.
Public Method | Commit | When using TransactionLog, this method commits the changes in the current instance to the output file and truncates the log. For all other cases the method is a no-op and no exception is raised. This method is NOT thread safe UNLESS the CallLevelLock property has been set to valid reader/writer lock. If you need to call this method while writers are currently accessing the tree, make sure the CallLevelLock options is specified.
Public Method | ContainsKey | Determines whether the IDictionary contains an element with the specified key.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | DebugSetOutput | Sets a text writter that the entire btree will be dumped to after every read/write/seek operation. The format is a single line of text in abbreviated form: {k1{k1,k2,k3},k4{k4,k5}}
Public Method | DebugSetValidateOnCheckpoint | Sets a boolean condition that will validate the state of the entire btree after every operation.
Public Method | Dispose | Closes the storage and clears memory used by the instance
Public Method | EnableCount | Due to the cost of upkeep, this must be enable each time the object is created via a call to EnableCount() which itself must be done before any writer threads are active for it to be accurate. This requires that the entire tree be loaded (sequentially) in order to build the initial working count. Once completed, members like Add() and Remove() will keep the initial count accurate.
static (Shared in Visual Basic) | EnumerateFile | Directly enumerates the contents of BPlusTree from disk in read-only mode.
Public Method | EnumerateFrom | Inclusivly enumerates from start key to the end of the collection
Public Method | EnumerateRange | Inclusivly enumerates from start key to stop key
Public Method | First | Returns the first key and it's associated value.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | GetOrAdd | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist.
Public Method | Last | Returns the last key and it's associated value.
Public Method | Print | Prints the entire tree to the text writer
static (Shared in Visual Basic) | RecoverFile | Recovers as much file content as possible into a newly created BPlusTree<TKey,TValue>, if the operation returns a non-zero result it was successful and the file has been replaced with a new database containing the recovered data. The original file remains in-tact but was renamed with a '.deleted' extension.
static (Shared in Visual Basic) | RecoveryScan | Performs a low-level scan of the storage file to yield all Key/Value pairs it was able to read from the file.
Public Method | Remove | Removes the element with the specified key from the IDictionary.
Public Method | Rollback | With version 2 storage this will revert the contents of tree to it's initial state when the file was first opened, or to the state captured with the last call to commit. Any transaction log data will be truncated.
Public Method | TryAdd | Overloaded. Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.
Public Method | TryGetFirst | Returns the first key and it's associated value.
Public Method | TryGetLast | Returns the last key and it's associated value.
Public Method | TryGetValue | Gets the value associated with the specified key.
Public Method | TryRemove | Overloaded. Removes the element with the specified key from the IDictionary.
Public Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Public Method | UnloadCache | Safely removes all items from the in-memory cache.
Public Method | Validate | Forces a top-down, depth-first, crawl of the entire tree in which every node and every link or key is checked for accuracy. Throws on error.
Top

See Also

Reference

BPlusTree<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : BPlusTree<TKey,TValue> Constructor

Glossary Item Box

Overload List

Overload | Description
BPlusTree<TKey,TValue> Constructor() | Constructs an in-memory BPlusTree
BPlusTree<TKey,TValue> Constructor(IComparer<TKey>) | Constructs an in-memory BPlusTree
BPlusTree<TKey,TValue> Constructor(BPlusTree<TKey,TValue>+OptionsV2) | Constructs a BPlusTree using a Version 2 file format

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree<TKey,TValue> Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > BPlusTree<TKey,TValue> Constructor : BPlusTree<TKey,TValue> Constructor()

Glossary Item Box

Constructs an in-memory BPlusTree

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public BPlusTree<TKey,TValue>()

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree<TKey,TValue> Constructor(IComparer<TKey>)
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > BPlusTree<TKey,TValue> Constructor : BPlusTree<TKey,TValue> Constructor(IComparer<TKey>)

comparer

Glossary Item Box

Constructs an in-memory BPlusTree

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of TKey) _
)
C#
public BPlusTree<TKey,TValue>(
   IComparer<TKey> comparer
)

Parameters

comparer

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree<TKey,TValue> Constructor(BPlusTree<TKey,TValue>+OptionsV2)
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > BPlusTree<TKey,TValue> Constructor : BPlusTree<TKey,TValue> Constructor(BPlusTree<TKey,TValue>+OptionsV2)

optionsV2

Glossary Item Box

Constructs a BPlusTree using a Version 2 file format

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal optionsV2 As BPlusTree(Of TKey,TValue) _
)
C#
public BPlusTree<TKey,TValue>(
   BPlusTree<TKey,TValue> optionsV2
)

Parameters

optionsV2

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BPlusTree<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BPlusTree<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Add | Adds an element with the provided key and value to the IDictionary.
Public Method | AddRange | Overloaded. Presorts the provided enumeration in batches and then performs an optimized insert on the resulting set(s).
Public Method | AddRangeSorted | Overloaded. Optimized insert of presorted key/value pairs. If the input is not presorted, please use AddRange() instead.
Public Method | BulkInsert | Overloaded. Rewrite the entire BTree as a transaction to include the provided items. This method is Thread safe. If the input is already sorted, use BulkInsertOptions overload to specify InputIsSorted = true.
Public Method | Clear | Removes all items from the collection and permanently destroys all storage.
Public Method | Commit | When using TransactionLog, this method commits the changes in the current instance to the output file and truncates the log. For all other cases the method is a no-op and no exception is raised. This method is NOT thread safe UNLESS the CallLevelLock property has been set to valid reader/writer lock. If you need to call this method while writers are currently accessing the tree, make sure the CallLevelLock options is specified.
Public Method | ContainsKey | Determines whether the IDictionary contains an element with the specified key.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | DebugSetOutput | Sets a text writter that the entire btree will be dumped to after every read/write/seek operation. The format is a single line of text in abbreviated form: {k1{k1,k2,k3},k4{k4,k5}}
Public Method | DebugSetValidateOnCheckpoint | Sets a boolean condition that will validate the state of the entire btree after every operation.
Public Method | Dispose | Closes the storage and clears memory used by the instance
Public Method | EnableCount | Due to the cost of upkeep, this must be enable each time the object is created via a call to EnableCount() which itself must be done before any writer threads are active for it to be accurate. This requires that the entire tree be loaded (sequentially) in order to build the initial working count. Once completed, members like Add() and Remove() will keep the initial count accurate.
static (Shared in Visual Basic) | EnumerateFile | Directly enumerates the contents of BPlusTree from disk in read-only mode.
Public Method | EnumerateFrom | Inclusivly enumerates from start key to the end of the collection
Public Method | EnumerateRange | Inclusivly enumerates from start key to stop key
Public Method | First | Returns the first key and it's associated value.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | GetOrAdd | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist.
Public Method | Last | Returns the last key and it's associated value.
Public Method | Print | Prints the entire tree to the text writer
static (Shared in Visual Basic) | RecoverFile | Recovers as much file content as possible into a newly created BPlusTree<TKey,TValue>, if the operation returns a non-zero result it was successful and the file has been replaced with a new database containing the recovered data. The original file remains in-tact but was renamed with a '.deleted' extension.
static (Shared in Visual Basic) | RecoveryScan | Performs a low-level scan of the storage file to yield all Key/Value pairs it was able to read from the file.
Public Method | Remove | Removes the element with the specified key from the IDictionary.
Public Method | Rollback | With version 2 storage this will revert the contents of tree to it's initial state when the file was first opened, or to the state captured with the last call to commit. Any transaction log data will be truncated.
Public Method | TryAdd | Overloaded. Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.
Public Method | TryGetFirst | Returns the first key and it's associated value.
Public Method | TryGetLast | Returns the last key and it's associated value.
Public Method | TryGetValue | Gets the value associated with the specified key.
Public Method | TryRemove | Overloaded. Removes the element with the specified key from the IDictionary.
Public Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Public Method | UnloadCache | Safely removes all items from the in-memory cache.
Public Method | Validate | Forces a top-down, depth-first, crawl of the entire tree in which every node and every link or key is checked for accuracy. Throws on error.
Top

See Also

Reference

BPlusTree<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Add Method

key
value

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Public Sub Add( _
   ByVal key As TKey, _
   ByVal value As TValue _
)
C#
public void Add(
   TKey key,
   TValue value
)

Parameters

key
value

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : AddRange Method

Glossary Item Box

Presorts the provided enumeration in batches and then performs an optimized insert on the resulting set(s).

Overload List

Overload | Description
AddRange(IEnumerable<KeyValuePair<TKey,TValue>>) | Presorts the provided enumeration in batches and then performs an optimized insert on the resulting set(s).
AddRange(IEnumerable<KeyValuePair<TKey,TValue>>,Boolean) | Presorts the provided enumeration in batches and then performs an optimized insert on the resulting set(s).

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange(IEnumerable<KeyValuePair<TKey,TValue>>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > AddRange Method : AddRange(IEnumerable<KeyValuePair<TKey,TValue>>) Method

unorderedItems
The items to insert

Glossary Item Box

Presorts the provided enumeration in batches and then performs an optimized insert on the resulting set(s).

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddRange( _
   ByVal unorderedItems As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
)
C#
public void AddRange(
   IEnumerable<KeyValuePair<TKey,TValue>> unorderedItems
)

Parameters

unorderedItems
The items to insert

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange(IEnumerable<KeyValuePair<TKey,TValue>>,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > AddRange Method : AddRange(IEnumerable<KeyValuePair<TKey,TValue>>,Boolean) Method

unorderedItems
The items to insert
allowUpdates
True to overwrite any existing records

Glossary Item Box

Presorts the provided enumeration in batches and then performs an optimized insert on the resulting set(s).

Syntax

Visual Basic (Declaration)
Public Overloads Function AddRange( _
   ByVal unorderedItems As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal allowUpdates As Boolean _
) As Integer
C#
public int AddRange(
   IEnumerable<KeyValuePair<TKey,TValue>> unorderedItems,
   bool allowUpdates
)

Parameters

unorderedItems
The items to insert
allowUpdates
True to overwrite any existing records

Return Value

The total number of records inserted or updated

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
Stopwatch sw = Stopwatch.StartNew();
var options = Options.Clone();
using (TempFile temp = new TempFile())
{
    //using (BPlusTree<int, string> data = Create(Options))
    using (BPlusTree<int, string> data = Create(options))
    {
        const bool bulk = true;
        Insert(data, CreateRandom(1000, 3000), bulk, false);

        data.EnableCount();
        Assert.AreEqual(1000, data.Count);

        Insert(data, CreateCount(data.Last().Key + 1, 1, 1000), bulk, true);
        Assert.AreEqual(2000, data.Count);

        Insert(data, CreateCount(data.Last().Key + 10001, -1, 1000), bulk, false);
        Assert.AreEqual(3000, data.Count);

        int lastKey = data.Last().Key;
        data.AddRange(CreateCount(1, 2, lastKey / 2), true);
    }
    temp.Dispose();
}
Trace.WriteLine("Inserted in " + sw.Elapsed);
VB.NET Copy Code
Dim sw As Stopwatch = Stopwatch.StartNew()
Dim options As var = Options.Clone()
Using temp As New TempFile()
    'using (BPlusTree<int, string> data = Create(Options))
    Using data As BPlusTree(Of Integer, String) = Create(options)
        Const  bulk As Boolean = True
        Insert(data, CreateRandom(1000, 3000), bulk, False)

        data.EnableCount()
        Assert.AreEqual(1000, data.Count)

        Insert(data, CreateCount(data.Last().Key + 1, 1, 1000), bulk, True)
        Assert.AreEqual(2000, data.Count)

        Insert(data, CreateCount(data.Last().Key + 10001, -1, 1000), bulk, False)
        Assert.AreEqual(3000, data.Count)

        Dim lastKey As Integer = data.Last().Key
        data.AddRange(CreateCount(1, 2, lastKey / 2), True)
    End Using
    temp.Dispose()
End Using
Trace.WriteLine("Inserted in " + sw.Elapsed)

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Used By

BPlusTree.AddRange(IEnumerable>)

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRangeSorted Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : AddRangeSorted Method

Glossary Item Box

Optimized insert of presorted key/value pairs. If the input is not presorted, please use AddRange() instead.

Overload List

Overload | Description
AddRangeSorted(IEnumerable<KeyValuePair<TKey,TValue>>) | Optimized insert of presorted key/value pairs. If the input is not presorted, please use AddRange() instead.
AddRangeSorted(IEnumerable<KeyValuePair<TKey,TValue>>,Boolean) | Optimized insert of presorted key/value pairs. If the input is not presorted, please use AddRange() instead.

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRangeSorted(IEnumerable<KeyValuePair<TKey,TValue>>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > AddRangeSorted Method : AddRangeSorted(IEnumerable<KeyValuePair<TKey,TValue>>) Method

items
The ordered list of items to insert

Glossary Item Box

Optimized insert of presorted key/value pairs. If the input is not presorted, please use AddRange() instead.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddRangeSorted( _
   ByVal items As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
) As Integer
C#
public int AddRangeSorted(
   IEnumerable<KeyValuePair<TKey,TValue>> items
)

Parameters

items
The ordered list of items to insert

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRangeSorted(IEnumerable<KeyValuePair<TKey,TValue>>,Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > AddRangeSorted Method : AddRangeSorted(IEnumerable<KeyValuePair<TKey,TValue>>,Boolean) Method

items
The ordered list of items to insert
allowUpdates
True to overwrite any existing records

Glossary Item Box

Optimized insert of presorted key/value pairs. If the input is not presorted, please use AddRange() instead.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddRangeSorted( _
   ByVal items As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal allowUpdates As Boolean _
) As Integer
C#
public int AddRangeSorted(
   IEnumerable<KeyValuePair<TKey,TValue>> items,
   bool allowUpdates
)

Parameters

items
The ordered list of items to insert
allowUpdates
True to overwrite any existing records

Return Value

The total number of records inserted or updated

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Used By

Int32 BPlusTree.AddRange(IEnumerable>,Boolean)
Int32 BPlusTree.AddRangeSorted(IEnumerable>)

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BulkInsert Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : BulkInsert Method

Glossary Item Box

Rewrite the entire BTree as a transaction to include the provided items. This method is Thread safe. If the input is already sorted, use BulkInsertOptions overload to specify InputIsSorted = true.

Overload List

Overload | Description
BulkInsert(IEnumerable<KeyValuePair<TKey,TValue>>) | Rewrite the entire BTree as a transaction to include the provided items. This method is Thread safe. If the input is already sorted, use BulkInsertOptions overload to specify InputIsSorted = true.
BulkInsert(IEnumerable<KeyValuePair<TKey,TValue>>,BulkInsertOptions) | Rewrite the entire BTree as a transaction to include the provided items. This method is Thread safe. If the input is already sorted, use BulkInsertOptions overload to specify InputIsSorted = true.

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BulkInsert(IEnumerable<KeyValuePair<TKey,TValue>>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > BulkInsert Method : BulkInsert(IEnumerable<KeyValuePair<TKey,TValue>>) Method

items

Glossary Item Box

Rewrite the entire BTree as a transaction to include the provided items. This method is Thread safe. If the input is already sorted, use BulkInsertOptions overload to specify InputIsSorted = true.

Syntax

Visual Basic (Declaration)
Public Overloads Function BulkInsert( _
   ByVal items As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
) As Integer
C#
public int BulkInsert(
   IEnumerable<KeyValuePair<TKey,TValue>> items
)

Parameters

items

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BulkInsert(IEnumerable<KeyValuePair<TKey,TValue>>,BulkInsertOptions) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > BulkInsert Method : BulkInsert(IEnumerable<KeyValuePair<TKey,TValue>>,BulkInsertOptions) Method

items
bulkOptions

Glossary Item Box

Rewrite the entire BTree as a transaction to include the provided items. This method is Thread safe. If the input is already sorted, use BulkInsertOptions overload to specify InputIsSorted = true.

Syntax

Visual Basic (Declaration)
Public Overloads Function BulkInsert( _
   ByVal items As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal bulkOptions As BulkInsertOptions _
) As Integer
C#
public int BulkInsert(
   IEnumerable<KeyValuePair<TKey,TValue>> items,
   BulkInsertOptions bulkOptions
)

Parameters

items
bulkOptions

Exceptions

Exception | Description
System.IO.InvalidDataException |

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List
BulkInsertOptions

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)
Int32 BPlusTree.BulkInsert(IEnumerable>)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Clear Method

Glossary Item Box

Removes all items from the collection and permanently destroys all storage.

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
int iterations = 5;
int limit = 255;

using (BPlusTree<int, string> data = Create(Options))
{
    data.EnableCount();

    List<int> numbers = new List<int>();
    while (iterations-- > 0)
    {
        data.Clear();
        numbers.Clear();
        data.DebugSetValidateOnCheckpoint(true);

        for (int i = 0; i < limit; i++)
        {
            int id = Random.Next(limit);
            if (!numbers.Contains(id))
            {
                numbers.Add(id);
                data.Add(id, "V" + id);
            }
        }

        Assert.AreEqual(numbers.Count, data.Count);

        foreach (int number in numbers)
            Assert.IsTrue(data.Remove(number));

        Assert.AreEqual(0, data.Count);
    }
}
VB.NET Copy Code
Dim iterations As Integer = 5
Dim limit As Integer = 255

Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.EnableCount()

    Dim numbers As New List(Of Integer)()
    While System.Math.Max(System.Threading.Interlocked.Decrement(iterations),iterations + 1) > 0
        data.Clear()
        numbers.Clear()
        data.DebugSetValidateOnCheckpoint(True)

        Dim i As Integer = 0
        While i < limit
            Dim id As Integer = Random.[Next](limit)
            If Not numbers.Contains(id) Then
                numbers.Add(id)
                data.Add(id, "V" + id)
            End If
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.AreEqual(numbers.Count, data.Count)

        For Each number As Integer In numbers
            Assert.IsTrue(data.Remove(number))
        Next

        Assert.AreEqual(0, data.Count)
    End While
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Commit Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Commit Method

Glossary Item Box

When using TransactionLog, this method commits the changes in the current instance to the output file and truncates the log. For all other cases the method is a no-op and no exception is raised. This method is NOT thread safe UNLESS the CallLevelLock property has been set to valid reader/writer lock. If you need to call this method while writers are currently accessing the tree, make sure the CallLevelLock options is specified.

Syntax

Visual Basic (Declaration)
Public Sub Commit()
C#
public void Commit()

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)


%%PageItemTitle%%

[image]
CSharpTest.Net
ContainsKey Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : ContainsKey Method

key

Glossary Item Box

Determines whether the IDictionary contains an element with the specified key.

Syntax

Visual Basic (Declaration)
Public Function ContainsKey( _
   ByVal key As TKey _
) As Boolean
C#
public bool ContainsKey(
   TKey key
)

Parameters

key

Example

BPlusTree/BPlusTree.Test/BasicTestsVersion2.cs

C# Copy Code
using (BPlusTree<int, string> tree = Create(Options))
{
    tree.EnableCount();
    Assert.AreEqual(0, tree.Count);
    tree.Rollback();
    Assert.AreEqual(0, tree.Count);
    tree.Commit();
    Assert.AreEqual(0, tree.Count);

    tree.Add(1, "A");
    tree.Rollback();
    Assert.AreEqual(0, tree.Count);
    tree.Commit();
    Assert.AreEqual(0, tree.Count);

    tree.Add(1, "A");
    tree.Commit();
    Assert.AreEqual(1, tree.Count);
    tree.Rollback();
    Assert.AreEqual(1, tree.Count);

    tree.Add(2, "B");
    tree.Rollback();
    Assert.AreEqual(1, tree.Count);
    tree[1] = "abc";
    tree.Commit();
    Assert.AreEqual(1, tree.Count);
    tree.Rollback();

    Assert.AreEqual("abc", tree[1]);
    Assert.IsFalse(tree.ContainsKey(2));
}
VB.NET Copy Code
Using tree As BPlusTree(Of Integer, String) = Create(Options)
    tree.EnableCount()
    Assert.AreEqual(0, tree.Count)
    tree.Rollback()
    Assert.AreEqual(0, tree.Count)
    tree.Commit()
    Assert.AreEqual(0, tree.Count)

    tree.Add(1, "A")
    tree.Rollback()
    Assert.AreEqual(0, tree.Count)
    tree.Commit()
    Assert.AreEqual(0, tree.Count)

    tree.Add(1, "A")
    tree.Commit()
    Assert.AreEqual(1, tree.Count)
    tree.Rollback()
    Assert.AreEqual(1, tree.Count)

    tree.Add(2, "B")
    tree.Rollback()
    Assert.AreEqual(1, tree.Count)
    tree(1) = "abc"
    tree.Commit()
    Assert.AreEqual(1, tree.Count)
    tree.Rollback()

    Assert.AreEqual("abc", tree(1))
    Assert.IsFalse(tree.ContainsKey(2))
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As KeyValuePair(Of TKey,TValue), _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   KeyValuePair<TKey,TValue>[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugSetOutput Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : DebugSetOutput Method

output

Glossary Item Box

Sets a text writter that the entire btree will be dumped to after every read/write/seek operation. The format is a single line of text in abbreviated form: {k1{k1,k2,k3},k4{k4,k5}}

Syntax

Visual Basic (Declaration)
Public Sub DebugSetOutput( _
   ByVal output As TextWriter _
)
C#
public void DebugSetOutput(
   TextWriter output
)

Parameters

output

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
var options = Options;
options.BTreeOrder = 4;
using (BPlusTree<int, string> data = new BPlusTree<int,string>(options))
{
    data.EnableCount();

    data.DebugSetOutput(new StringWriter());
    data.DebugSetValidateOnCheckpoint(true);

    for (int id = 0; id < 10; id++)
        data.Add(id, id.ToString());

    using (IEnumerator<KeyValuePair<int, string>> enu = data.GetEnumerator())
    {
        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(0, enu.Current.Key);

        for (int id = 2; id < 10; id++)
            Assert.IsTrue(data.Remove(id));
        for (int id = 6; id < 11; id++)
            data.Add(id, id.ToString());

        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(1, enu.Current.Key);
        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(6, enu.Current.Key);
        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(7, enu.Current.Key);
        Assert.IsTrue(data.Remove(8));
        Assert.IsTrue(data.Remove(9));
        Assert.IsTrue(data.Remove(10));
        data.Add(11, 11.ToString());
        Assert.IsTrue(enu.MoveNext());
        Assert.AreEqual(11, enu.Current.Key);
        Assert.IsTrue(false == enu.MoveNext());
    }
    data.Clear();
}
VB.NET Copy Code
Dim options As var = Options
options.BTreeOrder = 4
Using data As New BPlusTree(Of Integer, String)(options)
    data.EnableCount()

    data.DebugSetOutput(New StringWriter())
    data.DebugSetValidateOnCheckpoint(True)

    Dim id As Integer = 0
    While id < 10
        data.Add(id, id.ToString())
        System.Math.Max(System.Threading.Interlocked.Increment(id),id - 1)
    End While

    Using enu As IEnumerator(Of KeyValuePair(Of Integer, String)) = data.GetEnumerator()
        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(0, enu.Current.Key)

        Dim id As Integer = 2
        While id < 10
            Assert.IsTrue(data.Remove(id))
            System.Math.Max(System.Threading.Interlocked.Increment(id),id - 1)
        End While
        Dim id As Integer = 6
        While id < 11
            data.Add(id, id.ToString())
            System.Math.Max(System.Threading.Interlocked.Increment(id),id - 1)
        End While

        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(1, enu.Current.Key)
        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(6, enu.Current.Key)
        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(7, enu.Current.Key)
        Assert.IsTrue(data.Remove(8))
        Assert.IsTrue(data.Remove(9))
        Assert.IsTrue(data.Remove(10))
        data.Add(11, 11.ToString())
        Assert.IsTrue(enu.MoveNext())
        Assert.AreEqual(11, enu.Current.Key)
        Assert.IsTrue(False = enu.MoveNext())
    End Using
    data.Clear()
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Debug.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugSetValidateOnCheckpoint Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : DebugSetValidateOnCheckpoint Method

validate

Glossary Item Box

Sets a boolean condition that will validate the state of the entire btree after every operation.

Syntax

Visual Basic (Declaration)
Public Sub DebugSetValidateOnCheckpoint( _
   ByVal validate As Boolean _
)
C#
public void DebugSetValidateOnCheckpoint(
   bool validate
)

Parameters

validate

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
int iterations = 5;
int limit = 255;

using (BPlusTree<int, string> data = Create(Options))
{
    data.EnableCount();

    List<int> numbers = new List<int>();
    while (iterations-- > 0)
    {
        data.Clear();
        numbers.Clear();
        data.DebugSetValidateOnCheckpoint(true);

        for (int i = 0; i < limit; i++)
        {
            int id = Random.Next(limit);
            if (!numbers.Contains(id))
            {
                numbers.Add(id);
                data.Add(id, "V" + id);
            }
        }

        Assert.AreEqual(numbers.Count, data.Count);

        foreach (int number in numbers)
            Assert.IsTrue(data.Remove(number));

        Assert.AreEqual(0, data.Count);
    }
}
VB.NET Copy Code
Dim iterations As Integer = 5
Dim limit As Integer = 255

Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.EnableCount()

    Dim numbers As New List(Of Integer)()
    While System.Math.Max(System.Threading.Interlocked.Decrement(iterations),iterations + 1) > 0
        data.Clear()
        numbers.Clear()
        data.DebugSetValidateOnCheckpoint(True)

        Dim i As Integer = 0
        While i < limit
            Dim id As Integer = Random.[Next](limit)
            If Not numbers.Contains(id) Then
                numbers.Add(id)
                data.Add(id, "V" + id)
            End If
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.AreEqual(numbers.Count, data.Count)

        For Each number As Integer In numbers
            Assert.IsTrue(data.Remove(number))
        Next

        Assert.AreEqual(0, data.Count)
    End While
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Debug.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Dispose Method

Glossary Item Box

Closes the storage and clears memory used by the instance

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnableCount Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : EnableCount Method

Glossary Item Box

Due to the cost of upkeep, this must be enable each time the object is created via a call to EnableCount() which itself must be done before any writer threads are active for it to be accurate. This requires that the entire tree be loaded (sequentially) in order to build the initial working count. Once completed, members like Add() and Remove() will keep the initial count accurate.

Syntax

Visual Basic (Declaration)
Public Sub EnableCount()
C#
public void EnableCount()

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Used By

BPlusTree.Rollback()

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateFile Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : EnumerateFile Method

options
The options normally used to create the BPlusTree<TKey,TValue> instance

Glossary Item Box

Directly enumerates the contents of BPlusTree from disk in read-only mode.

Syntax

Visual Basic (Declaration)
Public Shared Function EnumerateFile( _
   ByVal options As BPlusTreeOptions(Of TKey,TValue) _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public static IEnumerable<KeyValuePair<TKey,TValue>> EnumerateFile(
   BPlusTreeOptions<TKey,TValue> options
)

Parameters

options
The options normally used to create the BPlusTree<TKey,TValue> instance

Return Value

Yields the Key/Value pairs found in the file

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
BPlusTreeOptions

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateFrom Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : EnumerateFrom Method

start

Glossary Item Box

Inclusivly enumerates from start key to the end of the collection

Syntax

Visual Basic (Declaration)
Public Function EnumerateFrom( _
   ByVal start As TKey _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public IEnumerable<KeyValuePair<TKey,TValue>> EnumerateFrom(
   TKey start
)

Parameters

start

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    for (int i = 0; i < 100; i++)
        data.Add(i, i.ToString());

    Assert.AreEqual(50, new List<KeyValuePair<int, string>>(data.EnumerateFrom(50)).Count);
    Assert.AreEqual(25, new List<KeyValuePair<int, string>>(data.EnumerateFrom(75)).Count);

    for (int i = 0; i < 100; i++)
    {
        int first = -1;
        foreach (KeyValuePair<int, string> kv in data.EnumerateFrom(i))
        {
            first = kv.Key;
            break;
        }
        Assert.AreEqual(i, first);
    }
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    Dim i As Integer = 0
    While i < 100
        data.Add(i, i.ToString())
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    Assert.AreEqual(50, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(50)).Count)
    Assert.AreEqual(25, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(75)).Count)

    Dim i As Integer = 0
    While i < 100
        Dim first As Integer = -1
        For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateFrom(i)
            first = kv.Key
            Exit For
        Next
        Assert.AreEqual(i, first)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateRange Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : EnumerateRange Method

start
end

Glossary Item Box

Inclusivly enumerates from start key to stop key

Syntax

Visual Basic (Declaration)
Public Function EnumerateRange( _
   ByVal start As TKey, _
   ByVal end As TKey _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public IEnumerable<KeyValuePair<TKey,TValue>> EnumerateRange(
   TKey start,
   TKey end
)

Parameters

start
end

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    for (int i = 0; i < 100; i++)
        data.Add(i, i.ToString());

    int ix = 0;
    foreach (KeyValuePair<int, string> kv in data.EnumerateRange(-500, 5000))
        Assert.AreEqual(ix++, kv.Key);
    Assert.AreEqual(100, ix);

    foreach (KeyValuePair<int, int> range in new Dictionary<int, int> { { 6, 25 }, { 7, 25 }, { 8, 25 }, { 9, 25 }, { 22, 25 }, { 28, 28 } })
    {
        ix = range.Key;
        foreach (KeyValuePair<int, string> kv in data.EnumerateRange(ix, range.Value))
            Assert.AreEqual(ix++, kv.Key);
        Assert.AreEqual(range.Value, ix - 1);
    }
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    Dim i As Integer = 0
    While i < 100
        data.Add(i, i.ToString())
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    Dim ix As Integer = 0
    For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateRange(-500, 5000)
        Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1), kv.Key)
    Next
    Assert.AreEqual(100, ix)

    For Each range As KeyValuePair(Of Integer, Integer) In New Dictionary(Of Integer, Integer)() From { _
        {6, 25}, _
        {7, 25}, _
        {8, 25}, _
        {9, 25}, _
        {22, 25}, _
        {28, 28} _
    }
        ix = range.Key
        For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateRange(ix, range.Value)
            Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1), kv.Key)
        Next
        Assert.AreEqual(range.Value, ix - 1)
    Next
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
First Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : First Method

Glossary Item Box

Returns the first key and it's associated value.

Syntax

Visual Basic (Declaration)
Public Function First() As KeyValuePair(Of TKey,TValue)
C#
public KeyValuePair<TKey,TValue> First()

Exceptions

Exception | Description
System.InvalidOperationException | The exception that is thrown when a method call is invalid for the object's current state.

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
const int CountPerThread = 100;

BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using (WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, CountPerThread).Run);

    for (int i = 0; i < CountPerThread; i++)
    {
        if(i%2 == 0)
        {
            try {
                dictionary.TryAdd(new KeyInfo(Guid.NewGuid(), i), k => { throw new ExpectedException(); });
            } catch { }
        }
        else
        {
            try
            {
                dictionary.TryRemove(dictionary.First().Key, (k, v) => { throw new ExpectedException(); });
            }
            catch { }
        }
    }

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Const  CountPerThread As Integer = 100

        Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
        options.CalcBTreeOrder(32, 300)
        options.FileName = TempFile.TempPath
        options.CreateFile = CreatePolicy.Always

        Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
            Using work As New WorkQueue(Environment.ProcessorCount)
                Dim lastError As Exception = Nothing
                work.OnError += Function(o As Object, e As ErrorEventArgs) Do
                    lastError = e.GetException()
                End Function

                Dim i As Integer = 0
                While i < Environment.ProcessorCount
                    work.Enqueue(New ThreadedTest(dictionary, CountPerThread).Run)
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While

                Dim i As Integer = 0
                While i < CountPerThread
                    If i Mod 2 = 0 Then
                        Try
                            dictionary.TryAdd(New KeyInfo(Guid.NewGuid(), i), Function(k)
                            Throw New ExpectedException()

End Function)
                        Catch
                        End Try
                    Else
                        Try
                            dictionary.TryRemove(dictionary.First().Key, Function(k, v)
                            Throw New ExpectedException()

End Function)
                        Catch
                        End Try
                    End If
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While

                Assert.IsTrue(work.Complete(True, 60000))
                Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
            End Using
        End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of KeyValuePair(Of TKey,TValue))
C#
public IEnumerator<KeyValuePair<TKey,TValue>> GetEnumerator()

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.Options options = new BPlusTree<KeyInfo, DataValue>.Options(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (TempFile copy = new TempFile())
{
    copy.Delete();
    int minRecordCreated = StartAndAbortWriters(options, copy);

    using (TempFile.Attach(copy.TempPath + ".recovered")) //used to create the new copy
    using (TempFile.Attach(copy.TempPath + ".deleted"))  //renamed existing file
    {
        options.CreateFile = CreatePolicy.Never;
        int recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        if (recoveredRecords < RecordsCreated)
            Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated);

        options.FileName = copy.TempPath;
        recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords);

        using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
        {
            dictionary.EnableCount();
            Assert.AreEqual(recoveredRecords, dictionary.Count);

            foreach (KeyValuePair<KeyInfo, DataValue> kv in dictionary)
            {
                Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID);
                dictionary.Remove(kv.Key);
            }

            Assert.AreEqual(0, dictionary.Count);
        }
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always

Using copy As New TempFile()
    copy.Delete()
    Dim minRecordCreated As Integer = StartAndAbortWriters(options, copy)

    Using TempFile.Attach(copy.TempPath + ".recovered")
        'used to create the new copy
        Using TempFile.Attach(copy.TempPath + ".deleted")
            'renamed existing file
            options.CreateFile = CreatePolicy.Never
            Dim recoveredRecords As Integer = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            If recoveredRecords < RecordsCreated Then
                Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated)
            End If

            options.FileName = copy.TempPath
            recoveredRecords = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords)

            Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
                dictionary.EnableCount()
                Assert.AreEqual(recoveredRecords, dictionary.Count)

                For Each kv As KeyValuePair(Of KeyInfo, DataValue) In dictionary
                    Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID)
                    dictionary.Remove(kv.Key)
                Next

                Assert.AreEqual(0, dictionary.Count)
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs

Used By

BPlusTree.CopyTo(KeyValuePair[],Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : GetOrAdd Method

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Overload List

Overload | Description
GetOrAdd(TKey,TValue) | Adds a key/value pair to the IDictionary if the key does not already exist.
GetOrAdd(TKey,Converter<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist.

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > GetOrAdd Method : GetOrAdd(TKey,TValue) Method

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As TValue
C#
public TValue GetOrAdd(
   TKey key,
   TValue value
)

Parameters

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    Assert.AreEqual("a", data.GetOrAdd(1, "a"));
    Assert.AreEqual("a", data.GetOrAdd(1, "b"));

    Assert.AreEqual("b", data.GetOrAdd(2, k => "b"));
    Assert.AreEqual("b", data.GetOrAdd(2, k => "c"));
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    Assert.AreEqual("a", data.GetOrAdd(1, "a"))
    Assert.AreEqual("a", data.GetOrAdd(1, "b"))

    Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "b"))
    Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "c"))
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd(TKey,Converter<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > GetOrAdd Method : GetOrAdd(TKey,Converter<TKey,TValue>) Method

key
The key of the element to add.
fnCreate
Constructs a new value for the key.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue) _
) As TValue
C#
public TValue GetOrAdd(
   TKey key,
   Converter<TKey,TValue> fnCreate
)

Parameters

key
The key of the element to add.
fnCreate
Constructs a new value for the key.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    Assert.AreEqual("a", data.GetOrAdd(1, "a"));
    Assert.AreEqual("a", data.GetOrAdd(1, "b"));

    Assert.AreEqual("b", data.GetOrAdd(2, k => "b"));
    Assert.AreEqual("b", data.GetOrAdd(2, k => "c"));
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    Assert.AreEqual("a", data.GetOrAdd(1, "a"))
    Assert.AreEqual("a", data.GetOrAdd(1, "b"))

    Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "b"))
    Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "c"))
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Last Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Last Method

Glossary Item Box

Returns the last key and it's associated value.

Syntax

Visual Basic (Declaration)
Public Function Last() As KeyValuePair(Of TKey,TValue)
C#
public KeyValuePair<TKey,TValue> Last()

Exceptions

Exception | Description
System.InvalidOperationException | The exception that is thrown when a method call is invalid for the object's current state.

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
                      {
                          CreateFile = CreatePolicy.Always,
                          FileName = tempFile.TempPath,
                      }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.CreateFile = CreatePolicy.Never;
    readcopy.ReadOnly = true;

    using (var tree = new BPlusTree<int, string>(options))
    {
        using (var copy = new BPlusTree<int, string>(readcopy))
        {
            copy.EnableCount();
            Assert.AreEqual(0, copy.Count);
        }

        //insert some data...
        tree.AddRange(MakeValues(0, 100));

        using (var copy = new BPlusTree<int, string>(readcopy))
        {
            copy.EnableCount();
            Assert.AreEqual(0, copy.Count);
        }
        tree.Commit();

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tree.AddRange(MakeValues(1000, 1000));

        using (var copy = new BPlusTree<int, string>(readcopy))
        {
            copy.EnableCount();
            Assert.AreEqual(100, copy.Count);
            Assert.AreEqual(0, copy.First().Key);
            Assert.AreEqual(99, copy.Last().Key);
        }

        tree.Commit();

    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
        Key .CreateFile = CreatePolicy.Always, _
        Key .FileName = tempFile.TempPath _
    }.CalcBTreeOrder(4, 10)

    Dim readcopy As var = options.Clone()
    readcopy.CreateFile = CreatePolicy.Never
    readcopy.[ReadOnly] = True

    Using tree As var = New BPlusTree(Of Integer, String)(options)
        Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
            copy.EnableCount()
            Assert.AreEqual(0, copy.Count)
        End Using

        'insert some data...
        tree.AddRange(MakeValues(0, 100))

        Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
            copy.EnableCount()
            Assert.AreEqual(0, copy.Count)
        End Using
        tree.Commit()

        'insert some data...
        Dim i As Integer = 0
        While i < 100
            tree.Remove(i)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        tree.AddRange(MakeValues(1000, 1000))

        Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
            copy.EnableCount()
            Assert.AreEqual(100, copy.Count)
            Assert.AreEqual(0, copy.First().Key)
            Assert.AreEqual(99, copy.Last().Key)
        End Using

        tree.Commit()
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Print(TextWriter,BPlusTree<TKey,TValue>+DebugFormat) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Print(TextWriter,BPlusTree<TKey,TValue>+DebugFormat) Method

output
format

Glossary Item Box

Prints the entire tree to the text writer

Syntax

Visual Basic (Declaration)
Public Sub Print( _
   ByVal output As TextWriter, _
   ByVal format As BPlusTree(Of TKey,TValue) _
)
C#
public void Print(
   TextWriter output,
   BPlusTree<TKey,TValue> format
)

Parameters

output
format

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
BPlusTree.DebugFormat

Source Code

BPlusTree/Collections/BPlusTree.Debug.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RecoverFile Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : RecoverFile Method

options
The options normally used to create the BPlusTree<TKey,TValue> instance

Glossary Item Box

Recovers as much file content as possible into a newly created BPlusTree<TKey,TValue>, if the operation returns a non-zero result it was successful and the file has been replaced with a new database containing the recovered data. The original file remains in-tact but was renamed with a '.deleted' extension.

Syntax

Visual Basic (Declaration)
Public Shared Function RecoverFile( _
   ByVal options As BPlusTree(Of TKey,TValue) _
) As Integer
C#
public static int RecoverFile(
   BPlusTree<TKey,TValue> options
)

Parameters

options
The options normally used to create the BPlusTree<TKey,TValue> instance

Return Value

Returns 0 on failure, or the number of records successfully retrieved from the original file

Exceptions

Exception | Description
InvalidConfigurationValueException | Exception class: InvalidConfigurationValueException The configuration value '{0}' is invalid.

Remarks

If an exception occurs during the parsing of the file and one or more records were recovered, they will be stored in a file by the same name with an added extension of '.recovered'. This recovered file can be opened as a normal BPlusTree<TKey,TValue> to view it's contents. During the restore it is possible that a single Key was found multiple times, in this case the first occurrence found will be used.

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.Options options = new BPlusTree<KeyInfo, DataValue>.Options(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (TempFile copy = new TempFile())
{
    copy.Delete();
    int minRecordCreated = StartAndAbortWriters(options, copy);

    using (TempFile.Attach(copy.TempPath + ".recovered")) //used to create the new copy
    using (TempFile.Attach(copy.TempPath + ".deleted"))  //renamed existing file
    {
        options.CreateFile = CreatePolicy.Never;
        int recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        if (recoveredRecords < RecordsCreated)
            Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated);

        options.FileName = copy.TempPath;
        recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords);

        using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
        {
            dictionary.EnableCount();
            Assert.AreEqual(recoveredRecords, dictionary.Count);

            foreach (KeyValuePair<KeyInfo, DataValue> kv in dictionary)
            {
                Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID);
                dictionary.Remove(kv.Key);
            }

            Assert.AreEqual(0, dictionary.Count);
        }
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always

Using copy As New TempFile()
    copy.Delete()
    Dim minRecordCreated As Integer = StartAndAbortWriters(options, copy)

    Using TempFile.Attach(copy.TempPath + ".recovered")
        'used to create the new copy
        Using TempFile.Attach(copy.TempPath + ".deleted")
            'renamed existing file
            options.CreateFile = CreatePolicy.Never
            Dim recoveredRecords As Integer = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            If recoveredRecords < RecordsCreated Then
                Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated)
            End If

            options.FileName = copy.TempPath
            recoveredRecords = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords)

            Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
                dictionary.EnableCount()
                Assert.AreEqual(recoveredRecords, dictionary.Count)

                For Each kv As KeyValuePair(Of KeyInfo, DataValue) In dictionary
                    Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID)
                    dictionary.Remove(kv.Key)
                Next

                Assert.AreEqual(0, dictionary.Count)
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
BPlusTree.Options

Source Code

BPlusTree/Collections/BPlusTree.Recovery.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RecoveryScan Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : RecoveryScan Method

options
The options normally used to create the BPlusTree<TKey,TValue> instance
sharing
System.IO.FileShare options used to open the file

Glossary Item Box

Performs a low-level scan of the storage file to yield all Key/Value pairs it was able to read from the file.

Syntax

Visual Basic (Declaration)
Public Shared Function RecoveryScan( _
   ByVal options As BPlusTree(Of TKey,TValue), _
   ByVal sharing As FileShare _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public static IEnumerable<KeyValuePair<TKey,TValue>> RecoveryScan(
   BPlusTree<TKey,TValue> options,
   FileShare sharing
)

Parameters

options
The options normally used to create the BPlusTree<TKey,TValue> instance
sharing
System.IO.FileShare options used to open the file

Return Value

Yields the Key/Value pairs found in the file

Example

BPlusTree/BPlusTree.Test/TestFileSerialized.cs

C# Copy Code
BPlusTree<int, string>.Options options = (BPlusTree<int, string>.Options)Options;
options.BTreeOrder = 4;
options.FileBlockSize = 512;
options.FileGrowthRate = 25;
options.ConcurrentWriters = 4;
options.FileOpenOptions = FileOptions.None;

using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
{
    for(int i=0; i < 100; i++)
        Assert.IsTrue(tree.TryAdd(i, i.ToString()));
}

using (Stream io = TempFile.Open())
{
    //first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin);
    io.Write(new byte[512], 0, 512);

    //Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin);
    int len = PrimitiveSerializer.Int32.ReadFrom(io);
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin);//secrets of fragmented file revealed... ugly i know.
    io.WriteByte(255); //overwrite last used byte in chunk.
}

options.CreateFile = CreatePolicy.Never;

//Now that we've corrupted part of the file content, let's take a peek
try
{
    using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
    {
        foreach (KeyValuePair<int, string> kv in tree)
            Assert.AreEqual(kv.Key.ToString(), kv.Value);
    }
    Assert.Fail("Expected InvalidDataException");
}
catch (InvalidDataException)
{ }

Dictionary<int, string> found = new Dictionary<int, string>();
List<int> duplicates = new List<int>();
foreach (KeyValuePair<int, string> kv in BPlusTree<int, string>.RecoveryScan(options, FileShare.None))
{
    if (!found.ContainsKey(kv.Key))
        found.Add(kv.Key, kv.Value);
    else
        duplicates.Add(kv.Key);

    Assert.AreEqual(kv.Key.ToString(), kv.Value);
}
Assert.AreNotEqual(0, found.Count);

//The following may change...
Assert.AreEqual(99, found.Count);
Assert.IsFalse(found.ContainsKey(3), "should be missing #3");
Assert.AreEqual(0, duplicates.Count);
VB.NET Copy Code
Dim options As BPlusTree(Of Integer, String).Options = DirectCast(Options, BPlusTree(Of Integer, String).Options)
options.BTreeOrder = 4
options.FileBlockSize = 512
options.FileGrowthRate = 25
options.ConcurrentWriters = 4
options.FileOpenOptions = FileOptions.None

Using tree As New BPlusTree(Of Integer, String)(options)
    Dim i As Integer = 0
    While i < 100
        Assert.IsTrue(tree.TryAdd(i, i.ToString()))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
End Using

Using io As Stream = TempFile.Open()
    'first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin)
    io.Write(New Byte(512) {}, 0, 512)

    'Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin)
    Dim len As Integer = PrimitiveSerializer.Int32.ReadFrom(io)
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin)
    'secrets of fragmented file revealed... ugly i know.
        'overwrite last used byte in chunk.
    io.WriteByte(255)
End Using

options.CreateFile = CreatePolicy.Never

'Now that we've corrupted part of the file content, let's take a peek
Try
    Using tree As New BPlusTree(Of Integer, String)(options)
        For Each kv As KeyValuePair(Of Integer, String) In tree
            Assert.AreEqual(kv.Key.ToString(), kv.Value)
        Next
    End Using
    Assert.Fail("Expected InvalidDataException")
Catch generatedExceptionName As InvalidDataException
End Try

Dim found As New Dictionary(Of Integer, String)()
Dim duplicates As New List(Of Integer)()
For Each kv As KeyValuePair(Of Integer, String) In BPlusTree(Of Integer, String).RecoveryScan(options, FileShare.None)
    If Not found.ContainsKey(kv.Key) Then
        found.Add(kv.Key, kv.Value)
    Else
        duplicates.Add(kv.Key)
    End If

    Assert.AreEqual(kv.Key.ToString(), kv.Value)
Next
Assert.AreNotEqual(0, found.Count)

'The following may change...
Assert.AreEqual(99, found.Count)
Assert.IsFalse(found.ContainsKey(3), "should be missing #3")
Assert.AreEqual(0, duplicates.Count)

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
BPlusTree.Options

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Remove Method

key

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal key As TKey _
) As Boolean
C#
public bool Remove(
   TKey key
)

Parameters

key

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.Options options = new BPlusTree<KeyInfo, DataValue>.Options(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (TempFile copy = new TempFile())
{
    copy.Delete();
    int minRecordCreated = StartAndAbortWriters(options, copy);

    using (TempFile.Attach(copy.TempPath + ".recovered")) //used to create the new copy
    using (TempFile.Attach(copy.TempPath + ".deleted"))  //renamed existing file
    {
        options.CreateFile = CreatePolicy.Never;
        int recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        if (recoveredRecords < RecordsCreated)
            Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated);

        options.FileName = copy.TempPath;
        recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords);

        using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
        {
            dictionary.EnableCount();
            Assert.AreEqual(recoveredRecords, dictionary.Count);

            foreach (KeyValuePair<KeyInfo, DataValue> kv in dictionary)
            {
                Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID);
                dictionary.Remove(kv.Key);
            }

            Assert.AreEqual(0, dictionary.Count);
        }
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always

Using copy As New TempFile()
    copy.Delete()
    Dim minRecordCreated As Integer = StartAndAbortWriters(options, copy)

    Using TempFile.Attach(copy.TempPath + ".recovered")
        'used to create the new copy
        Using TempFile.Attach(copy.TempPath + ".deleted")
            'renamed existing file
            options.CreateFile = CreatePolicy.Never
            Dim recoveredRecords As Integer = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            If recoveredRecords < RecordsCreated Then
                Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated)
            End If

            options.FileName = copy.TempPath
            recoveredRecords = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords)

            Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
                dictionary.EnableCount()
                Assert.AreEqual(recoveredRecords, dictionary.Count)

                For Each kv As KeyValuePair(Of KeyInfo, DataValue) In dictionary
                    Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID)
                    dictionary.Remove(kv.Key)
                Next

                Assert.AreEqual(0, dictionary.Count)
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Rollback Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Rollback Method

Glossary Item Box

With version 2 storage this will revert the contents of tree to it's initial state when the file was first opened, or to the state captured with the last call to commit. Any transaction log data will be truncated.

Syntax

Visual Basic (Declaration)
Public Sub Rollback()
C#
public void Rollback()

Exceptions

Exception | Description
System.InvalidOperationException | Raised when called for a BPlusTree that is not using v2 files

Example

BPlusTree/BPlusTree.Test/BasicTestsVersion2.cs

C# Copy Code
using (BPlusTree<int, string> tree = Create(Options))
{
    tree.EnableCount();
    Assert.AreEqual(0, tree.Count);
    tree.Rollback();
    Assert.AreEqual(0, tree.Count);
    tree.Commit();
    Assert.AreEqual(0, tree.Count);

    tree.Add(1, "A");
    tree.Rollback();
    Assert.AreEqual(0, tree.Count);
    tree.Commit();
    Assert.AreEqual(0, tree.Count);

    tree.Add(1, "A");
    tree.Commit();
    Assert.AreEqual(1, tree.Count);
    tree.Rollback();
    Assert.AreEqual(1, tree.Count);

    tree.Add(2, "B");
    tree.Rollback();
    Assert.AreEqual(1, tree.Count);
    tree[1] = "abc";
    tree.Commit();
    Assert.AreEqual(1, tree.Count);
    tree.Rollback();

    Assert.AreEqual("abc", tree[1]);
    Assert.IsFalse(tree.ContainsKey(2));
}
VB.NET Copy Code
Using tree As BPlusTree(Of Integer, String) = Create(Options)
    tree.EnableCount()
    Assert.AreEqual(0, tree.Count)
    tree.Rollback()
    Assert.AreEqual(0, tree.Count)
    tree.Commit()
    Assert.AreEqual(0, tree.Count)

    tree.Add(1, "A")
    tree.Rollback()
    Assert.AreEqual(0, tree.Count)
    tree.Commit()
    Assert.AreEqual(0, tree.Count)

    tree.Add(1, "A")
    tree.Commit()
    Assert.AreEqual(1, tree.Count)
    tree.Rollback()
    Assert.AreEqual(1, tree.Count)

    tree.Add(2, "B")
    tree.Rollback()
    Assert.AreEqual(1, tree.Count)
    tree(1) = "abc"
    tree.Commit()
    Assert.AreEqual(1, tree.Count)
    tree.Rollback()

    Assert.AreEqual("abc", tree(1))
    Assert.IsFalse(tree.ContainsKey(2))
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : TryAdd Method

Glossary Item Box

Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.

Overload List

Overload | Description
TryAdd(TKey,Converter<TKey,TValue>) | Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.
TryAdd(TKey,TValue) | Adds an element with the provided key and value to the IDictionary.

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd(TKey,Converter<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > TryAdd Method : TryAdd(TKey,Converter<TKey,TValue>) Method

key
fnCreate

Glossary Item Box

Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryAdd( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue) _
) As Boolean
C#
public bool TryAdd(
   TKey key,
   Converter<TKey,TValue> fnCreate
)

Parameters

key
fnCreate

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
const int CountPerThread = 100;

BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using (WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, CountPerThread).Run);

    for (int i = 0; i < CountPerThread; i++)
    {
        if(i%2 == 0)
        {
            try {
                dictionary.TryAdd(new KeyInfo(Guid.NewGuid(), i), k => { throw new ExpectedException(); });
            } catch { }
        }
        else
        {
            try
            {
                dictionary.TryRemove(dictionary.First().Key, (k, v) => { throw new ExpectedException(); });
            }
            catch { }
        }
    }

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Const  CountPerThread As Integer = 100

        Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
        options.CalcBTreeOrder(32, 300)
        options.FileName = TempFile.TempPath
        options.CreateFile = CreatePolicy.Always

        Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
            Using work As New WorkQueue(Environment.ProcessorCount)
                Dim lastError As Exception = Nothing
                work.OnError += Function(o As Object, e As ErrorEventArgs) Do
                    lastError = e.GetException()
                End Function

                Dim i As Integer = 0
                While i < Environment.ProcessorCount
                    work.Enqueue(New ThreadedTest(dictionary, CountPerThread).Run)
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While

                Dim i As Integer = 0
                While i < CountPerThread
                    If i Mod 2 = 0 Then
                        Try
                            dictionary.TryAdd(New KeyInfo(Guid.NewGuid(), i), Function(k)
                            Throw New ExpectedException()

End Function)
                        Catch
                        End Try
                    Else
                        Try
                            dictionary.TryRemove(dictionary.First().Key, Function(k, v)
                            Throw New ExpectedException()

End Function)
                        Catch
                        End Try
                    End If
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While

                Assert.IsTrue(work.Complete(True, 60000))
                Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
            End Using
        End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > TryAdd Method : TryAdd(TKey,TValue) Method

key
value

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
public bool TryAdd(
   TKey key,
   TValue value
)

Parameters

key
value

Example

BPlusTree/BPlusTree.Test/TestFileSerialized.cs

C# Copy Code
try
{
    using (BPlusTree<int, string> tree = new BPlusTree<int, string>(Options))
    {
        Assert.IsTrue(tree.TryAdd(1, "hi"));
        TempFile.Delete();
    }
    Assert.Fail();
}
catch(IOException) { }
VB.NET Copy Code
Try
    Using tree As New BPlusTree(Of Integer, String)(Options)
        Assert.IsTrue(tree.TryAdd(1, "hi"))
        TempFile.Delete()
    End Using
    Assert.Fail()
Catch generatedExceptionName As IOException
End Try

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetFirst Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : TryGetFirst Method

item

Glossary Item Box

Returns the first key and it's associated value.

Syntax

Visual Basic (Declaration)
Public Function TryGetFirst( _
   ByRef item As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool TryGetFirst(
   out KeyValuePair<TKey,TValue> item
)

Parameters

item

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    data.Add(1, "a");
    data.Add(2, "b");
    data.Add(3, "c");
    data.Add(4, "d");
    data.Add(5, "e");

    Assert.AreEqual(1, data.First().Key);
    Assert.AreEqual("a", data.First().Value);
    data.Remove(1);
    Assert.AreEqual(2, data.First().Key);
    Assert.AreEqual("b", data.First().Value);

    Assert.AreEqual(5, data.Last().Key);
    Assert.AreEqual("e", data.Last().Value);
    data.Remove(5);
    Assert.AreEqual(4, data.Last().Key);
    Assert.AreEqual("d", data.Last().Value);

    data.Remove(4);
    data.Remove(3);

    KeyValuePair<int, string> kv;
    Assert.IsTrue(data.TryGetLast(out kv));
    Assert.IsTrue(data.TryGetFirst(out kv));
    data.Remove(2);
    Assert.IsFalse(data.TryGetLast(out kv));
    Assert.IsFalse(data.TryGetFirst(out kv));

    try { data.First(); Assert.Fail("Should raise InvalidOperationException"); }
    catch (InvalidOperationException) { }
    try { data.Last(); Assert.Fail("Should raise InvalidOperationException"); }
    catch (InvalidOperationException) { }
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.Add(1, "a")
    data.Add(2, "b")
    data.Add(3, "c")
    data.Add(4, "d")
    data.Add(5, "e")

    Assert.AreEqual(1, data.First().Key)
    Assert.AreEqual("a", data.First().Value)
    data.Remove(1)
    Assert.AreEqual(2, data.First().Key)
    Assert.AreEqual("b", data.First().Value)

    Assert.AreEqual(5, data.Last().Key)
    Assert.AreEqual("e", data.Last().Value)
    data.Remove(5)
    Assert.AreEqual(4, data.Last().Key)
    Assert.AreEqual("d", data.Last().Value)

    data.Remove(4)
    data.Remove(3)

    Dim kv As KeyValuePair(Of Integer, String)
    Assert.IsTrue(data.TryGetLast(kv))
    Assert.IsTrue(data.TryGetFirst(kv))
    data.Remove(2)
    Assert.IsFalse(data.TryGetLast(kv))
    Assert.IsFalse(data.TryGetFirst(kv))

    Try
        data.First()
        Assert.Fail("Should raise InvalidOperationException")
    Catch generatedExceptionName As InvalidOperationException
    End Try
    Try
        data.Last()
        Assert.Fail("Should raise InvalidOperationException")
    Catch generatedExceptionName As InvalidOperationException
    End Try
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Used By

KeyValuePair BPlusTree.First()

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetLast Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : TryGetLast Method

item

Glossary Item Box

Returns the last key and it's associated value.

Syntax

Visual Basic (Declaration)
Public Function TryGetLast( _
   ByRef item As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool TryGetLast(
   out KeyValuePair<TKey,TValue> item
)

Parameters

item

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    data.Add(1, "a");
    data.Add(2, "b");
    data.Add(3, "c");
    data.Add(4, "d");
    data.Add(5, "e");

    Assert.AreEqual(1, data.First().Key);
    Assert.AreEqual("a", data.First().Value);
    data.Remove(1);
    Assert.AreEqual(2, data.First().Key);
    Assert.AreEqual("b", data.First().Value);

    Assert.AreEqual(5, data.Last().Key);
    Assert.AreEqual("e", data.Last().Value);
    data.Remove(5);
    Assert.AreEqual(4, data.Last().Key);
    Assert.AreEqual("d", data.Last().Value);

    data.Remove(4);
    data.Remove(3);

    KeyValuePair<int, string> kv;
    Assert.IsTrue(data.TryGetLast(out kv));
    Assert.IsTrue(data.TryGetFirst(out kv));
    data.Remove(2);
    Assert.IsFalse(data.TryGetLast(out kv));
    Assert.IsFalse(data.TryGetFirst(out kv));

    try { data.First(); Assert.Fail("Should raise InvalidOperationException"); }
    catch (InvalidOperationException) { }
    try { data.Last(); Assert.Fail("Should raise InvalidOperationException"); }
    catch (InvalidOperationException) { }
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.Add(1, "a")
    data.Add(2, "b")
    data.Add(3, "c")
    data.Add(4, "d")
    data.Add(5, "e")

    Assert.AreEqual(1, data.First().Key)
    Assert.AreEqual("a", data.First().Value)
    data.Remove(1)
    Assert.AreEqual(2, data.First().Key)
    Assert.AreEqual("b", data.First().Value)

    Assert.AreEqual(5, data.Last().Key)
    Assert.AreEqual("e", data.Last().Value)
    data.Remove(5)
    Assert.AreEqual(4, data.Last().Key)
    Assert.AreEqual("d", data.Last().Value)

    data.Remove(4)
    data.Remove(3)

    Dim kv As KeyValuePair(Of Integer, String)
    Assert.IsTrue(data.TryGetLast(kv))
    Assert.IsTrue(data.TryGetFirst(kv))
    data.Remove(2)
    Assert.IsFalse(data.TryGetLast(kv))
    Assert.IsFalse(data.TryGetFirst(kv))

    Try
        data.First()
        Assert.Fail("Should raise InvalidOperationException")
    Catch generatedExceptionName As InvalidOperationException
    End Try
    Try
        data.Last()
        Assert.Fail("Should raise InvalidOperationException")
    Catch generatedExceptionName As InvalidOperationException
    End Try
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Used By

KeyValuePair BPlusTree.Last()

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : TryGetValue Method

key
value

Glossary Item Box

Gets the value associated with the specified key.

Syntax

Visual Basic (Declaration)
Public Function TryGetValue( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
public bool TryGetValue(
   TKey key,
   out TValue value
)

Parameters

key
value

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
string test;
using (BPlusTree<int, string> data = Create(Options))
{
    data.Add(2, "v2");
    data.Add(1, "v1");

    int i = 0;
    for (; i < 8; i++)
        data.TryAdd(i, "v" + i);
    for (i = 16; i >= 8; i--)
        data.TryAdd(i, "v" + i);
    data.TryAdd(13, "v" + i);

    for (i = 0; i <= 16; i++)
    {
        if (!data.TryGetValue(i, out test))
            throw new ApplicationException();
        Assert.AreEqual("v" + i, test);
    }

    data.Remove(1);
    data.Remove(3);
    IEnumerator<KeyValuePair<int, string>> e = data.GetEnumerator();
    Assert.IsTrue(e.MoveNext());
    Assert.AreEqual(0, e.Current.Key);
    data.Add(1, "v1");
    Assert.IsTrue(e.MoveNext());
    data.Add(3, "v3");
    Assert.IsTrue(e.MoveNext());
    data.Remove(8);
    Assert.IsTrue(e.MoveNext());
    e.Dispose();
    data.Add(8, "v8");

    i = 0;
    foreach (KeyValuePair<int, string> pair in data)
        Assert.AreEqual(pair.Key, i++);

    for (i = 0; i <= 16; i++)
        Assert.IsTrue(data.Remove(i) && data.TryAdd(i, "v" + i));

    for (i = 6; i <= 12; i++)
        Assert.IsTrue(data.Remove(i));

    for (i = 6; i <= 12; i++)
    {
        Assert.IsFalse(data.TryGetValue(i, out test));
        Assert.IsNull(test);
    }

    for (i = 0; i <= 5; i++)
    {
        Assert.IsTrue(data.TryGetValue(i, out test));
        Assert.AreEqual("v" + i, test);
    }

    for (i = 13; i <= 16; i++)
    {
        Assert.IsTrue(data.TryGetValue(i, out test));
        Assert.AreEqual("v" + i, test);
    }

    for (i = 0; i <= 16; i++)
        Assert.AreEqual(i < 6 || i > 12, data.Remove(i));
}
VB.NET Copy Code
Dim test As String
Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.Add(2, "v2")
    data.Add(1, "v1")

    Dim i As Integer = 0
    While i < 8
        data.TryAdd(i, "v" + i)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    i = 16
    While i >= 8
        data.TryAdd(i, "v" + i)
        System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
    End While
    data.TryAdd(13, "v" + i)

    i = 0
    While i <= 16
        If Not data.TryGetValue(i, test) Then
            Throw New ApplicationException()
        End If
        Assert.AreEqual("v" + i, test)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    data.Remove(1)
    data.Remove(3)
    Dim e As IEnumerator(Of KeyValuePair(Of Integer, String)) = data.GetEnumerator()
    Assert.IsTrue(e.MoveNext())
    Assert.AreEqual(0, e.Current.Key)
    data.Add(1, "v1")
    Assert.IsTrue(e.MoveNext())
    data.Add(3, "v3")
    Assert.IsTrue(e.MoveNext())
    data.Remove(8)
    Assert.IsTrue(e.MoveNext())
    e.Dispose()
    data.Add(8, "v8")

    i = 0
    For Each pair As KeyValuePair(Of Integer, String) In data
        Assert.AreEqual(pair.Key, System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1))
    Next

    i = 0
    While i <= 16
        Assert.IsTrue(data.Remove(i) AndAlso data.TryAdd(i, "v" + i))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    i = 6
    While i <= 12
        Assert.IsTrue(data.Remove(i))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    i = 6
    While i <= 12
        Assert.IsFalse(data.TryGetValue(i, test))
        Assert.IsNull(test)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    i = 0
    While i <= 5
        Assert.IsTrue(data.TryGetValue(i, test))
        Assert.AreEqual("v" + i, test)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    i = 13
    While i <= 16
        Assert.IsTrue(data.TryGetValue(i, test))
        Assert.AreEqual("v" + i, test)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    i = 0
    While i <= 16
        Assert.AreEqual(i < 6 OrElse i > 12, data.Remove(i))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Used By

Boolean BPlusTree.ContainsKey(TKey)

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : TryRemove Method

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Overload List

Overload | Description
TryRemove(TKey,TValue) | Removes the element with the specified key from the IDictionary.
TryRemove(TKey,KeyValuePredicate<TKey,TValue>) | Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.
TryRemove<T>(TKey,T) | Conditionally removes a key/value pair from the dictionary via an implementation of the IRemoveValue<TKey,TValue> interface.

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > TryRemove Method : TryRemove(TKey,TValue) Method

key
The key of the element to remove.
value
The value that was removed.

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
public bool TryRemove(
   TKey key,
   out TValue value
)

Parameters

key
The key of the element to remove.
value
The value that was removed.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary.

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    Assert.IsTrue(data.TryAdd(1, "a"));
    Assert.IsFalse(data.TryAdd(1, "a"));

    Assert.IsTrue(data.TryUpdate(1, "a"));
    Assert.IsTrue(data.TryUpdate(1, "c"));
    Assert.IsTrue(data.TryUpdate(1, "d", "c"));
    Assert.IsFalse(data.TryUpdate(1, "f", "c"));
    Assert.AreEqual("d", data[1]);
    Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
    Assert.AreEqual("a", data[1]);
    Assert.IsFalse(data.TryUpdate(2, "b"));

    string val;
    Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
    Assert.IsFalse(data.TryRemove(2, out val));
    Assert.AreNotEqual(val, "a");
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    Assert.IsTrue(data.TryAdd(1, "a"))
    Assert.IsFalse(data.TryAdd(1, "a"))

    Assert.IsTrue(data.TryUpdate(1, "a"))
    Assert.IsTrue(data.TryUpdate(1, "c"))
    Assert.IsTrue(data.TryUpdate(1, "d", "c"))
    Assert.IsFalse(data.TryUpdate(1, "f", "c"))
    Assert.AreEqual("d", data(1))
    Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
    Assert.AreEqual("a", data(1))
    Assert.IsFalse(data.TryUpdate(2, "b"))

    Dim val As String
    Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
    Assert.IsFalse(data.TryRemove(2, val))
    Assert.AreNotEqual(val, "a")
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove(TKey,KeyValuePredicate<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > TryRemove Method : TryRemove(TKey,KeyValuePredicate<TKey,TValue>) Method

key
fnCondition

Glossary Item Box

Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove( _
   ByVal key As TKey, _
   ByVal fnCondition As CSharpTest.Net.Collections.KeyValuePredicate(Of TKey,TValue) _
) As Boolean
C#
public bool TryRemove(
   TKey key,
   CSharpTest.Net.Collections.KeyValuePredicate<TKey,TValue> fnCondition
)

Parameters

key
fnCondition

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
const int CountPerThread = 100;

BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using (WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, CountPerThread).Run);

    for (int i = 0; i < CountPerThread; i++)
    {
        if(i%2 == 0)
        {
            try {
                dictionary.TryAdd(new KeyInfo(Guid.NewGuid(), i), k => { throw new ExpectedException(); });
            } catch { }
        }
        else
        {
            try
            {
                dictionary.TryRemove(dictionary.First().Key, (k, v) => { throw new ExpectedException(); });
            }
            catch { }
        }
    }

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Const  CountPerThread As Integer = 100

        Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
        options.CalcBTreeOrder(32, 300)
        options.FileName = TempFile.TempPath
        options.CreateFile = CreatePolicy.Always

        Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
            Using work As New WorkQueue(Environment.ProcessorCount)
                Dim lastError As Exception = Nothing
                work.OnError += Function(o As Object, e As ErrorEventArgs) Do
                    lastError = e.GetException()
                End Function

                Dim i As Integer = 0
                While i < Environment.ProcessorCount
                    work.Enqueue(New ThreadedTest(dictionary, CountPerThread).Run)
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While

                Dim i As Integer = 0
                While i < CountPerThread
                    If i Mod 2 = 0 Then
                        Try
                            dictionary.TryAdd(New KeyInfo(Guid.NewGuid(), i), Function(k)
                            Throw New ExpectedException()

End Function)
                        Catch
                        End Try
                    Else
                        Try
                            dictionary.TryRemove(dictionary.First().Key, Function(k, v)
                            Throw New ExpectedException()

End Function)
                        Catch
                        End Try
                    End If
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While

                Assert.IsTrue(work.Complete(True, 60000))
                Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
            End Using
        End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List
KeyValuePredicate

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
TryRemove<T>(TKey,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > TryRemove Method : TryRemove<T>(TKey,T) Method

key
removeValue

Glossary Item Box

Conditionally removes a key/value pair from the dictionary via an implementation of the IRemoveValue<TKey,TValue> interface.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove(Of T As IRemoveValue(Of TKey,TValue))( _
   ByVal key As TKey, _
   ByRef removeValue As T _
) As Boolean
C#
public bool TryRemove<T>(
   TKey key,
   ref T removeValue
)
where T: IRemoveValue<TKey,TValue>

Parameters

key
removeValue

Type Parameters

T

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : TryUpdate Method

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Overload List

Overload | Description
TryUpdate(TKey,TValue) | Updates an element with the provided key to the value if it exists.
TryUpdate(TKey,TValue,TValue) | Updates an element with the provided key to the value if it exists.
TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) | Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the tree lock. Be cautious about the behavior and performance of the code provided as it can cause a dead-lock to occur. If the method returns an instance who .Equals the original, no update is applied.

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Return Value

Returns true if the key provided was found and updated to the value.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    Assert.IsTrue(data.TryAdd(1, "a"));
    Assert.IsFalse(data.TryAdd(1, "a"));

    Assert.IsTrue(data.TryUpdate(1, "a"));
    Assert.IsTrue(data.TryUpdate(1, "c"));
    Assert.IsTrue(data.TryUpdate(1, "d", "c"));
    Assert.IsFalse(data.TryUpdate(1, "f", "c"));
    Assert.AreEqual("d", data[1]);
    Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
    Assert.AreEqual("a", data[1]);
    Assert.IsFalse(data.TryUpdate(2, "b"));

    string val;
    Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
    Assert.IsFalse(data.TryRemove(2, out val));
    Assert.AreNotEqual(val, "a");
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    Assert.IsTrue(data.TryAdd(1, "a"))
    Assert.IsFalse(data.TryAdd(1, "a"))

    Assert.IsTrue(data.TryUpdate(1, "a"))
    Assert.IsTrue(data.TryUpdate(1, "c"))
    Assert.IsTrue(data.TryUpdate(1, "d", "c"))
    Assert.IsFalse(data.TryUpdate(1, "f", "c"))
    Assert.AreEqual("d", data(1))
    Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
    Assert.AreEqual("a", data(1))
    Assert.IsFalse(data.TryUpdate(2, "b"))

    Dim val As String
    Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
    Assert.IsFalse(data.TryRemove(2, val))
    Assert.AreNotEqual(val, "a")
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,TValue,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue, _
   ByVal comparisonValue As TValue _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   TValue value,
   TValue comparisonValue
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Return Value

Returns true if the key provided was found and updated to the value.

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    Assert.IsTrue(data.TryAdd(1, "a"));
    Assert.IsFalse(data.TryAdd(1, "a"));

    Assert.IsTrue(data.TryUpdate(1, "a"));
    Assert.IsTrue(data.TryUpdate(1, "c"));
    Assert.IsTrue(data.TryUpdate(1, "d", "c"));
    Assert.IsFalse(data.TryUpdate(1, "f", "c"));
    Assert.AreEqual("d", data[1]);
    Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
    Assert.AreEqual("a", data[1]);
    Assert.IsFalse(data.TryUpdate(2, "b"));

    string val;
    Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
    Assert.IsFalse(data.TryRemove(2, out val));
    Assert.AreNotEqual(val, "a");
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    Assert.IsTrue(data.TryAdd(1, "a"))
    Assert.IsFalse(data.TryAdd(1, "a"))

    Assert.IsTrue(data.TryUpdate(1, "a"))
    Assert.IsTrue(data.TryUpdate(1, "c"))
    Assert.IsTrue(data.TryUpdate(1, "d", "c"))
    Assert.IsFalse(data.TryUpdate(1, "f", "c"))
    Assert.AreEqual("d", data(1))
    Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
    Assert.AreEqual("a", data(1))
    Assert.IsFalse(data.TryUpdate(2, "b"))

    Dim val As String
    Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
    Assert.IsFalse(data.TryRemove(2, val))
    Assert.AreNotEqual(val, "a")
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) Method

key
fnUpdate

Glossary Item Box

Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the tree lock. Be cautious about the behavior and performance of the code provided as it can cause a dead-lock to occur. If the method returns an instance who .Equals the original, no update is applied.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
fnUpdate

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UnloadCache Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : UnloadCache Method

Glossary Item Box

Safely removes all items from the in-memory cache.

Syntax

Visual Basic (Declaration)
Public Sub UnloadCache()
C#
public void UnloadCache()

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    data.EnableCount();

    int[][] TestArrays = new int[][]
    {
        new int[] { 10, 18, 81, 121, 76, 31, 250, 174, 24, 38, 246, 79 },
        new int[] { 110,191,84,218,170,217,199,232,184,254,32,90,241,136,181,28,226,69,52 },
    };

    foreach (int[] arry in TestArrays)
    {
        data.Clear();
        Assert.AreEqual(0, data.Count);

        int count = 0;
        foreach (int id in arry)
        {
            data.Add(id, id.ToString());
            Assert.AreEqual(++count, data.Count);
        }

        Assert.AreEqual(arry.Length, data.Count);
        data.UnloadCache();

        foreach (int id in arry)
        {
            Assert.AreEqual(id.ToString(), data[id]);
            data[id] = String.Empty;
            Assert.AreEqual(String.Empty, data[id]);

            Assert.IsTrue(data.Remove(id));
            Assert.AreEqual(--count, data.Count);
        }

        Assert.AreEqual(0, data.Count);
    }
}
VB.NET Copy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.EnableCount()

    Dim TestArrays As Integer()() = New Integer()() {New Integer() {10, 18, 81, 121, 76, 31, _
        250, 174, 24, 38, 246, 79}, New Integer() {110, 191, 84, 218, 170, 217, _
        199, 232, 184, 254, 32, 90, _
        241, 136, 181, 28, 226, 69, _
        52}}

    For Each arry As Integer() In TestArrays
        data.Clear()
        Assert.AreEqual(0, data.Count)

        Dim count As Integer = 0
        For Each id As Integer In arry
            data.Add(id, id.ToString())
            Assert.AreEqual(System.Threading.Interlocked.Increment(count), data.Count)
        Next

        Assert.AreEqual(arry.Length, data.Count)
        data.UnloadCache()

        For Each id As Integer In arry
            Assert.AreEqual(id.ToString(), data(id))
            data(id) = [String].Empty
            Assert.AreEqual([String].Empty, data(id))

            Assert.IsTrue(data.Remove(id))
            Assert.AreEqual(System.Threading.Interlocked.Decrement(count), data.Count)
        Next

        Assert.AreEqual(0, data.Count)
    Next
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Validate() Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Validate() Method

Glossary Item Box

Forces a top-down, depth-first, crawl of the entire tree in which every node and every link or key is checked for accuracy. Throws on error.

Syntax

Visual Basic (Declaration)
Public Sub Validate()
C#
public void Validate()

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Debug.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BPlusTree<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BPlusTree<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | CallLevelLock | Defines the lock used to provide tree-level exclusive operations. This should be set at the time of construction, or not at all since operations depending on this (Clear, EnableCount, and UnloadCache) may behave poorly if operations that started prior to setting this value are still being processed. Out of the locks I've tested the ReaderWriterLocking implementation performs best here since it is a highly read-intensive lock. All public APIs that access tree content will aquire this lock as a reader except the tree exclusive operations. This also allows you, by way of aquiring a write lock, to gain exclusive access and perform mass updates, atomic enumeration, etc.
Public Property | Count | See comments on EnableCount() for usage of this property
Public Property | IsReadOnly | Returns true if the file was opened in ReadOnly mode.
Public Property | Item | Gets or sets the element with the specified key.
Public Property | Keys | Gets an ICollection containing the keys of the IDictionary.
Public Property | Values | Gets an ICollection containing the values in the IDictionary.
Top

See Also

Reference

BPlusTree<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CallLevelLock Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : CallLevelLock Property

Glossary Item Box

Defines the lock used to provide tree-level exclusive operations. This should be set at the time of construction, or not at all since operations depending on this (Clear, EnableCount, and UnloadCache) may behave poorly if operations that started prior to setting this value are still being processed. Out of the locks I've tested the ReaderWriterLocking implementation performs best here since it is a highly read-intensive lock. All public APIs that access tree content will aquire this lock as a reader except the tree exclusive operations. This also allows you, by way of aquiring a write lock, to gain exclusive access and perform mass updates, atomic enumeration, etc.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CallLevelLock As ILockStrategy
C#
public ILockStrategy CallLevelLock {get;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<int, int>.OptionsV2 options = new BPlusTree<int, int>.OptionsV2(
    new PrimitiveSerializer(), new PrimitiveSerializer());
options.LockTimeout = 100;
options.CallLevelLock = new ReaderWriterLocking();

using (BPlusTree<int, int> dictionary = new BPlusTree<int, int>(options))
{
    bool canwrite = false, canread = false;
    ThreadStart proc = delegate()
    {
        try { dictionary[1] = 1; canwrite = true; } catch { canwrite = false; }
        try { int i; dictionary.TryGetValue(1, out i); canread = true; } catch { canread = false; }
    };

    Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
    Assert.IsTrue(canwrite);
    Assert.IsTrue(canread);

    //now we lock the entire btree:
    using (dictionary.CallLevelLock.Write())
    {
        //they can't read or write
        Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
        Assert.IsFalse(canwrite);
        Assert.IsFalse(canread);
        //but we can
        proc();
        Assert.IsTrue(canwrite);
        Assert.IsTrue(canread);
    }
    //lock release all is well
    Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
    Assert.IsTrue(canwrite);
    Assert.IsTrue(canread);

    //We can also make sure noone else gains exclusive access with a read lock
    using (dictionary.CallLevelLock.Read())
    {
        Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
        Assert.IsTrue(canwrite);
        Assert.IsTrue(canread);
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of Integer, Integer).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer())
options.LockTimeout = 100
options.CallLevelLock = New ReaderWriterLocking()

Using dictionary As New BPlusTree(Of Integer, Integer)(options)
    Dim canwrite As Boolean = False, canread As Boolean = False
    Dim proc As ThreadStart = Function() Do
        Try
            dictionary(1) = 1
            canwrite = True
        Catch
            canwrite = False
        End Try
        Try
            Dim i As Integer
            dictionary.TryGetValue(1, i)
            canread = True
        Catch
            canread = False
        End Try
    End Function

    Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
    Assert.IsTrue(canwrite)
    Assert.IsTrue(canread)

    'now we lock the entire btree:
    Using dictionary.CallLevelLock.Write()
        'they can't read or write
        Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
        Assert.IsFalse(canwrite)
        Assert.IsFalse(canread)
        'but we can
        proc()
        Assert.IsTrue(canwrite)
        Assert.IsTrue(canread)
    End Using
    'lock release all is well
    Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
    Assert.IsTrue(canwrite)
    Assert.IsTrue(canread)

    'We can also make sure noone else gains exclusive access with a read lock
    Using dictionary.CallLevelLock.Read()
        Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
        Assert.IsTrue(canwrite)
        Assert.IsTrue(canread)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members
ILockStrategy

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Count Property

Glossary Item Box

See comments on EnableCount() for usage of this property

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReadOnly Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : IsReadOnly Property

Glossary Item Box

Returns true if the file was opened in ReadOnly mode.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReadOnly As Boolean
C#
public bool IsReadOnly {get;}

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Used By

BPlusTree.Dispose()

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Item Property

key

Glossary Item Box

Gets or sets the element with the specified key.

Syntax

Visual Basic (Declaration)
Public Default Property Item( _
   ByVal key As TKey _
) As TValue
C#
public TValue this[
   TKey key
]; {get; set;}

Parameters

key

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Keys Property

Glossary Item Box

Gets an ICollection containing the keys of the IDictionary.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As ICollection(Of TKey)
C#
public ICollection<TKey> Keys {get;}

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
List<KeyValuePair<int, string>> sample = new List<KeyValuePair<int, string>>();
for (int i = 0; i < 20; i++)
    sample.Add(new KeyValuePair<int,string>(i, i.ToString()));

using (BPlusTree<int, string> data = Create(Options))
{
    data.AddRange(sample);
    //Key collection
    Assert.AreEqual(data.Count, data.Keys.Count);
    Assert.IsTrue(data.Keys.IsReadOnly);
    for (int i = 0; i < sample.Count && i < 5; i++)
        Assert.IsTrue(data.Keys.Contains(sample[i].Key));

    IEnumerator<int> ek = data.Keys.GetEnumerator();
    Assert.IsTrue(ek.MoveNext());
    int firstkey = ek.Current;
    Assert.IsTrue(ek.MoveNext());
    Assert.AreNotEqual(firstkey, ek.Current);
    ek.Reset();
    Assert.IsTrue(ek.MoveNext());
    Assert.AreEqual(firstkey, ek.Current);
    Assert.AreEqual(firstkey, ((System.Collections.IEnumerator) ek).Current);

    //Value collection
    Assert.AreEqual(data.Count, data.Values.Count);
    Assert.IsTrue(data.Values.IsReadOnly);
    for (int i = 0; i < sample.Count && i < 5; i++)
        Assert.IsTrue(data.Values.Contains(sample[i].Value));

    IEnumerator<string> ev = data.Values.GetEnumerator();
    Assert.IsTrue(ev.MoveNext());
    string firstvalue = ev.Current;
    Assert.IsTrue(ev.MoveNext());
    Assert.AreNotEqual(firstvalue, ev.Current);
    ev.Reset();
    Assert.IsTrue(ev.MoveNext());
    Assert.AreEqual(firstvalue, ((System.Collections.IEnumerator) ev).Current);
}
VB.NET Copy Code
Dim sample As New List(Of KeyValuePair(Of Integer, String))()
Dim i As Integer = 0
While i < 20
    sample.Add(New KeyValuePair(Of Integer, String)(i, i.ToString()))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.AddRange(sample)
    'Key collection
    Assert.AreEqual(data.Count, data.Keys.Count)
    Assert.IsTrue(data.Keys.IsReadOnly)
    Dim i As Integer = 0
    While i < sample.Count AndAlso i < 5
        Assert.IsTrue(data.Keys.Contains(sample(i).Key))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    Dim ek As IEnumerator(Of Integer) = data.Keys.GetEnumerator()
    Assert.IsTrue(ek.MoveNext())
    Dim firstkey As Integer = ek.Current
    Assert.IsTrue(ek.MoveNext())
    Assert.AreNotEqual(firstkey, ek.Current)
    ek.Reset()
    Assert.IsTrue(ek.MoveNext())
    Assert.AreEqual(firstkey, ek.Current)
    Assert.AreEqual(firstkey, (DirectCast(ek, System.Collections.IEnumerator)).Current)

    'Value collection
    Assert.AreEqual(data.Count, data.Values.Count)
    Assert.IsTrue(data.Values.IsReadOnly)
    Dim i As Integer = 0
    While i < sample.Count AndAlso i < 5
        Assert.IsTrue(data.Values.Contains(sample(i).Value))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    Dim ev As IEnumerator(Of String) = data.Values.GetEnumerator()
    Assert.IsTrue(ev.MoveNext())
    Dim firstvalue As String = ev.Current
    Assert.IsTrue(ev.MoveNext())
    Assert.AreNotEqual(firstvalue, ev.Current)
    ev.Reset()
    Assert.IsTrue(ev.MoveNext())
    Assert.AreEqual(firstvalue, (DirectCast(ev, System.Collections.IEnumerator)).Current)
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Values Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Values Property

Glossary Item Box

Gets an ICollection containing the values in the IDictionary.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Values As ICollection(Of TValue)
C#
public ICollection<TValue> Values {get;}

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C# Copy Code
List<KeyValuePair<int, string>> sample = new List<KeyValuePair<int, string>>();
for (int i = 0; i < 20; i++)
    sample.Add(new KeyValuePair<int,string>(i, i.ToString()));

using (BPlusTree<int, string> data = Create(Options))
{
    data.AddRange(sample);
    //Key collection
    Assert.AreEqual(data.Count, data.Keys.Count);
    Assert.IsTrue(data.Keys.IsReadOnly);
    for (int i = 0; i < sample.Count && i < 5; i++)
        Assert.IsTrue(data.Keys.Contains(sample[i].Key));

    IEnumerator<int> ek = data.Keys.GetEnumerator();
    Assert.IsTrue(ek.MoveNext());
    int firstkey = ek.Current;
    Assert.IsTrue(ek.MoveNext());
    Assert.AreNotEqual(firstkey, ek.Current);
    ek.Reset();
    Assert.IsTrue(ek.MoveNext());
    Assert.AreEqual(firstkey, ek.Current);
    Assert.AreEqual(firstkey, ((System.Collections.IEnumerator) ek).Current);

    //Value collection
    Assert.AreEqual(data.Count, data.Values.Count);
    Assert.IsTrue(data.Values.IsReadOnly);
    for (int i = 0; i < sample.Count && i < 5; i++)
        Assert.IsTrue(data.Values.Contains(sample[i].Value));

    IEnumerator<string> ev = data.Values.GetEnumerator();
    Assert.IsTrue(ev.MoveNext());
    string firstvalue = ev.Current;
    Assert.IsTrue(ev.MoveNext());
    Assert.AreNotEqual(firstvalue, ev.Current);
    ev.Reset();
    Assert.IsTrue(ev.MoveNext());
    Assert.AreEqual(firstvalue, ((System.Collections.IEnumerator) ev).Current);
}
VB.NET Copy Code
Dim sample As New List(Of KeyValuePair(Of Integer, String))()
Dim i As Integer = 0
While i < 20
    sample.Add(New KeyValuePair(Of Integer, String)(i, i.ToString()))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.AddRange(sample)
    'Key collection
    Assert.AreEqual(data.Count, data.Keys.Count)
    Assert.IsTrue(data.Keys.IsReadOnly)
    Dim i As Integer = 0
    While i < sample.Count AndAlso i < 5
        Assert.IsTrue(data.Keys.Contains(sample(i).Key))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    Dim ek As IEnumerator(Of Integer) = data.Keys.GetEnumerator()
    Assert.IsTrue(ek.MoveNext())
    Dim firstkey As Integer = ek.Current
    Assert.IsTrue(ek.MoveNext())
    Assert.AreNotEqual(firstkey, ek.Current)
    ek.Reset()
    Assert.IsTrue(ek.MoveNext())
    Assert.AreEqual(firstkey, ek.Current)
    Assert.AreEqual(firstkey, (DirectCast(ek, System.Collections.IEnumerator)).Current)

    'Value collection
    Assert.AreEqual(data.Count, data.Values.Count)
    Assert.IsTrue(data.Values.IsReadOnly)
    Dim i As Integer = 0
    While i < sample.Count AndAlso i < 5
        Assert.IsTrue(data.Values.Contains(sample(i).Value))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    Dim ev As IEnumerator(Of String) = data.Values.GetEnumerator()
    Assert.IsTrue(ev.MoveNext())
    Dim firstvalue As String = ev.Current
    Assert.IsTrue(ev.MoveNext())
    Assert.AreNotEqual(firstvalue, ev.Current)
    ev.Reset()
    Assert.IsTrue(ev.MoveNext())
    Assert.AreEqual(firstvalue, (DirectCast(ev, System.Collections.IEnumerator)).Current)
End Using

Requirements

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

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
BPlusTree.Options<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.Options<TKey,TValue> Class

Glossary Item Box

Defines the options nessessary to construct a BPlusTree implementation

Object Model

BPlusTree.Options<TKey,TValue> ClassILockStrategy InterfaceILockFactory InterfaceINodeStorage Interface

Syntax

Visual Basic (Declaration)
Public NotInheritable Class BPlusTree.Options
    (Of TKey,TValue)
   Inherits BPlusTreeOptions(Of TKey,TValue)
C#
public sealed class BPlusTree.Options<TKey,TValue> : BPlusTreeOptions<TKey,TValue>

Type Parameters

TKey
TValue

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.Options options = new BPlusTree<KeyInfo, DataValue>.Options(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (TempFile copy = new TempFile())
{
    copy.Delete();
    int minRecordCreated = StartAndAbortWriters(options, copy);

    using (TempFile.Attach(copy.TempPath + ".recovered")) //used to create the new copy
    using (TempFile.Attach(copy.TempPath + ".deleted"))  //renamed existing file
    {
        options.CreateFile = CreatePolicy.Never;
        int recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        if (recoveredRecords < RecordsCreated)
            Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated);

        options.FileName = copy.TempPath;
        recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords);

        using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
        {
            dictionary.EnableCount();
            Assert.AreEqual(recoveredRecords, dictionary.Count);

            foreach (KeyValuePair<KeyInfo, DataValue> kv in dictionary)
            {
                Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID);
                dictionary.Remove(kv.Key);
            }

            Assert.AreEqual(0, dictionary.Count);
        }
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always

Using copy As New TempFile()
    copy.Delete()
    Dim minRecordCreated As Integer = StartAndAbortWriters(options, copy)

    Using TempFile.Attach(copy.TempPath + ".recovered")
        'used to create the new copy
        Using TempFile.Attach(copy.TempPath + ".deleted")
            'renamed existing file
            options.CreateFile = CreatePolicy.Never
            Dim recoveredRecords As Integer = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            If recoveredRecords < RecordsCreated Then
                Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated)
            End If

            options.FileName = copy.TempPath
            recoveredRecords = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords)

            Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
                dictionary.EnableCount()
                Assert.AreEqual(recoveredRecords, dictionary.Count)

                For Each kv As KeyValuePair(Of KeyInfo, DataValue) In dictionary
                    Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID)
                    dictionary.Remove(kv.Key)
                Next

                Assert.AreEqual(0, dictionary.Count)
            End Using
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>
CSharpTest.Net.Collections.BPlusTree`2.Options<TKey,TValue>

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Members
CSharpTest.Net.Collections Namespace
Int32 BPlusTree.RecoverFile(BPlusTree.Options)
IEnumerable> BPlusTree.RecoveryScan(BPlusTree.Options,FileShare)

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.Options BPlusTree.Options.Clone()


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BPlusTree.Options<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.Options<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by BPlusTree.Options<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | BPlusTree.Options<TKey,TValue> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | BTreeOrder | A quick means of setting all the min/max values for the node counts using this value as a basis for the Maximum fields and one-quarter of this value for Minimum fields provided the result is in range. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveFactory | CacheKeepAliveFactory provides a delegate to inject an implementation of the IObjectKeepAlive interface while then igoring all the other CacheKeepAliveXXX properties. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveMaximumHistory | Determins maximum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. The ceiling is always respected reguardless of the timeout. Specify a value of 0 to disable history keep alive. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveMinimumHistory | Determins minimum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. This number will always be kept reguardless of the timeout. Specify a value of 0 to allow the timeout to empty the cache. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveTimeout | If the cache contains more that CacheKeepAliveMinimumHistory items, this timeout will start to remove those items until the cache history is reduced to CacheKeepAliveMinimumHistory. It is important to know that the BPlusTree itself contains no theads and this timeout will not be respected if cache is not in use. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CachePolicy | Determines how long loaded nodes stay in memory, Full keeps all loaded nodes alive and is the most efficient, The default Recent keeps recently visited nodes alive based on the CacheKeepAlive properties, and None does not cache the nodes at all but does maintain a cache of locks for each node visited. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CallLevelLock | Defines a reader/writer lock that used to control exclusive tree access when needed. The public methods for EnableCount(), Clear(), and UnloadCache() each acquire an exclusive (write) lock while all other public methods acquire a shared (read) lock. By default this lock is non-operational (an instance of IgnoreLocking) so if you need the above methods to work while multiple threads are accessing the tree, or if you exclusive access to the tree, specify a lock instance. Since this lock is primarily a read-heavy lock consider using the ReaderWriterLocking or SimpleReadWriteLocking. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ConcurrentWriters | Gets or sets the number of streams that will be created for threads to write in the file store
Public Property | CreateFile | Gets or sets the file-create policy used when backing with a file storage (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileBlockSize | Gets or sets the number of bytes per file-block used in the file storage (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileGrowthRate | Gets or sets the number of blocks that a file will grow by when all blocks are used, use zero for incremental growth
Public Property | FileName | Gets or sets the FileName that should be used to store the BTree (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileOpenOptions | Gets or sets the number of bytes per file-block used in the file storage
Public Property | FileVersion | Overridden. Returns the version this option set is compatable with.
Public Property | KeyComparer | Defines a custom IComparer<T> to be used for comparing keys (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | KeySerializer | Accesses the key serializer given to the constructor (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | LockingFactory | Gets or sets the locking factory to use for accessing shared data. The default is WriterOnlyLocking() which does not perform read locks, rather it will rely on the cache of the btree and may preform dirty reads. You can use any implementation of ILockFactory; however, the SimpleReadWriteLocking seems to perform the most efficiently for both reader/writer locks. Additionally wrapping that instance in a ReserveredWriterLocking() instance will allow reads to continue up until a writer begins the commit process. If you are only accessing the BTree instance from a single thread this can be set to IgnoreLocking. Be careful of using ReaderWriterLocking as the write-intesive nature of the BTree will suffer extreme performance penalties with this lock. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | LockTimeout | Gets or sets the number of milliseconds to wait before failing a lock request, the default of two minutes should be more than adequate. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MaximumChildNodes | The largest number of child nodes that should be linked to before refactoring the tree to split this node into two. This property has a side-effect on MinimumChildNodes to ensure that it continues to be at most half of MaximumChildNodes. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MaximumValueNodes | The largest number of values that should be contained in this node before refactoring the tree to split this node into two. This property has a side-effect on MinimumValueNodes to ensure that it continues to be at most half of MaximumValueNodes. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MinimumChildNodes | The smallest number of child nodes that should be linked to before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MinimumValueNodes | The smallest number of values that should be contained in this node before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ReadOnly | Sets the BTree into a read-only mode (only supported when opening an existing file) (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | StorageSystem | Sets the custom implementation of the storage back-end to use for the BTree (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | StorageType | Can be used to explicitly specify the storage type, or by simply providing a file name this will be done for you. If no file name was specified the default is to use a memory store. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ValueSerializer | Accesses the key serializer given to the constructor (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Top

Public Methods

 | Name | Description
Public Method | CalcBTreeOrder | Calculates default node-threasholds based upon the average number of bytes in key and value
Public Method | Clone | Creates a shallow clone of the configuration options.
Top

Protected Methods

 | Name | Description
Protected Method | CalculateOrder | Overridden. Calculates default node-threasholds based upon the average number of bytes in key and value
Protected Method | SetLogFile | Sets the transaction log to use (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Protected Method | SetStorageCache | Enables or disables the caching and reordering of node write operations (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Top

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
Int32 BPlusTree.RecoverFile(BPlusTree.Options)
IEnumerable> BPlusTree.RecoveryScan(BPlusTree.Options,FileShare)

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.Options BPlusTree.Options.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree.Options<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class : BPlusTree.Options<TKey,TValue> Constructor

Glossary Item Box

Overload List

Overload | Description
BPlusTree.Options<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>) | Constructs the options configuration to initialize a BPlusTree instance using the default Comparer for TKey
BPlusTree.Options<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>,IComparer<TKey>) | Constructs the options configuration to initialize a BPlusTree instance

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree.Options<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class > BPlusTree.Options<TKey,TValue> Constructor : BPlusTree.Options<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>)

keySerializer
valueSerializer

Glossary Item Box

Constructs the options configuration to initialize a BPlusTree instance using the default Comparer for TKey

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue) _
)
C#
public BPlusTree.Options<TKey,TValue>(
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer
)

Parameters

keySerializer
valueSerializer

Example

BPlusTree/BPlusTree.Test/TestBPlusTreeOptions.cs

C# Copy Code
var options = new BPlusTree<int, int>.Options(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
{
    CreateFile = CreatePolicy.IfNeeded,
    BTreeOrder = 4
};
var copy = options.Clone();

Assert.IsFalse(Object.ReferenceEquals(options, copy));
Assert.IsTrue(Object.ReferenceEquals(options.CallLevelLock, copy.CallLevelLock));

//If we get/set the lock prior to clone we will have the same lock instance.
options.CallLevelLock = new SimpleReadWriteLocking();
copy = options.Clone();

Assert.IsFalse(Object.ReferenceEquals(options, copy));
Assert.IsTrue(Object.ReferenceEquals(options.CallLevelLock, copy.CallLevelLock));
VB.NET Copy Code
Dim options As var = New BPlusTree(Of Integer, Integer).Options(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32) With { _
    Key .CreateFile = CreatePolicy.IfNeeded, _
    Key .BTreeOrder = 4 _
}
Dim copy As var = options.Clone()

Assert.IsFalse([Object].ReferenceEquals(options, copy))
Assert.IsTrue([Object].ReferenceEquals(options.CallLevelLock, copy.CallLevelLock))

'If we get/set the lock prior to clone we will have the same lock instance.
options.CallLevelLock = New SimpleReadWriteLocking()
copy = options.Clone()

Assert.IsFalse([Object].ReferenceEquals(options, copy))
Assert.IsTrue([Object].ReferenceEquals(options.CallLevelLock, copy.CallLevelLock))

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.Options.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree.Options<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>,IComparer<TKey>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class > BPlusTree.Options<TKey,TValue> Constructor : BPlusTree.Options<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>,IComparer<TKey>)

keySerializer
valueSerializer
comparer

Glossary Item Box

Constructs the options configuration to initialize a BPlusTree instance

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue), _
   ByVal comparer As IComparer(Of TKey) _
)
C#
public BPlusTree.Options<TKey,TValue>(
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer,
   IComparer<TKey> comparer
)

Parameters

keySerializer
valueSerializer
comparer

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.Options options = new BPlusTree<KeyInfo, DataValue>.Options(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (TempFile copy = new TempFile())
{
    copy.Delete();
    int minRecordCreated = StartAndAbortWriters(options, copy);

    using (TempFile.Attach(copy.TempPath + ".recovered")) //used to create the new copy
    using (TempFile.Attach(copy.TempPath + ".deleted"))  //renamed existing file
    {
        options.CreateFile = CreatePolicy.Never;
        int recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        if (recoveredRecords < RecordsCreated)
            Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated);

        options.FileName = copy.TempPath;
        recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords);

        using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
        {
            dictionary.EnableCount();
            Assert.AreEqual(recoveredRecords, dictionary.Count);

            foreach (KeyValuePair<KeyInfo, DataValue> kv in dictionary)
            {
                Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID);
                dictionary.Remove(kv.Key);
            }

            Assert.AreEqual(0, dictionary.Count);
        }
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always

Using copy As New TempFile()
    copy.Delete()
    Dim minRecordCreated As Integer = StartAndAbortWriters(options, copy)

    Using TempFile.Attach(copy.TempPath + ".recovered")
        'used to create the new copy
        Using TempFile.Attach(copy.TempPath + ".deleted")
            'renamed existing file
            options.CreateFile = CreatePolicy.Never
            Dim recoveredRecords As Integer = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            If recoveredRecords < RecordsCreated Then
                Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated)
            End If

            options.FileName = copy.TempPath
            recoveredRecords = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords)

            Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
                dictionary.EnableCount()
                Assert.AreEqual(recoveredRecords, dictionary.Count)

                For Each kv As KeyValuePair(Of KeyInfo, DataValue) In dictionary
                    Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID)
                    dictionary.Remove(kv.Key)
                Next

                Assert.AreEqual(0, dictionary.Count)
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.Options.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BPlusTree.Options<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.Options<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BPlusTree.Options<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | CalcBTreeOrder | Calculates default node-threasholds based upon the average number of bytes in key and value
Public Method | Clone | Creates a shallow clone of the configuration options.
Top

Protected Methods

 | Name | Description
Protected Method | CalculateOrder | Overridden. Calculates default node-threasholds based upon the average number of bytes in key and value
Protected Method | SetLogFile | Sets the transaction log to use (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Protected Method | SetStorageCache | Enables or disables the caching and reordering of node write operations (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Top

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
Int32 BPlusTree.RecoverFile(BPlusTree.Options)
IEnumerable> BPlusTree.RecoveryScan(BPlusTree.Options,FileShare)

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.Options BPlusTree.Options.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
CalcBTreeOrder Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class : CalcBTreeOrder Method

avgKeySizeBytes
avgValueSizeBytes

Glossary Item Box

Calculates default node-threasholds based upon the average number of bytes in key and value

Syntax

Visual Basic (Declaration)
Public Shadows Function CalcBTreeOrder( _
   ByVal avgKeySizeBytes As Integer, _
   ByVal avgValueSizeBytes As Integer _
) As BPlusTree(Of TKey,TValue)
C#
public new BPlusTree<TKey,TValue> CalcBTreeOrder(
   int avgKeySizeBytes,
   int avgValueSizeBytes
)

Parameters

avgKeySizeBytes
avgValueSizeBytes

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.Options options = new BPlusTree<KeyInfo, DataValue>.Options(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (TempFile copy = new TempFile())
{
    copy.Delete();
    int minRecordCreated = StartAndAbortWriters(options, copy);

    using (TempFile.Attach(copy.TempPath + ".recovered")) //used to create the new copy
    using (TempFile.Attach(copy.TempPath + ".deleted"))  //renamed existing file
    {
        options.CreateFile = CreatePolicy.Never;
        int recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        if (recoveredRecords < RecordsCreated)
            Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated);

        options.FileName = copy.TempPath;
        recoveredRecords = BPlusTree<KeyInfo, DataValue>.RecoverFile(options);
        Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords);

        using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
        {
            dictionary.EnableCount();
            Assert.AreEqual(recoveredRecords, dictionary.Count);

            foreach (KeyValuePair<KeyInfo, DataValue> kv in dictionary)
            {
                Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID);
                dictionary.Remove(kv.Key);
            }

            Assert.AreEqual(0, dictionary.Count);
        }
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always

Using copy As New TempFile()
    copy.Delete()
    Dim minRecordCreated As Integer = StartAndAbortWriters(options, copy)

    Using TempFile.Attach(copy.TempPath + ".recovered")
        'used to create the new copy
        Using TempFile.Attach(copy.TempPath + ".deleted")
            'renamed existing file
            options.CreateFile = CreatePolicy.Never
            Dim recoveredRecords As Integer = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            If recoveredRecords < RecordsCreated Then
                Assert.Fail("Unable to recover records, recieved ({0} of {1}).", recoveredRecords, RecordsCreated)
            End If

            options.FileName = copy.TempPath
            recoveredRecords = BPlusTree(Of KeyInfo, DataValue).RecoverFile(options)
            Assert.IsTrue(recoveredRecords >= minRecordCreated, "Expected at least " + minRecordCreated + " found " + recoveredRecords)

            Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
                dictionary.EnableCount()
                Assert.AreEqual(recoveredRecords, dictionary.Count)

                For Each kv As KeyValuePair(Of KeyInfo, DataValue) In dictionary
                    Assert.AreEqual(kv.Key.UID, kv.Value.Key.UID)
                    dictionary.Remove(kv.Key)
                Next

                Assert.AreEqual(0, dictionary.Count)
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CalculateOrder Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class : CalculateOrder Method

avgKeySizeBytes
avgValueSizeBytes

Glossary Item Box

Calculates default node-threasholds based upon the average number of bytes in key and value

Syntax

Visual Basic (Declaration)
Protected Overrides NotOverridable Sub CalculateOrder( _
   ByVal avgKeySizeBytes As Integer, _
   ByVal avgValueSizeBytes As Integer _
)
C#
protected override void CalculateOrder(
   int avgKeySizeBytes,
   int avgValueSizeBytes
)

Parameters

avgKeySizeBytes
avgValueSizeBytes

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members
Base Implementation in CalculateOrder


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class : Clone Method

Glossary Item Box

Creates a shallow clone of the configuration options.

Syntax

Visual Basic (Declaration)
Public Shadows Function Clone() As BPlusTree(Of TKey,TValue)
C#
public new BPlusTree<TKey,TValue> Clone()

Example

BPlusTree/BPlusTree.Test/TestBPlusTreeOptions.cs

C# Copy Code
var options = new BPlusTree<int, int>.Options(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
{
    CreateFile = CreatePolicy.IfNeeded,
    BTreeOrder = 4
};
var copy = options.Clone();

Assert.IsFalse(Object.ReferenceEquals(options, copy));
Assert.IsTrue(Object.ReferenceEquals(options.CallLevelLock, copy.CallLevelLock));

//If we get/set the lock prior to clone we will have the same lock instance.
options.CallLevelLock = new SimpleReadWriteLocking();
copy = options.Clone();

Assert.IsFalse(Object.ReferenceEquals(options, copy));
Assert.IsTrue(Object.ReferenceEquals(options.CallLevelLock, copy.CallLevelLock));
VB.NET Copy Code
Dim options As var = New BPlusTree(Of Integer, Integer).Options(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32) With { _
    Key .CreateFile = CreatePolicy.IfNeeded, _
    Key .BTreeOrder = 4 _
}
Dim copy As var = options.Clone()

Assert.IsFalse([Object].ReferenceEquals(options, copy))
Assert.IsTrue([Object].ReferenceEquals(options.CallLevelLock, copy.CallLevelLock))

'If we get/set the lock prior to clone we will have the same lock instance.
options.CallLevelLock = New SimpleReadWriteLocking()
copy = options.Clone()

Assert.IsFalse([Object].ReferenceEquals(options, copy))
Assert.IsTrue([Object].ReferenceEquals(options.CallLevelLock, copy.CallLevelLock))

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BPlusTree.Options<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.Options<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BPlusTree.Options<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | BTreeOrder | A quick means of setting all the min/max values for the node counts using this value as a basis for the Maximum fields and one-quarter of this value for Minimum fields provided the result is in range. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveFactory | CacheKeepAliveFactory provides a delegate to inject an implementation of the IObjectKeepAlive interface while then igoring all the other CacheKeepAliveXXX properties. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveMaximumHistory | Determins maximum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. The ceiling is always respected reguardless of the timeout. Specify a value of 0 to disable history keep alive. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveMinimumHistory | Determins minimum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. This number will always be kept reguardless of the timeout. Specify a value of 0 to allow the timeout to empty the cache. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveTimeout | If the cache contains more that CacheKeepAliveMinimumHistory items, this timeout will start to remove those items until the cache history is reduced to CacheKeepAliveMinimumHistory. It is important to know that the BPlusTree itself contains no theads and this timeout will not be respected if cache is not in use. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CachePolicy | Determines how long loaded nodes stay in memory, Full keeps all loaded nodes alive and is the most efficient, The default Recent keeps recently visited nodes alive based on the CacheKeepAlive properties, and None does not cache the nodes at all but does maintain a cache of locks for each node visited. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CallLevelLock | Defines a reader/writer lock that used to control exclusive tree access when needed. The public methods for EnableCount(), Clear(), and UnloadCache() each acquire an exclusive (write) lock while all other public methods acquire a shared (read) lock. By default this lock is non-operational (an instance of IgnoreLocking) so if you need the above methods to work while multiple threads are accessing the tree, or if you exclusive access to the tree, specify a lock instance. Since this lock is primarily a read-heavy lock consider using the ReaderWriterLocking or SimpleReadWriteLocking. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ConcurrentWriters | Gets or sets the number of streams that will be created for threads to write in the file store
Public Property | CreateFile | Gets or sets the file-create policy used when backing with a file storage (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileBlockSize | Gets or sets the number of bytes per file-block used in the file storage (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileGrowthRate | Gets or sets the number of blocks that a file will grow by when all blocks are used, use zero for incremental growth
Public Property | FileName | Gets or sets the FileName that should be used to store the BTree (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileOpenOptions | Gets or sets the number of bytes per file-block used in the file storage
Public Property | FileVersion | Overridden. Returns the version this option set is compatable with.
Public Property | KeyComparer | Defines a custom IComparer<T> to be used for comparing keys (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | KeySerializer | Accesses the key serializer given to the constructor (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | LockingFactory | Gets or sets the locking factory to use for accessing shared data. The default is WriterOnlyLocking() which does not perform read locks, rather it will rely on the cache of the btree and may preform dirty reads. You can use any implementation of ILockFactory; however, the SimpleReadWriteLocking seems to perform the most efficiently for both reader/writer locks. Additionally wrapping that instance in a ReserveredWriterLocking() instance will allow reads to continue up until a writer begins the commit process. If you are only accessing the BTree instance from a single thread this can be set to IgnoreLocking. Be careful of using ReaderWriterLocking as the write-intesive nature of the BTree will suffer extreme performance penalties with this lock. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | LockTimeout | Gets or sets the number of milliseconds to wait before failing a lock request, the default of two minutes should be more than adequate. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MaximumChildNodes | The largest number of child nodes that should be linked to before refactoring the tree to split this node into two. This property has a side-effect on MinimumChildNodes to ensure that it continues to be at most half of MaximumChildNodes. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MaximumValueNodes | The largest number of values that should be contained in this node before refactoring the tree to split this node into two. This property has a side-effect on MinimumValueNodes to ensure that it continues to be at most half of MaximumValueNodes. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MinimumChildNodes | The smallest number of child nodes that should be linked to before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MinimumValueNodes | The smallest number of values that should be contained in this node before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ReadOnly | Sets the BTree into a read-only mode (only supported when opening an existing file) (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | StorageSystem | Sets the custom implementation of the storage back-end to use for the BTree (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | StorageType | Can be used to explicitly specify the storage type, or by simply providing a file name this will be done for you. If no file name was specified the default is to use a memory store. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ValueSerializer | Accesses the key serializer given to the constructor (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Top

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
Int32 BPlusTree.RecoverFile(BPlusTree.Options)
IEnumerable> BPlusTree.RecoveryScan(BPlusTree.Options,FileShare)

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.Options BPlusTree.Options.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
ConcurrentWriters Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class : ConcurrentWriters Property

Glossary Item Box

Gets or sets the number of streams that will be created for threads to write in the file store

Syntax

Visual Basic (Declaration)
Public Property ConcurrentWriters As Integer
C#
public int ConcurrentWriters {get; set;}

Example

BPlusTree/BPlusTree.Test/TestFileSerialized.cs

C# Copy Code
BPlusTree<int, string>.Options options = (BPlusTree<int, string>.Options)Options;
options.BTreeOrder = 4;
options.FileBlockSize = 512;
options.FileGrowthRate = 25;
options.ConcurrentWriters = 4;
options.FileOpenOptions = FileOptions.None;

using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
{
    for(int i=0; i < 100; i++)
        Assert.IsTrue(tree.TryAdd(i, i.ToString()));
}

using (Stream io = TempFile.Open())
{
    //first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin);
    io.Write(new byte[512], 0, 512);

    //Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin);
    int len = PrimitiveSerializer.Int32.ReadFrom(io);
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin);//secrets of fragmented file revealed... ugly i know.
    io.WriteByte(255); //overwrite last used byte in chunk.
}

options.CreateFile = CreatePolicy.Never;

//Now that we've corrupted part of the file content, let's take a peek
try
{
    using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
    {
        foreach (KeyValuePair<int, string> kv in tree)
            Assert.AreEqual(kv.Key.ToString(), kv.Value);
    }
    Assert.Fail("Expected InvalidDataException");
}
catch (InvalidDataException)
{ }

Dictionary<int, string> found = new Dictionary<int, string>();
List<int> duplicates = new List<int>();
foreach (KeyValuePair<int, string> kv in BPlusTree<int, string>.RecoveryScan(options, FileShare.None))
{
    if (!found.ContainsKey(kv.Key))
        found.Add(kv.Key, kv.Value);
    else
        duplicates.Add(kv.Key);

    Assert.AreEqual(kv.Key.ToString(), kv.Value);
}
Assert.AreNotEqual(0, found.Count);

//The following may change...
Assert.AreEqual(99, found.Count);
Assert.IsFalse(found.ContainsKey(3), "should be missing #3");
Assert.AreEqual(0, duplicates.Count);
VB.NET Copy Code
Dim options As BPlusTree(Of Integer, String).Options = DirectCast(Options, BPlusTree(Of Integer, String).Options)
options.BTreeOrder = 4
options.FileBlockSize = 512
options.FileGrowthRate = 25
options.ConcurrentWriters = 4
options.FileOpenOptions = FileOptions.None

Using tree As New BPlusTree(Of Integer, String)(options)
    Dim i As Integer = 0
    While i < 100
        Assert.IsTrue(tree.TryAdd(i, i.ToString()))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
End Using

Using io As Stream = TempFile.Open()
    'first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin)
    io.Write(New Byte(512) {}, 0, 512)

    'Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin)
    Dim len As Integer = PrimitiveSerializer.Int32.ReadFrom(io)
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin)
    'secrets of fragmented file revealed... ugly i know.
        'overwrite last used byte in chunk.
    io.WriteByte(255)
End Using

options.CreateFile = CreatePolicy.Never

'Now that we've corrupted part of the file content, let's take a peek
Try
    Using tree As New BPlusTree(Of Integer, String)(options)
        For Each kv As KeyValuePair(Of Integer, String) In tree
            Assert.AreEqual(kv.Key.ToString(), kv.Value)
        Next
    End Using
    Assert.Fail("Expected InvalidDataException")
Catch generatedExceptionName As InvalidDataException
End Try

Dim found As New Dictionary(Of Integer, String)()
Dim duplicates As New List(Of Integer)()
For Each kv As KeyValuePair(Of Integer, String) In BPlusTree(Of Integer, String).RecoveryScan(options, FileShare.None)
    If Not found.ContainsKey(kv.Key) Then
        found.Add(kv.Key, kv.Value)
    Else
        duplicates.Add(kv.Key)
    End If

    Assert.AreEqual(kv.Key.ToString(), kv.Value)
Next
Assert.AreNotEqual(0, found.Count)

'The following may change...
Assert.AreEqual(99, found.Count)
Assert.IsFalse(found.ContainsKey(3), "should be missing #3")
Assert.AreEqual(0, duplicates.Count)

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileGrowthRate Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class : FileGrowthRate Property

Glossary Item Box

Gets or sets the number of blocks that a file will grow by when all blocks are used, use zero for incremental growth

Syntax

Visual Basic (Declaration)
Public Property FileGrowthRate As Integer
C#
public int FileGrowthRate {get; set;}

Example

BPlusTree/BPlusTree.Test/TestFileSerialized.cs

C# Copy Code
BPlusTree<int, string>.Options options = (BPlusTree<int, string>.Options)Options;
options.BTreeOrder = 4;
options.FileBlockSize = 512;
options.FileGrowthRate = 25;
options.ConcurrentWriters = 4;
options.FileOpenOptions = FileOptions.None;

using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
{
    for(int i=0; i < 100; i++)
        Assert.IsTrue(tree.TryAdd(i, i.ToString()));
}

using (Stream io = TempFile.Open())
{
    //first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin);
    io.Write(new byte[512], 0, 512);

    //Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin);
    int len = PrimitiveSerializer.Int32.ReadFrom(io);
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin);//secrets of fragmented file revealed... ugly i know.
    io.WriteByte(255); //overwrite last used byte in chunk.
}

options.CreateFile = CreatePolicy.Never;

//Now that we've corrupted part of the file content, let's take a peek
try
{
    using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
    {
        foreach (KeyValuePair<int, string> kv in tree)
            Assert.AreEqual(kv.Key.ToString(), kv.Value);
    }
    Assert.Fail("Expected InvalidDataException");
}
catch (InvalidDataException)
{ }

Dictionary<int, string> found = new Dictionary<int, string>();
List<int> duplicates = new List<int>();
foreach (KeyValuePair<int, string> kv in BPlusTree<int, string>.RecoveryScan(options, FileShare.None))
{
    if (!found.ContainsKey(kv.Key))
        found.Add(kv.Key, kv.Value);
    else
        duplicates.Add(kv.Key);

    Assert.AreEqual(kv.Key.ToString(), kv.Value);
}
Assert.AreNotEqual(0, found.Count);

//The following may change...
Assert.AreEqual(99, found.Count);
Assert.IsFalse(found.ContainsKey(3), "should be missing #3");
Assert.AreEqual(0, duplicates.Count);
VB.NET Copy Code
Dim options As BPlusTree(Of Integer, String).Options = DirectCast(Options, BPlusTree(Of Integer, String).Options)
options.BTreeOrder = 4
options.FileBlockSize = 512
options.FileGrowthRate = 25
options.ConcurrentWriters = 4
options.FileOpenOptions = FileOptions.None

Using tree As New BPlusTree(Of Integer, String)(options)
    Dim i As Integer = 0
    While i < 100
        Assert.IsTrue(tree.TryAdd(i, i.ToString()))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
End Using

Using io As Stream = TempFile.Open()
    'first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin)
    io.Write(New Byte(512) {}, 0, 512)

    'Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin)
    Dim len As Integer = PrimitiveSerializer.Int32.ReadFrom(io)
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin)
    'secrets of fragmented file revealed... ugly i know.
        'overwrite last used byte in chunk.
    io.WriteByte(255)
End Using

options.CreateFile = CreatePolicy.Never

'Now that we've corrupted part of the file content, let's take a peek
Try
    Using tree As New BPlusTree(Of Integer, String)(options)
        For Each kv As KeyValuePair(Of Integer, String) In tree
            Assert.AreEqual(kv.Key.ToString(), kv.Value)
        Next
    End Using
    Assert.Fail("Expected InvalidDataException")
Catch generatedExceptionName As InvalidDataException
End Try

Dim found As New Dictionary(Of Integer, String)()
Dim duplicates As New List(Of Integer)()
For Each kv As KeyValuePair(Of Integer, String) In BPlusTree(Of Integer, String).RecoveryScan(options, FileShare.None)
    If Not found.ContainsKey(kv.Key) Then
        found.Add(kv.Key, kv.Value)
    Else
        duplicates.Add(kv.Key)
    End If

    Assert.AreEqual(kv.Key.ToString(), kv.Value)
Next
Assert.AreNotEqual(0, found.Count)

'The following may change...
Assert.AreEqual(99, found.Count)
Assert.IsFalse(found.ContainsKey(3), "should be missing #3")
Assert.AreEqual(0, duplicates.Count)

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileOpenOptions Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class : FileOpenOptions Property

Glossary Item Box

Gets or sets the number of bytes per file-block used in the file storage

Syntax

Visual Basic (Declaration)
Public Property FileOpenOptions As FileOptions
C#
public FileOptions FileOpenOptions {get; set;}

Example

BPlusTree/BPlusTree.Test/TestFileSerialized.cs

C# Copy Code
BPlusTree<int, string>.Options options = (BPlusTree<int, string>.Options)Options;
options.BTreeOrder = 4;
options.FileBlockSize = 512;
options.FileGrowthRate = 25;
options.ConcurrentWriters = 4;
options.FileOpenOptions = FileOptions.None;

using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
{
    for(int i=0; i < 100; i++)
        Assert.IsTrue(tree.TryAdd(i, i.ToString()));
}

using (Stream io = TempFile.Open())
{
    //first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin);
    io.Write(new byte[512], 0, 512);

    //Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin);
    int len = PrimitiveSerializer.Int32.ReadFrom(io);
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin);//secrets of fragmented file revealed... ugly i know.
    io.WriteByte(255); //overwrite last used byte in chunk.
}

options.CreateFile = CreatePolicy.Never;

//Now that we've corrupted part of the file content, let's take a peek
try
{
    using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
    {
        foreach (KeyValuePair<int, string> kv in tree)
            Assert.AreEqual(kv.Key.ToString(), kv.Value);
    }
    Assert.Fail("Expected InvalidDataException");
}
catch (InvalidDataException)
{ }

Dictionary<int, string> found = new Dictionary<int, string>();
List<int> duplicates = new List<int>();
foreach (KeyValuePair<int, string> kv in BPlusTree<int, string>.RecoveryScan(options, FileShare.None))
{
    if (!found.ContainsKey(kv.Key))
        found.Add(kv.Key, kv.Value);
    else
        duplicates.Add(kv.Key);

    Assert.AreEqual(kv.Key.ToString(), kv.Value);
}
Assert.AreNotEqual(0, found.Count);

//The following may change...
Assert.AreEqual(99, found.Count);
Assert.IsFalse(found.ContainsKey(3), "should be missing #3");
Assert.AreEqual(0, duplicates.Count);
VB.NET Copy Code
Dim options As BPlusTree(Of Integer, String).Options = DirectCast(Options, BPlusTree(Of Integer, String).Options)
options.BTreeOrder = 4
options.FileBlockSize = 512
options.FileGrowthRate = 25
options.ConcurrentWriters = 4
options.FileOpenOptions = FileOptions.None

Using tree As New BPlusTree(Of Integer, String)(options)
    Dim i As Integer = 0
    While i < 100
        Assert.IsTrue(tree.TryAdd(i, i.ToString()))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
End Using

Using io As Stream = TempFile.Open()
    'first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin)
    io.Write(New Byte(512) {}, 0, 512)

    'Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin)
    Dim len As Integer = PrimitiveSerializer.Int32.ReadFrom(io)
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin)
    'secrets of fragmented file revealed... ugly i know.
        'overwrite last used byte in chunk.
    io.WriteByte(255)
End Using

options.CreateFile = CreatePolicy.Never

'Now that we've corrupted part of the file content, let's take a peek
Try
    Using tree As New BPlusTree(Of Integer, String)(options)
        For Each kv As KeyValuePair(Of Integer, String) In tree
            Assert.AreEqual(kv.Key.ToString(), kv.Value)
        Next
    End Using
    Assert.Fail("Expected InvalidDataException")
Catch generatedExceptionName As InvalidDataException
End Try

Dim found As New Dictionary(Of Integer, String)()
Dim duplicates As New List(Of Integer)()
For Each kv As KeyValuePair(Of Integer, String) In BPlusTree(Of Integer, String).RecoveryScan(options, FileShare.None)
    If Not found.ContainsKey(kv.Key) Then
        found.Add(kv.Key, kv.Value)
    Else
        duplicates.Add(kv.Key)
    End If

    Assert.AreEqual(kv.Key.ToString(), kv.Value)
Next
Assert.AreNotEqual(0, found.Count)

'The following may change...
Assert.AreEqual(99, found.Count)
Assert.IsFalse(found.ContainsKey(3), "should be missing #3")
Assert.AreEqual(0, duplicates.Count)

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.Options<TKey,TValue> Class : FileVersion Property

Glossary Item Box

Returns the version this option set is compatable with.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable ReadOnly Property FileVersion As FileVersion
C#
public override FileVersion FileVersion {get;}

Requirements

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

See Also

Reference

BPlusTree.Options<TKey,TValue> Class
BPlusTree.Options<TKey,TValue> Members
Base Implementation in FileVersion
FileVersion

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
BPlusTree.OptionsV2<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.OptionsV2<TKey,TValue> Class

Glossary Item Box

Defines the options nessessary to construct a BPlusTree implementation

Object Model

BPlusTree.OptionsV2<TKey,TValue> ClassILockStrategy InterfaceILockFactory InterfaceINodeStorage Interface

Syntax

Visual Basic (Declaration)
Public NotInheritable Class BPlusTree.OptionsV2
    (Of TKey,TValue)
   Inherits BPlusTreeOptions(Of TKey,TValue)
C#
public sealed class BPlusTree.OptionsV2<TKey,TValue> : BPlusTreeOptions<TKey,TValue>

Type Parameters

TKey
TValue

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>
CSharpTest.Net.Collections.BPlusTree`2.OptionsV2<TKey,TValue>

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.OptionsV2 BPlusTree.OptionsV2.Clone()


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BPlusTree.OptionsV2<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.OptionsV2<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by BPlusTree.OptionsV2<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | BPlusTree.OptionsV2<TKey,TValue> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | BTreeOrder | A quick means of setting all the min/max values for the node counts using this value as a basis for the Maximum fields and one-quarter of this value for Minimum fields provided the result is in range. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveFactory | CacheKeepAliveFactory provides a delegate to inject an implementation of the IObjectKeepAlive interface while then igoring all the other CacheKeepAliveXXX properties. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveMaximumHistory | Determins maximum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. The ceiling is always respected reguardless of the timeout. Specify a value of 0 to disable history keep alive. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveMinimumHistory | Determins minimum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. This number will always be kept reguardless of the timeout. Specify a value of 0 to allow the timeout to empty the cache. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveTimeout | If the cache contains more that CacheKeepAliveMinimumHistory items, this timeout will start to remove those items until the cache history is reduced to CacheKeepAliveMinimumHistory. It is important to know that the BPlusTree itself contains no theads and this timeout will not be respected if cache is not in use. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CachePolicy | Determines how long loaded nodes stay in memory, Full keeps all loaded nodes alive and is the most efficient, The default Recent keeps recently visited nodes alive based on the CacheKeepAlive properties, and None does not cache the nodes at all but does maintain a cache of locks for each node visited. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CallLevelLock | Overridden. Defines a reader/writer lock that used to control exclusive tree access when needed. Version2 files using trasacation logs will use this to gain exclusive access to the tree during calls to Commit, Rollback, etc. The default is to use a SimpleReadWriteLocking class. If you are accessing the tree from a single thread, consider using the IgnoreLocking class for better performance.
Public Property | CreateFile | Gets or sets the file-create policy used when backing with a file storage (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ExistingLogAction | Defines the action to perform when opening a BPlusTree with an existing log file.
Public Property | FileBlockSize | Gets or sets the number of bytes per file-block used in the file storage (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileName | Gets or sets the FileName that should be used to store the BTree (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileVersion | Overridden. Returns the version this option set is compatible with.
Public Property | KeyComparer | Defines a custom IComparer<T> to be used for comparing keys (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | KeySerializer | Accesses the key serializer given to the constructor (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | LockingFactory | Gets or sets the locking factory to use for accessing shared data. The default is WriterOnlyLocking() which does not perform read locks, rather it will rely on the cache of the btree and may preform dirty reads. You can use any implementation of ILockFactory; however, the SimpleReadWriteLocking seems to perform the most efficiently for both reader/writer locks. Additionally wrapping that instance in a ReserveredWriterLocking() instance will allow reads to continue up until a writer begins the commit process. If you are only accessing the BTree instance from a single thread this can be set to IgnoreLocking. Be careful of using ReaderWriterLocking as the write-intesive nature of the BTree will suffer extreme performance penalties with this lock. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | LockTimeout | Gets or sets the number of milliseconds to wait before failing a lock request, the default of two minutes should be more than adequate. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MaximumChildNodes | The largest number of child nodes that should be linked to before refactoring the tree to split this node into two. This property has a side-effect on MinimumChildNodes to ensure that it continues to be at most half of MaximumChildNodes. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MaximumValueNodes | The largest number of values that should be contained in this node before refactoring the tree to split this node into two. This property has a side-effect on MinimumValueNodes to ensure that it continues to be at most half of MaximumValueNodes. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MinimumChildNodes | The smallest number of child nodes that should be linked to before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MinimumValueNodes | The smallest number of values that should be contained in this node before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ReadOnly | Sets the BTree into a read-only mode (only supported when opening an existing file) (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | StoragePerformance | Returns the DurabilityProtection of the underlying storage to create.
Public Property | StorageSystem | Sets the custom implementation of the storage back-end to use for the BTree (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | StorageType | Can be used to explicitly specify the storage type, or by simply providing a file name this will be done for you. If no file name was specified the default is to use a memory store. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | TransactionLog | Gets or sets an implementation of ITransactionLog<TKey, TValue> used to log writes to this tree for recovery and/or monitoring.
Public Property | TransactionLogFileName | Gets or sets a filename to write binary log files to.
Public Property | TransactionLogLimit | Defines the number of bytes in the transaction log file before the BPlusTree will auto-commit and truncate the log. Values equal to or less than zero will not auto-commit (default).
Public Property | ValueSerializer | Accesses the key serializer given to the constructor (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Top

Public Methods

 | Name | Description
Public Method | CalcBTreeOrder | Calculates default node-thresholds based upon the average number of bytes in key and value
Public Method | Clone | Creates a shallow clone of the configuration options.
Top

Protected Methods

 | Name | Description
Protected Method | CalculateOrder | Overridden. Calculates default node-thresholds based upon the average number of bytes in key and value
Protected Method | SetLogFile | Sets the transaction log to use (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Protected Method | SetStorageCache | Enables or disables the caching and reordering of node write operations (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Top

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.OptionsV2 BPlusTree.OptionsV2.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree.OptionsV2<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : BPlusTree.OptionsV2<TKey,TValue> Constructor

Glossary Item Box

Overload List

Overload | Description
BPlusTree.OptionsV2<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>) | Constructs the options configuration to initialize a BPlusTree instance using the default Comparer for TKey
BPlusTree.OptionsV2<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>,IComparer<TKey>) | Constructs the options configuration to initialize a BPlusTree instance

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree.OptionsV2<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class > BPlusTree.OptionsV2<TKey,TValue> Constructor : BPlusTree.OptionsV2<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>)

keySerializer
valueSerializer

Glossary Item Box

Constructs the options configuration to initialize a BPlusTree instance using the default Comparer for TKey

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue) _
)
C#
public BPlusTree.OptionsV2<TKey,TValue>(
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer
)

Parameters

keySerializer
valueSerializer

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.Options.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree.OptionsV2<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>,IComparer<TKey>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class > BPlusTree.OptionsV2<TKey,TValue> Constructor : BPlusTree.OptionsV2<TKey,TValue> Constructor(ISerializer<TKey>,ISerializer<TValue>,IComparer<TKey>)

keySerializer
valueSerializer
comparer

Glossary Item Box

Constructs the options configuration to initialize a BPlusTree instance

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue), _
   ByVal comparer As IComparer(Of TKey) _
)
C#
public BPlusTree.OptionsV2<TKey,TValue>(
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer,
   IComparer<TKey> comparer
)

Parameters

keySerializer
valueSerializer
comparer

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/BPlusTree.Options.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BPlusTree.OptionsV2<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.OptionsV2<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BPlusTree.OptionsV2<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | CalcBTreeOrder | Calculates default node-thresholds based upon the average number of bytes in key and value
Public Method | Clone | Creates a shallow clone of the configuration options.
Top

Protected Methods

 | Name | Description
Protected Method | CalculateOrder | Overridden. Calculates default node-thresholds based upon the average number of bytes in key and value
Protected Method | SetLogFile | Sets the transaction log to use (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Protected Method | SetStorageCache | Enables or disables the caching and reordering of node write operations (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Top

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.OptionsV2 BPlusTree.OptionsV2.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
CalcBTreeOrder Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : CalcBTreeOrder Method

avgKeySizeBytes
avgValueSizeBytes

Glossary Item Box

Calculates default node-thresholds based upon the average number of bytes in key and value

Syntax

Visual Basic (Declaration)
Public Shadows Function CalcBTreeOrder( _
   ByVal avgKeySizeBytes As Integer, _
   ByVal avgValueSizeBytes As Integer _
) As BPlusTree(Of TKey,TValue)
C#
public new BPlusTree<TKey,TValue> CalcBTreeOrder(
   int avgKeySizeBytes,
   int avgValueSizeBytes
)

Parameters

avgKeySizeBytes
avgValueSizeBytes

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CalculateOrder Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : CalculateOrder Method

avgKeySizeBytes
avgValueSizeBytes

Glossary Item Box

Calculates default node-thresholds based upon the average number of bytes in key and value

Syntax

Visual Basic (Declaration)
Protected Overrides NotOverridable Sub CalculateOrder( _
   ByVal avgKeySizeBytes As Integer, _
   ByVal avgValueSizeBytes As Integer _
)
C#
protected override void CalculateOrder(
   int avgKeySizeBytes,
   int avgValueSizeBytes
)

Parameters

avgKeySizeBytes
avgValueSizeBytes

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members
Base Implementation in CalculateOrder


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : Clone Method

Glossary Item Box

Creates a shallow clone of the configuration options.

Syntax

Visual Basic (Declaration)
Public Shadows Function Clone() As BPlusTree(Of TKey,TValue)
C#
public new BPlusTree<TKey,TValue> Clone()

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BPlusTree.OptionsV2<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.OptionsV2<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BPlusTree.OptionsV2<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | BTreeOrder | A quick means of setting all the min/max values for the node counts using this value as a basis for the Maximum fields and one-quarter of this value for Minimum fields provided the result is in range. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveFactory | CacheKeepAliveFactory provides a delegate to inject an implementation of the IObjectKeepAlive interface while then igoring all the other CacheKeepAliveXXX properties. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveMaximumHistory | Determins maximum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. The ceiling is always respected reguardless of the timeout. Specify a value of 0 to disable history keep alive. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveMinimumHistory | Determins minimum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. This number will always be kept reguardless of the timeout. Specify a value of 0 to allow the timeout to empty the cache. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CacheKeepAliveTimeout | If the cache contains more that CacheKeepAliveMinimumHistory items, this timeout will start to remove those items until the cache history is reduced to CacheKeepAliveMinimumHistory. It is important to know that the BPlusTree itself contains no theads and this timeout will not be respected if cache is not in use. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CachePolicy | Determines how long loaded nodes stay in memory, Full keeps all loaded nodes alive and is the most efficient, The default Recent keeps recently visited nodes alive based on the CacheKeepAlive properties, and None does not cache the nodes at all but does maintain a cache of locks for each node visited. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | CallLevelLock | Overridden. Defines a reader/writer lock that used to control exclusive tree access when needed. Version2 files using trasacation logs will use this to gain exclusive access to the tree during calls to Commit, Rollback, etc. The default is to use a SimpleReadWriteLocking class. If you are accessing the tree from a single thread, consider using the IgnoreLocking class for better performance.
Public Property | CreateFile | Gets or sets the file-create policy used when backing with a file storage (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ExistingLogAction | Defines the action to perform when opening a BPlusTree with an existing log file.
Public Property | FileBlockSize | Gets or sets the number of bytes per file-block used in the file storage (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileName | Gets or sets the FileName that should be used to store the BTree (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | FileVersion | Overridden. Returns the version this option set is compatible with.
Public Property | KeyComparer | Defines a custom IComparer<T> to be used for comparing keys (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | KeySerializer | Accesses the key serializer given to the constructor (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | LockingFactory | Gets or sets the locking factory to use for accessing shared data. The default is WriterOnlyLocking() which does not perform read locks, rather it will rely on the cache of the btree and may preform dirty reads. You can use any implementation of ILockFactory; however, the SimpleReadWriteLocking seems to perform the most efficiently for both reader/writer locks. Additionally wrapping that instance in a ReserveredWriterLocking() instance will allow reads to continue up until a writer begins the commit process. If you are only accessing the BTree instance from a single thread this can be set to IgnoreLocking. Be careful of using ReaderWriterLocking as the write-intesive nature of the BTree will suffer extreme performance penalties with this lock. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | LockTimeout | Gets or sets the number of milliseconds to wait before failing a lock request, the default of two minutes should be more than adequate. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MaximumChildNodes | The largest number of child nodes that should be linked to before refactoring the tree to split this node into two. This property has a side-effect on MinimumChildNodes to ensure that it continues to be at most half of MaximumChildNodes. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MaximumValueNodes | The largest number of values that should be contained in this node before refactoring the tree to split this node into two. This property has a side-effect on MinimumValueNodes to ensure that it continues to be at most half of MaximumValueNodes. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MinimumChildNodes | The smallest number of child nodes that should be linked to before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | MinimumValueNodes | The smallest number of values that should be contained in this node before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | ReadOnly | Sets the BTree into a read-only mode (only supported when opening an existing file) (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | StoragePerformance | Returns the DurabilityProtection of the underlying storage to create.
Public Property | StorageSystem | Sets the custom implementation of the storage back-end to use for the BTree (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | StorageType | Can be used to explicitly specify the storage type, or by simply providing a file name this will be done for you. If no file name was specified the default is to use a memory store. (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Public Property | TransactionLog | Gets or sets an implementation of ITransactionLog<TKey, TValue> used to log writes to this tree for recovery and/or monitoring.
Public Property | TransactionLogFileName | Gets or sets a filename to write binary log files to.
Public Property | TransactionLogLimit | Defines the number of bytes in the transaction log file before the BPlusTree will auto-commit and truncate the log. Values equal to or less than zero will not auto-commit (default).
Public Property | ValueSerializer | Accesses the key serializer given to the constructor (Inherited from CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>)
Top

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.Options.cs

Used By

BPlusTree.OptionsV2 BPlusTree.OptionsV2.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
CallLevelLock Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : CallLevelLock Property

Glossary Item Box

Defines a reader/writer lock that used to control exclusive tree access when needed. Version2 files using trasacation logs will use this to gain exclusive access to the tree during calls to Commit, Rollback, etc. The default is to use a SimpleReadWriteLocking class. If you are accessing the tree from a single thread, consider using the IgnoreLocking class for better performance.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable Property CallLevelLock As ILockStrategy
C#
public override ILockStrategy CallLevelLock {get; set;}

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members
Base Implementation in CallLevelLock
ILockStrategy

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExistingLogAction Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : ExistingLogAction Property

Glossary Item Box

Defines the action to perform when opening a BPlusTree with an existing log file.

Syntax

Visual Basic (Declaration)
Public Shadows Property ExistingLogAction As ExistingLogAction
C#
public new ExistingLogAction ExistingLogAction {get; set;}

Example

BPlusTree/BPlusTree.Test/BasicTestsVersion2.cs

C# Copy Code
var options = (BPlusTree<int, string>.OptionsV2)Options;

Assert.AreEqual(ExistingLogAction.Default, options.ExistingLogAction);
options.ExistingLogAction = ExistingLogAction.Ignore;
Assert.AreEqual(ExistingLogAction.Ignore, options.ExistingLogAction);

Assert.AreEqual(-1, options.TransactionLogLimit);
options.TransactionLogLimit = int.MaxValue;
Assert.AreEqual(int.MaxValue, options.TransactionLogLimit);
VB.NET Copy Code
Dim options As var = DirectCast(Options, BPlusTree(Of Integer, String).OptionsV2)

Assert.AreEqual(ExistingLogAction.[Default], options.ExistingLogAction)
options.ExistingLogAction = ExistingLogAction.Ignore
Assert.AreEqual(ExistingLogAction.Ignore, options.ExistingLogAction)

Assert.AreEqual(-1, options.TransactionLogLimit)
options.TransactionLogLimit = Integer.MaxValue
Assert.AreEqual(Integer.MaxValue, options.TransactionLogLimit)

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members
ExistingLogAction

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : FileVersion Property

Glossary Item Box

Returns the version this option set is compatible with.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable ReadOnly Property FileVersion As FileVersion
C#
public override FileVersion FileVersion {get;}

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members
Base Implementation in FileVersion
FileVersion

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StoragePerformance Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : StoragePerformance Property

Glossary Item Box

Returns the DurabilityProtection of the underlying storage to create.

Syntax

Visual Basic (Declaration)
Public Property StoragePerformance As StoragePerformance
C#
public StoragePerformance StoragePerformance {get; set;}

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members
StoragePerformance

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactionLog Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : TransactionLog Property

Glossary Item Box

Gets or sets an implementation of ITransactionLog<TKey, TValue> used to log writes to this tree for recovery and/or monitoring.

Syntax

Visual Basic (Declaration)
Public Property TransactionLog As ITransactionLog(Of TKey,TValue)
C#
public ITransactionLog<TKey,TValue> TransactionLog {get; set;}

Example

BPlusTree/BPlusTree.Test/TestBackupAndRecovery.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    var options = GetOptions(temp);
    options.MaximumValueNodes = 255;
    options.MinimumValueNodes = 100;
    options.TransactionLog = new TransactionLog<Guid, TestInfo>(
        new TransactionLogOptions<Guid, TestInfo>(
            options.TransactionLogFileName,
            options.KeySerializer,
            options.ValueSerializer
            ) { FileOptions = FileOptions.None } /* no-write through */
        );
    TestRecoveryOnExisting(options, 100, ushort.MaxValue);
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim options As var = GetOptions(temp)
    options.MaximumValueNodes = 255
    options.MinimumValueNodes = 100
        ' no-write through
    options.TransactionLog = New TransactionLog(Of Guid, TestInfo)(New TransactionLogOptions(Of Guid, TestInfo)(options.TransactionLogFileName, options.KeySerializer, options.ValueSerializer) With { _
        Key .FileOptions = FileOptions.None _
    })
    TestRecoveryOnExisting(options, 100, UShort.MaxValue)
End Using

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members
ITransactionLog

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactionLogFileName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : TransactionLogFileName Property

Glossary Item Box

Gets or sets a filename to write binary log files to.

Syntax

Visual Basic (Declaration)
Public Property TransactionLogFileName As String
C#
public string TransactionLogFileName {get; set;}

Remarks

This is just a short-hand way of setting the TransactionLog instance. For better performance at the risk of loosing a record or two, consider creating the TransactionLog instance with the FileOptions set to (FileOptions.WriteThrough | FileOptions.Asynchronous).

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactionLogLimit Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree.OptionsV2<TKey,TValue> Class : TransactionLogLimit Property

Glossary Item Box

Defines the number of bytes in the transaction log file before the BPlusTree will auto-commit and truncate the log. Values equal to or less than zero will not auto-commit (default).

Syntax

Visual Basic (Declaration)
Public Shadows Property TransactionLogLimit As Long
C#
public new long TransactionLogLimit {get; set;}

Example

BPlusTree/BPlusTree.Test/BasicTestsVersion2.cs

C# Copy Code
var options = (BPlusTree<int, string>.OptionsV2)Options;
options.TransactionLogLimit = 30;

using (BPlusTree<int, string> tree = Create(options))
{
    tree.EnableCount();
    Assert.AreEqual(0, tree.Count);

    tree.Add(1, "A");
    tree.Rollback();
    Assert.AreEqual(0, tree.Count);

    tree.Add(1, "A");
    tree.Add(2, "B"); //The second write exceeds 30 bytes and auto-commits
    tree.Rollback();
    Assert.AreEqual(2, tree.Count);
    tree.Add(3, "C");
    tree.Add(4, "D"); //The second write will commit, but not the last
    tree.Add(5, "E");
    tree.Rollback();
    Assert.AreEqual(4, tree.Count);
    Assert.IsFalse(tree.ContainsKey(5));
}
VB.NET Copy Code
Dim options As var = DirectCast(Options, BPlusTree(Of Integer, String).OptionsV2)
options.TransactionLogLimit = 30

Using tree As BPlusTree(Of Integer, String) = Create(options)
    tree.EnableCount()
    Assert.AreEqual(0, tree.Count)

    tree.Add(1, "A")
    tree.Rollback()
    Assert.AreEqual(0, tree.Count)

    tree.Add(1, "A")
    tree.Add(2, "B")
    'The second write exceeds 30 bytes and auto-commits
    tree.Rollback()
    Assert.AreEqual(2, tree.Count)
    tree.Add(3, "C")
    tree.Add(4, "D")
    'The second write will commit, but not the last
    tree.Add(5, "E")
    tree.Rollback()
    Assert.AreEqual(4, tree.Count)
    Assert.IsFalse(tree.ContainsKey(5))
End Using

Requirements

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

See Also

Reference

BPlusTree.OptionsV2<TKey,TValue> Class
BPlusTree.OptionsV2<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.Options.cs
BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
BPlusTreeOptions<TKey,TValue> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTreeOptions<TKey,TValue> Class

Glossary Item Box

Defines the options nessessary to construct a BPlusTree implementation

Object Model

BPlusTreeOptions<TKey,TValue> ClassILockStrategy InterfaceILockFactory InterfaceINodeStorage Interface

Syntax

Visual Basic (Declaration)
Public MustInherit Class BPlusTreeOptions
    (Of TKey,TValue)
C#
public abstract class BPlusTreeOptions<TKey,TValue>

Type Parameters

TKey
TValue

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>
CSharpTest.Net.Collections.BPlusTree`2.Options<TKey,TValue>
CSharpTest.Net.Collections.BPlusTree`2.OptionsV2<TKey,TValue>

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BPlusTreeOptions<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTreeOptions<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by BPlusTreeOptions<TKey,TValue>.

Protected Constructors

 | Name | Description
Protected Constructor | BPlusTreeOptions<TKey,TValue> Constructor | Constructs the options configuration to initialize a BPlusTree instance
Top

Public Properties

 | Name | Description
Public Property | BTreeOrder | A quick means of setting all the min/max values for the node counts using this value as a basis for the Maximum fields and one-quarter of this value for Minimum fields provided the result is in range.
Public Property | CacheKeepAliveFactory | CacheKeepAliveFactory provides a delegate to inject an implementation of the IObjectKeepAlive interface while then igoring all the other CacheKeepAliveXXX properties.
Public Property | CacheKeepAliveMaximumHistory | Determins maximum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. The ceiling is always respected reguardless of the timeout. Specify a value of 0 to disable history keep alive.
Public Property | CacheKeepAliveMinimumHistory | Determins minimum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. This number will always be kept reguardless of the timeout. Specify a value of 0 to allow the timeout to empty the cache.
Public Property | CacheKeepAliveTimeout | If the cache contains more that CacheKeepAliveMinimumHistory items, this timeout will start to remove those items until the cache history is reduced to CacheKeepAliveMinimumHistory. It is important to know that the BPlusTree itself contains no theads and this timeout will not be respected if cache is not in use.
Public Property | CachePolicy | Determines how long loaded nodes stay in memory, Full keeps all loaded nodes alive and is the most efficient, The default Recent keeps recently visited nodes alive based on the CacheKeepAlive properties, and None does not cache the nodes at all but does maintain a cache of locks for each node visited.
Public Property | CallLevelLock | Defines a reader/writer lock that used to control exclusive tree access when needed. The public methods for EnableCount(), Clear(), and UnloadCache() each acquire an exclusive (write) lock while all other public methods acquire a shared (read) lock. By default this lock is non-operational (an instance of IgnoreLocking) so if you need the above methods to work while multiple threads are accessing the tree, or if you exclusive access to the tree, specify a lock instance. Since this lock is primarily a read-heavy lock consider using the ReaderWriterLocking or SimpleReadWriteLocking.
Public Property | CreateFile | Gets or sets the file-create policy used when backing with a file storage
Public Property | FileBlockSize | Gets or sets the number of bytes per file-block used in the file storage
Public Property | FileName | Gets or sets the FileName that should be used to store the BTree
Public Property | FileVersion | Returns the version this option set is compatable with.
Public Property | KeyComparer | Defines a custom IComparer<T> to be used for comparing keys
Public Property | KeySerializer | Accesses the key serializer given to the constructor
Public Property | LockingFactory | Gets or sets the locking factory to use for accessing shared data. The default is WriterOnlyLocking() which does not perform read locks, rather it will rely on the cache of the btree and may preform dirty reads. You can use any implementation of ILockFactory; however, the SimpleReadWriteLocking seems to perform the most efficiently for both reader/writer locks. Additionally wrapping that instance in a ReserveredWriterLocking() instance will allow reads to continue up until a writer begins the commit process. If you are only accessing the BTree instance from a single thread this can be set to IgnoreLocking. Be careful of using ReaderWriterLocking as the write-intesive nature of the BTree will suffer extreme performance penalties with this lock.
Public Property | LockTimeout | Gets or sets the number of milliseconds to wait before failing a lock request, the default of two minutes should be more than adequate.
Public Property | MaximumChildNodes | The largest number of child nodes that should be linked to before refactoring the tree to split this node into two. This property has a side-effect on MinimumChildNodes to ensure that it continues to be at most half of MaximumChildNodes.
Public Property | MaximumValueNodes | The largest number of values that should be contained in this node before refactoring the tree to split this node into two. This property has a side-effect on MinimumValueNodes to ensure that it continues to be at most half of MaximumValueNodes.
Public Property | MinimumChildNodes | The smallest number of child nodes that should be linked to before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2.
Public Property | MinimumValueNodes | The smallest number of values that should be contained in this node before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2.
Public Property | ReadOnly | Sets the BTree into a read-only mode (only supported when opening an existing file)
Public Property | StorageSystem | Sets the custom implementation of the storage back-end to use for the BTree
Public Property | StorageType | Can be used to explicitly specify the storage type, or by simply providing a file name this will be done for you. If no file name was specified the default is to use a memory store.
Public Property | ValueSerializer | Accesses the key serializer given to the constructor
Top

Public Methods

 | Name | Description
Public Method | CalcBTreeOrder | Calculates default node-threasholds based upon the average number of bytes in key and value
Public Method | Clone | Creates a shallow clone of the configuration options.
Top

Protected Methods

 | Name | Description
Protected Method | CalculateOrder | Calculates default node-threasholds based upon the average number of bytes in key and value
Protected Method | SetLogFile | Sets the transaction log to use
Protected Method | SetStorageCache | Enables or disables the caching and reordering of node write operations
Top

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTreeOptions<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : BPlusTreeOptions<TKey,TValue> Constructor

keySerializer
valueSerializer
comparer

Glossary Item Box

Constructs the options configuration to initialize a BPlusTree instance

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue), _
   ByVal comparer As IComparer(Of TKey) _
)
C#
protected BPlusTreeOptions<TKey,TValue>(
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer,
   IComparer<TKey> comparer
)

Parameters

keySerializer
valueSerializer
comparer

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BPlusTreeOptions<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTreeOptions<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BPlusTreeOptions<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | CalcBTreeOrder | Calculates default node-threasholds based upon the average number of bytes in key and value
Public Method | Clone | Creates a shallow clone of the configuration options.
Top

Protected Methods

 | Name | Description
Protected Method | CalculateOrder | Calculates default node-threasholds based upon the average number of bytes in key and value
Protected Method | SetLogFile | Sets the transaction log to use
Protected Method | SetStorageCache | Enables or disables the caching and reordering of node write operations
Top

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CalcBTreeOrder Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CalcBTreeOrder Method

avgKeySizeBytes
avgValueSizeBytes

Glossary Item Box

Calculates default node-threasholds based upon the average number of bytes in key and value

Syntax

Visual Basic (Declaration)
Public Sub CalcBTreeOrder( _
   ByVal avgKeySizeBytes As Integer, _
   ByVal avgValueSizeBytes As Integer _
)
C#
public void CalcBTreeOrder(
   int avgKeySizeBytes,
   int avgValueSizeBytes
)

Parameters

avgKeySizeBytes
avgValueSizeBytes

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C# Copy Code
BPlusTreeOptions<int, string> options = Options;
using (TempFile temp = new TempFile())
{
    temp.Delete();
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    options.CalcBTreeOrder(4, 4);
    Stopwatch sw = Stopwatch.StartNew();

    Dictionary<int, string> expected =
        TestMergeRandom(options, 2, 300);

    Trace.TraceInformation("Creating {0} nodes in {1}.", expected.Count, sw.Elapsed);
    sw = Stopwatch.StartNew();

    options = Options;
    options.CreateFile = CreatePolicy.Never;
    options.FileName = temp.TempPath;
    options.CalcBTreeOrder(4, 4);
    using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
    {
        VerifyDictionary(expected, tree);
    }

    Trace.TraceInformation("Verified {0} nodes in {1}.", expected.Count, sw.Elapsed);
}
VB.NET Copy Code
Dim options As BPlusTreeOptions(Of Integer, String) = Options
Using temp As New TempFile()
    temp.Delete()
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    options.CalcBTreeOrder(4, 4)
    Dim sw As Stopwatch = Stopwatch.StartNew()

    Dim expected As Dictionary(Of Integer, String) = TestMergeRandom(options, 2, 300)

    Trace.TraceInformation("Creating {0} nodes in {1}.", expected.Count, sw.Elapsed)
    sw = Stopwatch.StartNew()

    options = Options
    options.CreateFile = CreatePolicy.Never
    options.FileName = temp.TempPath
    options.CalcBTreeOrder(4, 4)
    Using tree As New BPlusTree(Of Integer, String)(options)
        VerifyDictionary(expected, tree)
    End Using

    Trace.TraceInformation("Verified {0} nodes in {1}.", expected.Count, sw.Elapsed)
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CalculateOrder Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CalculateOrder Method

avgKeySizeBytes
avgValueSizeBytes

Glossary Item Box

Calculates default node-threasholds based upon the average number of bytes in key and value

Syntax

Visual Basic (Declaration)
Protected MustOverride Sub CalculateOrder( _
   ByVal avgKeySizeBytes As Integer, _
   ByVal avgValueSizeBytes As Integer _
)
C#
protected abstract void CalculateOrder(
   int avgKeySizeBytes,
   int avgValueSizeBytes
)

Parameters

avgKeySizeBytes
avgValueSizeBytes

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Used By

BPlusTreeOptions.CalcBTreeOrder(Int32,Int32)
BPlusTree.OptionsV2 BPlusTree.OptionsV2.CalcBTreeOrder(Int32,Int32)
BPlusTree.Options BPlusTree.Options.CalcBTreeOrder(Int32,Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : Clone Method

Glossary Item Box

Creates a shallow clone of the configuration options.

Syntax

Visual Basic (Declaration)
Public Function Clone() As BPlusTreeOptions(Of TKey,TValue)
C#
public BPlusTreeOptions<TKey,TValue> Clone()

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C# Copy Code
BPlusTreeOptions<int, string> options = Options;
using (TempFile temp = new TempFile())
{
    options = Options;
    temp.Delete();
    //options.CreateFile = CreatePolicy.Always;
    //options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14;
    options.MinimumValueNodes = 7;
    options.MaximumChildNodes = 6;
    options.MinimumChildNodes = 2;

    // Just to make sure we don't break some fencepost condition in the future
    for (int i = 0; i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1; i++)
        TestMergeSequenceInFile(options.Clone(), i);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1);
}
VB.NET Copy Code
Dim options As BPlusTreeOptions(Of Integer, String) = Options
Using temp As New TempFile()
    options = Options
    temp.Delete()
    'options.CreateFile = CreatePolicy.Always;
    'options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14
    options.MinimumValueNodes = 7
    options.MaximumChildNodes = 6
    options.MinimumChildNodes = 2

    ' Just to make sure we don't break some fencepost condition in the future
    Dim i As Integer = 0
    While i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1
        TestMergeSequenceInFile(options.Clone(), i)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes)
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1)
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetLogFile Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : SetLogFile Method

logFile

Glossary Item Box

Sets the transaction log to use

Syntax

Visual Basic (Declaration)
Protected Sub SetLogFile( _
   ByVal logFile As ITransactionLog(Of TKey,TValue) _
)
C#
protected void SetLogFile(
   ITransactionLog<TKey,TValue> logFile
)

Parameters

logFile

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SetStorageCache Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : SetStorageCache Method

cached

Glossary Item Box

Enables or disables the caching and reordering of node write operations

Syntax

Visual Basic (Declaration)
Protected Sub SetStorageCache( _
   ByVal cached As Boolean _
)
C#
protected void SetStorageCache(
   bool cached
)

Parameters

cached

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BPlusTreeOptions<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTreeOptions<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BPlusTreeOptions<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | BTreeOrder | A quick means of setting all the min/max values for the node counts using this value as a basis for the Maximum fields and one-quarter of this value for Minimum fields provided the result is in range.
Public Property | CacheKeepAliveFactory | CacheKeepAliveFactory provides a delegate to inject an implementation of the IObjectKeepAlive interface while then igoring all the other CacheKeepAliveXXX properties.
Public Property | CacheKeepAliveMaximumHistory | Determins maximum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. The ceiling is always respected reguardless of the timeout. Specify a value of 0 to disable history keep alive.
Public Property | CacheKeepAliveMinimumHistory | Determins minimum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. This number will always be kept reguardless of the timeout. Specify a value of 0 to allow the timeout to empty the cache.
Public Property | CacheKeepAliveTimeout | If the cache contains more that CacheKeepAliveMinimumHistory items, this timeout will start to remove those items until the cache history is reduced to CacheKeepAliveMinimumHistory. It is important to know that the BPlusTree itself contains no theads and this timeout will not be respected if cache is not in use.
Public Property | CachePolicy | Determines how long loaded nodes stay in memory, Full keeps all loaded nodes alive and is the most efficient, The default Recent keeps recently visited nodes alive based on the CacheKeepAlive properties, and None does not cache the nodes at all but does maintain a cache of locks for each node visited.
Public Property | CallLevelLock | Defines a reader/writer lock that used to control exclusive tree access when needed. The public methods for EnableCount(), Clear(), and UnloadCache() each acquire an exclusive (write) lock while all other public methods acquire a shared (read) lock. By default this lock is non-operational (an instance of IgnoreLocking) so if you need the above methods to work while multiple threads are accessing the tree, or if you exclusive access to the tree, specify a lock instance. Since this lock is primarily a read-heavy lock consider using the ReaderWriterLocking or SimpleReadWriteLocking.
Public Property | CreateFile | Gets or sets the file-create policy used when backing with a file storage
Public Property | FileBlockSize | Gets or sets the number of bytes per file-block used in the file storage
Public Property | FileName | Gets or sets the FileName that should be used to store the BTree
Public Property | FileVersion | Returns the version this option set is compatable with.
Public Property | KeyComparer | Defines a custom IComparer<T> to be used for comparing keys
Public Property | KeySerializer | Accesses the key serializer given to the constructor
Public Property | LockingFactory | Gets or sets the locking factory to use for accessing shared data. The default is WriterOnlyLocking() which does not perform read locks, rather it will rely on the cache of the btree and may preform dirty reads. You can use any implementation of ILockFactory; however, the SimpleReadWriteLocking seems to perform the most efficiently for both reader/writer locks. Additionally wrapping that instance in a ReserveredWriterLocking() instance will allow reads to continue up until a writer begins the commit process. If you are only accessing the BTree instance from a single thread this can be set to IgnoreLocking. Be careful of using ReaderWriterLocking as the write-intesive nature of the BTree will suffer extreme performance penalties with this lock.
Public Property | LockTimeout | Gets or sets the number of milliseconds to wait before failing a lock request, the default of two minutes should be more than adequate.
Public Property | MaximumChildNodes | The largest number of child nodes that should be linked to before refactoring the tree to split this node into two. This property has a side-effect on MinimumChildNodes to ensure that it continues to be at most half of MaximumChildNodes.
Public Property | MaximumValueNodes | The largest number of values that should be contained in this node before refactoring the tree to split this node into two. This property has a side-effect on MinimumValueNodes to ensure that it continues to be at most half of MaximumValueNodes.
Public Property | MinimumChildNodes | The smallest number of child nodes that should be linked to before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2.
Public Property | MinimumValueNodes | The smallest number of values that should be contained in this node before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2.
Public Property | ReadOnly | Sets the BTree into a read-only mode (only supported when opening an existing file)
Public Property | StorageSystem | Sets the custom implementation of the storage back-end to use for the BTree
Public Property | StorageType | Can be used to explicitly specify the storage type, or by simply providing a file name this will be done for you. If no file name was specified the default is to use a memory store.
Public Property | ValueSerializer | Accesses the key serializer given to the constructor
Top

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeOrder Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : BTreeOrder Property

Glossary Item Box

A quick means of setting all the min/max values for the node counts using this value as a basis for the Maximum fields and one-quarter of this value for Minimum fields provided the result is in range.

Syntax

Visual Basic (Declaration)
Public WriteOnly Property BTreeOrder As Integer
C#
public int BTreeOrder {set;}

Example

BPlusTree/BPlusTree.Test/TestFileSerialized.cs

C# Copy Code
BPlusTree<int, string>.Options options = (BPlusTree<int, string>.Options)Options;
options.BTreeOrder = 4;
options.FileBlockSize = 512;
options.FileGrowthRate = 25;
options.ConcurrentWriters = 4;
options.FileOpenOptions = FileOptions.None;

using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
{
    for(int i=0; i < 100; i++)
        Assert.IsTrue(tree.TryAdd(i, i.ToString()));
}

using (Stream io = TempFile.Open())
{
    //first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin);
    io.Write(new byte[512], 0, 512);

    //Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin);
    int len = PrimitiveSerializer.Int32.ReadFrom(io);
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin);//secrets of fragmented file revealed... ugly i know.
    io.WriteByte(255); //overwrite last used byte in chunk.
}

options.CreateFile = CreatePolicy.Never;

//Now that we've corrupted part of the file content, let's take a peek
try
{
    using (BPlusTree<int, string> tree = new BPlusTree<int, string>(options))
    {
        foreach (KeyValuePair<int, string> kv in tree)
            Assert.AreEqual(kv.Key.ToString(), kv.Value);
    }
    Assert.Fail("Expected InvalidDataException");
}
catch (InvalidDataException)
{ }

Dictionary<int, string> found = new Dictionary<int, string>();
List<int> duplicates = new List<int>();
foreach (KeyValuePair<int, string> kv in BPlusTree<int, string>.RecoveryScan(options, FileShare.None))
{
    if (!found.ContainsKey(kv.Key))
        found.Add(kv.Key, kv.Value);
    else
        duplicates.Add(kv.Key);

    Assert.AreEqual(kv.Key.ToString(), kv.Value);
}
Assert.AreNotEqual(0, found.Count);

//The following may change...
Assert.AreEqual(99, found.Count);
Assert.IsFalse(found.ContainsKey(3), "should be missing #3");
Assert.AreEqual(0, duplicates.Count);
VB.NET Copy Code
Dim options As BPlusTree(Of Integer, String).Options = DirectCast(Options, BPlusTree(Of Integer, String).Options)
options.BTreeOrder = 4
options.FileBlockSize = 512
options.FileGrowthRate = 25
options.ConcurrentWriters = 4
options.FileOpenOptions = FileOptions.None

Using tree As New BPlusTree(Of Integer, String)(options)
    Dim i As Integer = 0
    While i < 100
        Assert.IsTrue(tree.TryAdd(i, i.ToString()))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
End Using

Using io As Stream = TempFile.Open()
    'first we can corrupt the root node, which is always at an offset of BlockSize
    io.Seek(512, SeekOrigin.Begin)
    io.Write(New Byte(512) {}, 0, 512)

    'Now let's corrupt one byte from the end of the node at index 3
    io.Seek(1024 + 16, SeekOrigin.Begin)
    Dim len As Integer = PrimitiveSerializer.Int32.ReadFrom(io)
    io.Seek(1024 + 32 + len - 1, SeekOrigin.Begin)
    'secrets of fragmented file revealed... ugly i know.
        'overwrite last used byte in chunk.
    io.WriteByte(255)
End Using

options.CreateFile = CreatePolicy.Never

'Now that we've corrupted part of the file content, let's take a peek
Try
    Using tree As New BPlusTree(Of Integer, String)(options)
        For Each kv As KeyValuePair(Of Integer, String) In tree
            Assert.AreEqual(kv.Key.ToString(), kv.Value)
        Next
    End Using
    Assert.Fail("Expected InvalidDataException")
Catch generatedExceptionName As InvalidDataException
End Try

Dim found As New Dictionary(Of Integer, String)()
Dim duplicates As New List(Of Integer)()
For Each kv As KeyValuePair(Of Integer, String) In BPlusTree(Of Integer, String).RecoveryScan(options, FileShare.None)
    If Not found.ContainsKey(kv.Key) Then
        found.Add(kv.Key, kv.Value)
    Else
        duplicates.Add(kv.Key)
    End If

    Assert.AreEqual(kv.Key.ToString(), kv.Value)
Next
Assert.AreNotEqual(0, found.Count)

'The following may change...
Assert.AreEqual(99, found.Count)
Assert.IsFalse(found.ContainsKey(3), "should be missing #3")
Assert.AreEqual(0, duplicates.Count)

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CacheKeepAliveFactory Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CacheKeepAliveFactory Property

Glossary Item Box

CacheKeepAliveFactory provides a delegate to inject an implementation of the IObjectKeepAlive interface while then igoring all the other CacheKeepAliveXXX properties.

Syntax

Visual Basic (Declaration)
Public Property CacheKeepAliveFactory As CSharpTest.Net.Interfaces.FactoryMethod(Of IObjectKeepAlive)
C#
public CSharpTest.Net.Interfaces.FactoryMethod<IObjectKeepAlive> CacheKeepAliveFactory {get; set;}

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
FactoryMethod

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CacheKeepAliveMaximumHistory Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CacheKeepAliveMaximumHistory Property

Glossary Item Box

Determins maximum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. The ceiling is always respected reguardless of the timeout. Specify a value of 0 to disable history keep alive.

Syntax

Visual Basic (Declaration)
Public Property CacheKeepAliveMaximumHistory As Integer
C#
public int CacheKeepAliveMaximumHistory {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CacheKeepAliveMinimumHistory Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CacheKeepAliveMinimumHistory Property

Glossary Item Box

Determins minimum number of recently visited nodes to keep alive in memory. This number defines the history size, not the number of distinct nodes. This number will always be kept reguardless of the timeout. Specify a value of 0 to allow the timeout to empty the cache.

Syntax

Visual Basic (Declaration)
Public Property CacheKeepAliveMinimumHistory As Integer
C#
public int CacheKeepAliveMinimumHistory {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CacheKeepAliveTimeout Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CacheKeepAliveTimeout Property

Glossary Item Box

If the cache contains more that CacheKeepAliveMinimumHistory items, this timeout will start to remove those items until the cache history is reduced to CacheKeepAliveMinimumHistory. It is important to know that the BPlusTree itself contains no theads and this timeout will not be respected if cache is not in use.

Syntax

Visual Basic (Declaration)
Public Property CacheKeepAliveTimeout As Integer
C#
public int CacheKeepAliveTimeout {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CachePolicy Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CachePolicy Property

Glossary Item Box

Determines how long loaded nodes stay in memory, Full keeps all loaded nodes alive and is the most efficient, The default Recent keeps recently visited nodes alive based on the CacheKeepAlive properties, and None does not cache the nodes at all but does maintain a cache of locks for each node visited.

Syntax

Visual Basic (Declaration)
Public Property CachePolicy As CachePolicy
C#
public CachePolicy CachePolicy {get; set;}

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
CachePolicy

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CallLevelLock Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CallLevelLock Property

Glossary Item Box

Defines a reader/writer lock that used to control exclusive tree access when needed. The public methods for EnableCount(), Clear(), and UnloadCache() each acquire an exclusive (write) lock while all other public methods acquire a shared (read) lock. By default this lock is non-operational (an instance of IgnoreLocking) so if you need the above methods to work while multiple threads are accessing the tree, or if you exclusive access to the tree, specify a lock instance. Since this lock is primarily a read-heavy lock consider using the ReaderWriterLocking or SimpleReadWriteLocking.

Syntax

Visual Basic (Declaration)
Public Overridable Property CallLevelLock As ILockStrategy
C#
public virtual ILockStrategy CallLevelLock {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
ILockStrategy

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateFile Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : CreateFile Property

Glossary Item Box

Gets or sets the file-create policy used when backing with a file storage

Syntax

Visual Basic (Declaration)
Public Property CreateFile As CreatePolicy
C#
public CreatePolicy CreateFile {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
CreatePolicy

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileBlockSize Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : FileBlockSize Property

Glossary Item Box

Gets or sets the number of bytes per file-block used in the file storage

Syntax

Visual Basic (Declaration)
Public Property FileBlockSize As Integer
C#
public int FileBlockSize {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : FileName Property

Glossary Item Box

Gets or sets the FileName that should be used to store the BTree

Syntax

Visual Basic (Declaration)
Public Property FileName As String
C#
public string FileName {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedMassInsertTest.cs

C# Copy Code
mreStop.Reset();
using(TempFile temp = new TempFile())
{
    BPlusTree<Guid, TestInfo>.OptionsV2 options = new BPlusTree<Guid, TestInfo>.OptionsV2(
        PrimitiveSerializer.Guid, new TestInfoSerializer());
    options.CalcBTreeOrder(16, 24);
    options.CreateFile = CreatePolicy.Always;
    options.FileName = temp.TempPath;
    using (BPlusTree<Guid, TestInfo> tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        var actions = new List<IAsyncResult>();
        var tests = new Action<BPlusTree<Guid, TestInfo>>[]
        {
            DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts,
            FetchStuff, FetchStuff, FetchStuff, FetchStuff, FetchStuff
        };

        foreach (var t in tests)
            actions.Add(t.BeginInvoke(tree, null, null));

        do
        {
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
            Thread.Sleep(1000);
        } while (Debugger.IsAttached);

        mreStop.Set();
        for (int i = 0; i < actions.Count; i++)
        {
            tests[i].EndInvoke(actions[i]);
        }

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count);
    }
}
VB.NET Copy Code
mreStop.Reset()
Using temp As New TempFile()
    Dim options As New BPlusTree(Of Guid, TestInfo).OptionsV2(PrimitiveSerializer.Guid, New TestInfoSerializer())
    options.CalcBTreeOrder(16, 24)
    options.CreateFile = CreatePolicy.Always
    options.FileName = temp.TempPath
    Using tree As New BPlusTree(Of Guid, TestInfo)(options)
        tree.EnableCount()
        Dim actions As var = New List(Of IAsyncResult)()
        Dim tests As var = New Action(Of BPlusTree(Of Guid, TestInfo))() {DeleteStuff, UpdateStuff, AddStuff, AddRanges, BulkyInserts, FetchStuff, _
            FetchStuff, FetchStuff, FetchStuff, FetchStuff}

        For Each t As var In tests
            actions.Add(t.BeginInvoke(tree, Nothing, Nothing))
        Next

        Do
            Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
            Thread.Sleep(1000)
        Loop While Debugger.IsAttached

        mreStop.[Set]()
        Dim i As Integer = 0
        While i < actions.Count
            tests(i).EndInvoke(actions(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Trace.TraceInformation("Dictionary.Count = {0}", tree.Count)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileVersion Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : FileVersion Property

Glossary Item Box

Returns the version this option set is compatable with.

Syntax

Visual Basic (Declaration)
Public MustOverride ReadOnly Property FileVersion As FileVersion
C#
public abstract FileVersion FileVersion {get;}

Example

BPlusTree/BPlusTree.Test/SampleCustomTypeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.Options options =
    new BPlusTree<KeyInfo, DataValue>.Options(new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);//we can simply just guess close
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;//obviously this is just for testing
Assert.AreEqual(FileVersion.Version1, options.FileVersion);

Random rand = new Random();
KeyInfo k1 = new KeyInfo(), k2 = new KeyInfo();

using (BPlusTree<KeyInfo, DataValue> tree = new BPlusTree<KeyInfo, DataValue>(options))
{
    byte[] data = new byte[255];

    rand.NextBytes(data);
    tree.Add(k1, new DataValue(k1, data));

    Assert.IsTrue(tree.ContainsKey(k1));
    Assert.IsFalse(tree.ContainsKey(k1.Next()));
    Assert.AreEqual(data, tree[k1].Bytes);

    rand.NextBytes(data);
    tree.Add(k2, new DataValue(k2, data));

    Assert.IsTrue(tree.ContainsKey(k2));
    Assert.IsFalse(tree.ContainsKey(k2.Next()));
    Assert.AreEqual(data, tree[k2].Bytes);
}
options.CreateFile = CreatePolicy.Never;
using (BPlusTree<KeyInfo, DataValue> tree = new BPlusTree<KeyInfo, DataValue>(options))
{
    Assert.IsTrue(tree.ContainsKey(k1));
    Assert.IsTrue(tree.ContainsKey(k2));
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
'we can simply just guess close
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
'obviously this is just for testing
Assert.AreEqual(FileVersion.Version1, options.FileVersion)

Dim rand As New Random()
Dim k1 As New KeyInfo(), k2 As New KeyInfo()

Using tree As New BPlusTree(Of KeyInfo, DataValue)(options)
    Dim data As Byte() = New Byte(255) {}

    rand.NextBytes(data)
    tree.Add(k1, New DataValue(k1, data))

    Assert.IsTrue(tree.ContainsKey(k1))
    Assert.IsFalse(tree.ContainsKey(k1.[Next]()))
    Assert.AreEqual(data, tree(k1).Bytes)

    rand.NextBytes(data)
    tree.Add(k2, New DataValue(k2, data))

    Assert.IsTrue(tree.ContainsKey(k2))
    Assert.IsFalse(tree.ContainsKey(k2.[Next]()))
    Assert.AreEqual(data, tree(k2).Bytes)
End Using
options.CreateFile = CreatePolicy.Never
Using tree As New BPlusTree(Of KeyInfo, DataValue)(options)
    Assert.IsTrue(tree.ContainsKey(k1))
    Assert.IsTrue(tree.ContainsKey(k2))
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
FileVersion


%%PageItemTitle%%

[image]
CSharpTest.Net
KeyComparer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : KeyComparer Property

Glossary Item Box

Defines a custom IComparer<T> to be used for comparing keys

Syntax

Visual Basic (Declaration)
Public Property KeyComparer As IComparer(Of TKey)
C#
public IComparer<TKey> KeyComparer {get; set;}

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C# Copy Code
Dictionary<int, string> test = new Dictionary<int, string>();
List<IEnumerable<KeyValuePair<int, string>>> sets =
    new List<IEnumerable<KeyValuePair<int, string>>>(CreateSets(2, 100, test));
foreach (KeyValuePair<int, string> pair in
    OrderedKeyValuePairs<int, string>.Merge(Options.KeyComparer, DuplicateHandling.LastValueWins, sets.ToArray()))
{
    string val;
    Assert.IsTrue(test.TryGetValue(pair.Key, out val));
    Assert.AreEqual(pair.Value, val);
    Assert.IsTrue(test.Remove(pair.Key));
}

Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim test As New Dictionary(Of Integer, String)()
Dim sets As New List(Of IEnumerable(Of KeyValuePair(Of Integer, String)))(CreateSets(2, 100, test))
For Each pair As KeyValuePair(Of Integer, String) In OrderedKeyValuePairs(Of Integer, String).Merge(Options.KeyComparer, DuplicateHandling.LastValueWins, sets.ToArray())
    Dim val As String
    Assert.IsTrue(test.TryGetValue(pair.Key, val))
    Assert.AreEqual(pair.Value, val)
    Assert.IsTrue(test.Remove(pair.Key))
Next

Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
KeySerializer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : KeySerializer Property

Glossary Item Box

Accesses the key serializer given to the constructor

Syntax

Visual Basic (Declaration)
Public ReadOnly Property KeySerializer As ISerializer(Of TKey)
C#
public ISerializer<TKey> KeySerializer {get;}

Example

BPlusTree/BPlusTree.Test/TestBackupAndRecovery.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    var options = GetOptions(temp);
    options.MaximumValueNodes = 255;
    options.MinimumValueNodes = 100;
    options.TransactionLog = new TransactionLog<Guid, TestInfo>(
        new TransactionLogOptions<Guid, TestInfo>(
            options.TransactionLogFileName,
            options.KeySerializer,
            options.ValueSerializer
            ) { FileOptions = FileOptions.None } /* no-write through */
        );
    TestRecoveryOnExisting(options, 100, ushort.MaxValue);
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim options As var = GetOptions(temp)
    options.MaximumValueNodes = 255
    options.MinimumValueNodes = 100
        ' no-write through
    options.TransactionLog = New TransactionLog(Of Guid, TestInfo)(New TransactionLogOptions(Of Guid, TestInfo)(options.TransactionLogFileName, options.KeySerializer, options.ValueSerializer) With { _
        Key .FileOptions = FileOptions.None _
    })
    TestRecoveryOnExisting(options, 100, UShort.MaxValue)
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
ISerializer

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LockingFactory Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : LockingFactory Property

Glossary Item Box

Gets or sets the locking factory to use for accessing shared data. The default is WriterOnlyLocking() which does not perform read locks, rather it will rely on the cache of the btree and may preform dirty reads. You can use any implementation of ILockFactory; however, the SimpleReadWriteLocking seems to perform the most efficiently for both reader/writer locks. Additionally wrapping that instance in a ReserveredWriterLocking() instance will allow reads to continue up until a writer begins the commit process. If you are only accessing the BTree instance from a single thread this can be set to IgnoreLocking. Be careful of using ReaderWriterLocking as the write-intesive nature of the BTree will suffer extreme performance penalties with this lock.

Syntax

Visual Basic (Declaration)
Public Property LockingFactory As ILockFactory
C#
public ILockFactory LockingFactory {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
ILockFactory

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LockTimeout Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : LockTimeout Property

Glossary Item Box

Gets or sets the number of milliseconds to wait before failing a lock request, the default of two minutes should be more than adequate.

Syntax

Visual Basic (Declaration)
Public Property LockTimeout As Integer
C#
public int LockTimeout {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaximumChildNodes Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : MaximumChildNodes Property

Glossary Item Box

The largest number of child nodes that should be linked to before refactoring the tree to split this node into two. This property has a side-effect on MinimumChildNodes to ensure that it continues to be at most half of MaximumChildNodes.

Syntax

Visual Basic (Declaration)
Public Property MaximumChildNodes As Integer
C#
public int MaximumChildNodes {get; set;}

Property Value

A number in the range of 4 to 256.

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C# Copy Code
BPlusTreeOptions<int, string> options = Options;
using (TempFile temp = new TempFile())
{
    options = Options;
    temp.Delete();
    //options.CreateFile = CreatePolicy.Always;
    //options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14;
    options.MinimumValueNodes = 7;
    options.MaximumChildNodes = 6;
    options.MinimumChildNodes = 2;

    // Just to make sure we don't break some fencepost condition in the future
    for (int i = 0; i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1; i++)
        TestMergeSequenceInFile(options.Clone(), i);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1);
}
VB.NET Copy Code
Dim options As BPlusTreeOptions(Of Integer, String) = Options
Using temp As New TempFile()
    options = Options
    temp.Delete()
    'options.CreateFile = CreatePolicy.Always;
    'options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14
    options.MinimumValueNodes = 7
    options.MaximumChildNodes = 6
    options.MinimumChildNodes = 2

    ' Just to make sure we don't break some fencepost condition in the future
    Dim i As Integer = 0
    While i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1
        TestMergeSequenceInFile(options.Clone(), i)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes)
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1)
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaximumValueNodes Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : MaximumValueNodes Property

Glossary Item Box

The largest number of values that should be contained in this node before refactoring the tree to split this node into two. This property has a side-effect on MinimumValueNodes to ensure that it continues to be at most half of MaximumValueNodes.

Syntax

Visual Basic (Declaration)
Public Property MaximumValueNodes As Integer
C#
public int MaximumValueNodes {get; set;}

Property Value

A number in the range of 4 to 256.

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C# Copy Code
BPlusTreeOptions<int, string> options = Options;
using (TempFile temp = new TempFile())
{
    options = Options;
    temp.Delete();
    //options.CreateFile = CreatePolicy.Always;
    //options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14;
    options.MinimumValueNodes = 7;
    options.MaximumChildNodes = 6;
    options.MinimumChildNodes = 2;

    // Just to make sure we don't break some fencepost condition in the future
    for (int i = 0; i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1; i++)
        TestMergeSequenceInFile(options.Clone(), i);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1);
}
VB.NET Copy Code
Dim options As BPlusTreeOptions(Of Integer, String) = Options
Using temp As New TempFile()
    options = Options
    temp.Delete()
    'options.CreateFile = CreatePolicy.Always;
    'options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14
    options.MinimumValueNodes = 7
    options.MaximumChildNodes = 6
    options.MinimumChildNodes = 2

    ' Just to make sure we don't break some fencepost condition in the future
    Dim i As Integer = 0
    While i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1
        TestMergeSequenceInFile(options.Clone(), i)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes)
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1)
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MinimumChildNodes Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : MinimumChildNodes Property

Glossary Item Box

The smallest number of child nodes that should be linked to before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2.

Syntax

Visual Basic (Declaration)
Public Property MinimumChildNodes As Integer
C#
public int MinimumChildNodes {get; set;}

Property Value

A number in the range of 2 to 128 that is at most half of MaximumChildNodes.

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C# Copy Code
BPlusTreeOptions<int, string> options = Options;
using (TempFile temp = new TempFile())
{
    options = Options;
    temp.Delete();
    //options.CreateFile = CreatePolicy.Always;
    //options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14;
    options.MinimumValueNodes = 7;
    options.MaximumChildNodes = 6;
    options.MinimumChildNodes = 2;

    // Just to make sure we don't break some fencepost condition in the future
    for (int i = 0; i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1; i++)
        TestMergeSequenceInFile(options.Clone(), i);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1);
}
VB.NET Copy Code
Dim options As BPlusTreeOptions(Of Integer, String) = Options
Using temp As New TempFile()
    options = Options
    temp.Delete()
    'options.CreateFile = CreatePolicy.Always;
    'options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14
    options.MinimumValueNodes = 7
    options.MaximumChildNodes = 6
    options.MinimumChildNodes = 2

    ' Just to make sure we don't break some fencepost condition in the future
    Dim i As Integer = 0
    While i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1
        TestMergeSequenceInFile(options.Clone(), i)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes)
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1)
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MinimumValueNodes Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : MinimumValueNodes Property

Glossary Item Box

The smallest number of values that should be contained in this node before refactoring the tree to remove this node. In a 'normal' and/or purest B+Tree this is always half of max; however for performance reasons this B+Tree allow any value equal to or less than half of max but at least 2.

Syntax

Visual Basic (Declaration)
Public Property MinimumValueNodes As Integer
C#
public int MinimumValueNodes {get; set;}

Property Value

A number in the range of 2 to 128 that is at most half of MaximumValueNodes.

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C# Copy Code
BPlusTreeOptions<int, string> options = Options;
using (TempFile temp = new TempFile())
{
    options = Options;
    temp.Delete();
    //options.CreateFile = CreatePolicy.Always;
    //options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14;
    options.MinimumValueNodes = 7;
    options.MaximumChildNodes = 6;
    options.MinimumChildNodes = 2;

    // Just to make sure we don't break some fencepost condition in the future
    for (int i = 0; i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1; i++)
        TestMergeSequenceInFile(options.Clone(), i);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes);
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1);
}
VB.NET Copy Code
Dim options As BPlusTreeOptions(Of Integer, String) = Options
Using temp As New TempFile()
    options = Options
    temp.Delete()
    'options.CreateFile = CreatePolicy.Always;
    'options.FileName = temp.TempPath;
    options.MaximumValueNodes = 14
    options.MinimumValueNodes = 7
    options.MaximumChildNodes = 6
    options.MinimumChildNodes = 2

    ' Just to make sure we don't break some fencepost condition in the future
    Dim i As Integer = 0
    While i <= (options.MaximumValueNodes * options.MaximumChildNodes) + 1
        TestMergeSequenceInFile(options.Clone(), i)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes)
    TestMergeSequenceInFile(options.Clone(), options.MaximumValueNodes * options.MaximumChildNodes * options.MaximumChildNodes + 1)
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadOnly Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : ReadOnly Property

Glossary Item Box

Sets the BTree into a read-only mode (only supported when opening an existing file)

Syntax

Visual Basic (Declaration)
Public Property ReadOnly As Boolean
C#
public bool ReadOnly {get; set;}

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
                      {
                          CreateFile = CreatePolicy.Always,
                          FileName = tempFile.TempPath,
                      }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.CreateFile = CreatePolicy.Never;
    readcopy.ReadOnly = true;

    using (var tree = new BPlusTree<int, string>(options))
    {
        using (var copy = new BPlusTree<int, string>(readcopy))
        {
            copy.EnableCount();
            Assert.AreEqual(0, copy.Count);
        }

        //insert some data...
        tree.AddRange(MakeValues(0, 100));

        using (var copy = new BPlusTree<int, string>(readcopy))
        {
            copy.EnableCount();
            Assert.AreEqual(0, copy.Count);
        }
        tree.Commit();

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tree.AddRange(MakeValues(1000, 1000));

        using (var copy = new BPlusTree<int, string>(readcopy))
        {
            copy.EnableCount();
            Assert.AreEqual(100, copy.Count);
            Assert.AreEqual(0, copy.First().Key);
            Assert.AreEqual(99, copy.Last().Key);
        }

        tree.Commit();

    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
        Key .CreateFile = CreatePolicy.Always, _
        Key .FileName = tempFile.TempPath _
    }.CalcBTreeOrder(4, 10)

    Dim readcopy As var = options.Clone()
    readcopy.CreateFile = CreatePolicy.Never
    readcopy.[ReadOnly] = True

    Using tree As var = New BPlusTree(Of Integer, String)(options)
        Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
            copy.EnableCount()
            Assert.AreEqual(0, copy.Count)
        End Using

        'insert some data...
        tree.AddRange(MakeValues(0, 100))

        Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
            copy.EnableCount()
            Assert.AreEqual(0, copy.Count)
        End Using
        tree.Commit()

        'insert some data...
        Dim i As Integer = 0
        While i < 100
            tree.Remove(i)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        tree.AddRange(MakeValues(1000, 1000))

        Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
            copy.EnableCount()
            Assert.AreEqual(100, copy.Count)
            Assert.AreEqual(0, copy.First().Key)
            Assert.AreEqual(99, copy.Last().Key)
        End Using

        tree.Commit()
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StorageSystem Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : StorageSystem Property

Glossary Item Box

Sets the custom implementation of the storage back-end to use for the BTree

Syntax

Visual Basic (Declaration)
Public Property StorageSystem As INodeStorage
C#
public INodeStorage StorageSystem {get; set;}

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
INodeStorage

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StorageType Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : StorageType Property

Glossary Item Box

Can be used to explicitly specify the storage type, or by simply providing a file name this will be done for you. If no file name was specified the default is to use a memory store.

Syntax

Visual Basic (Declaration)
Public Property StorageType As StorageType
C#
public StorageType StorageType {get; set;}

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
StorageType

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ValueSerializer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTreeOptions<TKey,TValue> Class : ValueSerializer Property

Glossary Item Box

Accesses the key serializer given to the constructor

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ValueSerializer As ISerializer(Of TValue)
C#
public ISerializer<TValue> ValueSerializer {get;}

Example

BPlusTree/BPlusTree.Test/TestBackupAndRecovery.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    var options = GetOptions(temp);
    options.MaximumValueNodes = 255;
    options.MinimumValueNodes = 100;
    options.TransactionLog = new TransactionLog<Guid, TestInfo>(
        new TransactionLogOptions<Guid, TestInfo>(
            options.TransactionLogFileName,
            options.KeySerializer,
            options.ValueSerializer
            ) { FileOptions = FileOptions.None } /* no-write through */
        );
    TestRecoveryOnExisting(options, 100, ushort.MaxValue);
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim options As var = GetOptions(temp)
    options.MaximumValueNodes = 255
    options.MinimumValueNodes = 100
        ' no-write through
    options.TransactionLog = New TransactionLog(Of Guid, TestInfo)(New TransactionLogOptions(Of Guid, TestInfo)(options.TransactionLogFileName, options.KeySerializer, options.ValueSerializer) With { _
        Key .FileOptions = FileOptions.None _
    })
    TestRecoveryOnExisting(options, 100, UShort.MaxValue)
End Using

Requirements

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

See Also

Reference

BPlusTreeOptions<TKey,TValue> Class
BPlusTreeOptions<TKey,TValue> Members
ISerializer

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/BPlusTree.OptionsBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BulkInsertOptions Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BulkInsertOptions Class

Glossary Item Box

Options for bulk insertion

Syntax

Visual Basic (Declaration)
Public Class BulkInsertOptions
C#
public class BulkInsertOptions

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BulkInsertOptions

Requirements

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

See Also

Reference

BulkInsertOptions Members
CSharpTest.Net.Collections Namespace
Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BulkInsertOptions Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BulkInsertOptions Class

Glossary Item Box

The following tables list the members exposed by BulkInsertOptions.

Public Constructors

 | Name | Description
Public Constructor | BulkInsertOptions Constructor | Constructs with defaults: false/RaisesException
Top

Public Properties

 | Name | Description
Public Property | CommitOnCompletion | When true (default) BulkInsert will call CommitChanges() on successfull completion
Public Property | DuplicateHandling | Gets or sets the handling for duplicate key collisions
Public Property | InputIsSorted | Gets or sets a value that controls input presorting
Public Property | ReplaceContents | When false merges the data with the existing contents, set to true to replace all content
Top

See Also

Reference

BulkInsertOptions Class
CSharpTest.Net.Collections Namespace
Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BulkInsertOptions Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BulkInsertOptions Class : BulkInsertOptions Constructor

Glossary Item Box

Constructs with defaults: false/RaisesException

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public BulkInsertOptions()

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BulkInsertOptions Class
BulkInsertOptions Members

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)
Int32 BPlusTree.BulkInsert(IEnumerable>)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BulkInsertOptions Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BulkInsertOptions Class

Glossary Item Box

For a list of all members of this type, see BulkInsertOptions members.

Public Properties

 | Name | Description
Public Property | CommitOnCompletion | When true (default) BulkInsert will call CommitChanges() on successfull completion
Public Property | DuplicateHandling | Gets or sets the handling for duplicate key collisions
Public Property | InputIsSorted | Gets or sets a value that controls input presorting
Public Property | ReplaceContents | When false merges the data with the existing contents, set to true to replace all content
Top

See Also

Reference

BulkInsertOptions Class
CSharpTest.Net.Collections Namespace
Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommitOnCompletion Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BulkInsertOptions Class : CommitOnCompletion Property

Glossary Item Box

When true (default) BulkInsert will call CommitChanges() on successfull completion

Syntax

Visual Basic (Declaration)
Public Property CommitOnCompletion As Boolean
C#
public bool CommitOnCompletion {get; set;}

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BulkInsertOptions Class
BulkInsertOptions Members

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateHandling Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BulkInsertOptions Class : DuplicateHandling Property

Glossary Item Box

Gets or sets the handling for duplicate key collisions

Syntax

Visual Basic (Declaration)
Public Property DuplicateHandling As DuplicateHandling
C#
public DuplicateHandling DuplicateHandling {get; set;}

Example

BPlusTree/BPlusTree.Test/TestBulkInsert.cs

C# Copy Code
Dictionary<int, string> test = new Dictionary<int, string>();
IEnumerable<KeyValuePair<int, string>>[] sets =
    new List<IEnumerable<KeyValuePair<int, string>>>(CreateSets(1, 1000, test)).ToArray();

using (BPlusTree<int, string> tree = new BPlusTree<int, string>(Options))
{
    tree.BulkInsert(
        new OrderedKeyValuePairs<int, string>(sets[0]),
        new BulkInsertOptions { DuplicateHandling = DuplicateHandling.LastValueWins, InputIsSorted = true }
        );

    VerifyDictionary(test, tree);

    // Use bulk insert to overwrite the contents of tree
    test = new Dictionary<int, string>();
    sets = new List<IEnumerable<KeyValuePair<int, string>>>(CreateSets(1, 100, test)).ToArray();

    tree.BulkInsert(
        new OrderedKeyValuePairs<int, string>(sets[0]),
        new BulkInsertOptions
        {
            CommitOnCompletion = false,
            InputIsSorted = true,
            ReplaceContents = true,
            DuplicateHandling = DuplicateHandling.RaisesException,
        }
    );

    VerifyDictionary(test, tree);
}
VB.NET Copy Code
Dim test As New Dictionary(Of Integer, String)()
Dim sets As IEnumerable(Of KeyValuePair(Of Integer, String))() = New List(Of IEnumerable(Of KeyValuePair(Of Integer, String)))(CreateSets(1, 1000, test)).ToArray()

Using tree As New BPlusTree(Of Integer, String)(Options)
    tree.BulkInsert(New OrderedKeyValuePairs(Of Integer, String)(sets(0)), New BulkInsertOptions() With { _
        Key .DuplicateHandling = DuplicateHandling.LastValueWins, _
        Key .InputIsSorted = True _
    })

    VerifyDictionary(test, tree)

    ' Use bulk insert to overwrite the contents of tree
    test = New Dictionary(Of Integer, String)()
    sets = New List(Of IEnumerable(Of KeyValuePair(Of Integer, String)))(CreateSets(1, 100, test)).ToArray()

    tree.BulkInsert(New OrderedKeyValuePairs(Of Integer, String)(sets(0)), New BulkInsertOptions() With { _
        Key .CommitOnCompletion = False, _
        Key .InputIsSorted = True, _
        Key .ReplaceContents = True, _
        Key .DuplicateHandling = DuplicateHandling.RaisesException _
    })

    VerifyDictionary(test, tree)
End Using

Requirements

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

See Also

Reference

BulkInsertOptions Class
BulkInsertOptions Members
DuplicateHandling

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)
Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InputIsSorted Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BulkInsertOptions Class : InputIsSorted Property

Glossary Item Box

Gets or sets a value that controls input presorting

Syntax

Visual Basic (Declaration)
Public Property InputIsSorted As Boolean
C#
public bool InputIsSorted {get; set;}

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BulkInsertOptions Class
BulkInsertOptions Members

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplaceContents Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BulkInsertOptions Class : ReplaceContents Property

Glossary Item Box

When false merges the data with the existing contents, set to true to replace all content

Syntax

Visual Basic (Declaration)
Public Property ReplaceContents As Boolean
C#
public bool ReplaceContents {get; set;}

Example

BPlusTree/BPlusTree.Test/TestMultiInstance.cs

C# Copy Code
using (var tempFile = new TempFile())
using (var logfile = new TempFile())
using (var tempCopy = new TempFile())
{
    var options = new BPlusTree<int, string>.OptionsV2(new PrimitiveSerializer(), new PrimitiveSerializer())
    {
        CreateFile = CreatePolicy.Always,
        FileName = tempFile.TempPath,
        TransactionLogFileName = logfile.TempPath,
    }.CalcBTreeOrder(4, 10);

    var readcopy = options.Clone();
    readcopy.FileName = tempCopy.TempPath;
    readcopy.StoragePerformance = StoragePerformance.Fastest;

    using (var tree = new BPlusTree<int, string>(options))
    using (var copy = new BPlusTree<int, string>(readcopy))
    using (var tlog = new TransactionLog<int, string>(
        new TransactionLogOptions<int, string>(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.String) { ReadOnly = true }))
    {
        tree.Add(0, "0");
        tree.Commit();

        long logpos = 0;
        copy.EnableCount();
        //start by copying the data from tree's file into the copy instance:
        copy.BulkInsert(
            BPlusTree<int, string>.EnumerateFile(options),
            new BulkInsertOptions { InputIsSorted = true, CommitOnCompletion = false, ReplaceContents = true }
            );

        Assert.AreEqual(1, copy.Count);
        Assert.AreEqual("0", copy[0]);

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1, copy.Count);

        //insert some data...
        tree.AddRange(MakeValues(1, 99));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(100, copy.Count);

        //insert some data...
        for (int i = 0; i < 100; i++)
            tree.Remove(i);
        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(0, copy.Count);

        tree.AddRange(MakeValues(1000, 1000));

        tlog.ReplayLog(copy, ref logpos);
        Assert.AreEqual(1000, copy.Count);
    }
}
VB.NET Copy Code
Using tempFile As var = New TempFile()
    Using logfile As var = New TempFile()
        Using tempCopy As var = New TempFile()
            Dim options As var = New BPlusTree(Of Integer, String).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer()) With { _
                Key .CreateFile = CreatePolicy.Always, _
                Key .FileName = tempFile.TempPath, _
                Key .TransactionLogFileName = logfile.TempPath _
            }.CalcBTreeOrder(4, 10)

            Dim readcopy As var = options.Clone()
            readcopy.FileName = tempCopy.TempPath
            readcopy.StoragePerformance = StoragePerformance.Fastest

            Using tree As var = New BPlusTree(Of Integer, String)(options)
                Using copy As var = New BPlusTree(Of Integer, String)(readcopy)
                    Using tlog As var = New TransactionLog(Of Integer, String)(New TransactionLogOptions(Of Integer, String)(logfile.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String]) With { _
                        Key .[ReadOnly] = True _
                    })
                        tree.Add(0, "0")
                        tree.Commit()

                        Dim logpos As Long = 0
                        copy.EnableCount()
                        'start by copying the data from tree's file into the copy instance:
                        copy.BulkInsert(BPlusTree(Of Integer, String).EnumerateFile(options), New BulkInsertOptions() With { _
                            Key .InputIsSorted = True, _
                            Key .CommitOnCompletion = False, _
                            Key .ReplaceContents = True _
                        })

                        Assert.AreEqual(1, copy.Count)
                        Assert.AreEqual("0", copy(0))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1, copy.Count)

                        'insert some data...
                        tree.AddRange(MakeValues(1, 99))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(100, copy.Count)

                        'insert some data...
                        Dim i As Integer = 0
                        While i < 100
                            tree.Remove(i)
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(0, copy.Count)

                        tree.AddRange(MakeValues(1000, 1000))

                        tlog.ReplayLog(copy, logpos)
                        Assert.AreEqual(1000, copy.Count)
                    End Using
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

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

See Also

Reference

BulkInsertOptions Class
BulkInsertOptions Members

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

BPlusTree/Collections/Node.BulkInsert.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
TransactionLog<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionLog<TKey,TValue> Class

Glossary Item Box

The default transaction log for a BPlusTree instance to provide backup+log recovery

Syntax

Visual Basic (Declaration)
Public Class TransactionLog
    (Of TKey,TValue)
   Implements ITransactionLog(Of TKey,TValue)
C#
public class TransactionLog<TKey,TValue> : ITransactionLog<TKey,TValue>

Type Parameters

TKey
TValue

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
{
    using (var log = new TransactionLog<int, string>(Options(tmp)))
    {
        var token = log.BeginTransaction();
        log.AddValue(ref token, 1, Guid.NewGuid().ToString());
        log.CommitTransaction(ref token);
        var test = new Dictionary<int, string>();
        long offset = 0;
        log.ReplayLog(test, ref offset);
        Assert.AreEqual(1, test.Count);
    }
    byte[] bytes = tmp.ReadAllBytes();

    var TestVariants =
        new Converter<KeyValuePair<int, byte[]>, byte[]>[]
            {
                kv => { kv.Value[kv.Key] ^= 0xff; return kv.Value; },
                kv => { kv.Value[kv.Key] = 0xff; return kv.Value; },
                kv => { byte[] b = kv.Value; Array.Resize(ref b, kv.Key); return b; },
            };

    for (int corruptionIx = 0; corruptionIx < bytes.Length; corruptionIx++)
    {
        foreach (var testcase in TestVariants)
        {
            byte[] corrupt = testcase(new KeyValuePair<int, byte[]>(corruptionIx, (byte[]) bytes.Clone()));
            tmp.WriteAllBytes(corrupt);

            using (var log = new TransactionLog<int, string>(Options(tmp)))
            {
                var test = new Dictionary<int, string>();
                log.ReplayLog(test);
                Assert.AreEqual(0, test.Count);
            }
            Assert.IsFalse(File.Exists(tmp.TempPath));
        }
    }
}
VB.NET Copy Code
Using tmp As New TempFile()
            Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                Dim token As var = log.BeginTransaction()
                log.AddValue(token, 1, Guid.NewGuid().ToString())
                log.CommitTransaction(token)
                Dim test As var = New Dictionary(Of Integer, String)()
                Dim offset As Long = 0
                log.ReplayLog(test, offset)
                Assert.AreEqual(1, test.Count)
            End Using
            Dim bytes As Byte() = tmp.ReadAllBytes()

            Dim TestVariants As var = New Converter(Of KeyValuePair(Of Integer, Byte()), Byte())() {Function(kv)
            kv.Value(kv.Key) = kv.Value(kv.Key) Xor &Hff
            Return kv.Value

End Function, Function(kv)
            kv.Value(kv.Key) = &Hff
            Return kv.Value

End Function, Function(kv)
            Dim b As Byte() = kv.Value
            Array.Resize(b, kv.Key)
            Return b

End Function}

            Dim corruptionIx As Integer = 0
            While corruptionIx < bytes.Length
                For Each testcase As var In TestVariants
                    Dim corrupt As Byte() = testcase(New KeyValuePair(Of Integer, Byte())(corruptionIx, DirectCast(bytes.Clone(), Byte())))
                    tmp.WriteAllBytes(corrupt)

                    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                        Dim test As var = New Dictionary(Of Integer, String)()
                        log.ReplayLog(test)
                        Assert.AreEqual(0, test.Count)
                    End Using
                    Assert.IsFalse(File.Exists(tmp.TempPath))
                Next
                System.Math.Max(System.Threading.Interlocked.Increment(corruptionIx),corruptionIx - 1)
            End While
        End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.TransactionLog<TKey,TValue>

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TransactionLog<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionLog<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by TransactionLog<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | TransactionLog<TKey,TValue> Constructor | Creates an instance of a transaction log
Top

Public Properties

 | Name | Description
Public Property | FileName | Returns the file name of the current transaction log file
Public Property | Size | Returns the current size of the log file in bytes
Top

Public Methods

 | Name | Description
Public Method | AddValue | The provided key/value pair was added in the provided transaction
Public Method | BeginTransaction | Notifies the log that a transaction is begining and create a token for this transaction scope.
Public Method | Close | Flushes any pending writes and closes the writer.
Public Method | CommitTransaction | Commits the provided transaction
Public Method | MergeLog | Merges the contents of the log with an existing ordered key/value pair collection.
Public Method | RemoveValue | The provided key/value pair was removed in the provided transaction
Public Method | ReplayLog | Overloaded. Replay the entire log file to the provided dictionary interface
Public Method | RollbackTransaction | Abandons the provided transaction
Public Method | TruncateLog | Truncate the log and remove all existing entries
Public Method | UpdateValue | The provided key/value pair was updated in the provided transaction
Top

See Also

Reference

TransactionLog<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactionLog<TKey,TValue> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : TransactionLog<TKey,TValue> Constructor

options

Glossary Item Box

Creates an instance of a transaction log

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal options As TransactionLogOptions(Of TKey,TValue) _
)
C#
public TransactionLog<TKey,TValue>(
   TransactionLogOptions<TKey,TValue> options
)

Parameters

options

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
{
    using (var log = new TransactionLog<int, string>(Options(tmp)))
    {
        var token = log.BeginTransaction();
        log.AddValue(ref token, 1, Guid.NewGuid().ToString());
        log.CommitTransaction(ref token);
        var test = new Dictionary<int, string>();
        long offset = 0;
        log.ReplayLog(test, ref offset);
        Assert.AreEqual(1, test.Count);
    }
    byte[] bytes = tmp.ReadAllBytes();

    var TestVariants =
        new Converter<KeyValuePair<int, byte[]>, byte[]>[]
            {
                kv => { kv.Value[kv.Key] ^= 0xff; return kv.Value; },
                kv => { kv.Value[kv.Key] = 0xff; return kv.Value; },
                kv => { byte[] b = kv.Value; Array.Resize(ref b, kv.Key); return b; },
            };

    for (int corruptionIx = 0; corruptionIx < bytes.Length; corruptionIx++)
    {
        foreach (var testcase in TestVariants)
        {
            byte[] corrupt = testcase(new KeyValuePair<int, byte[]>(corruptionIx, (byte[]) bytes.Clone()));
            tmp.WriteAllBytes(corrupt);

            using (var log = new TransactionLog<int, string>(Options(tmp)))
            {
                var test = new Dictionary<int, string>();
                log.ReplayLog(test);
                Assert.AreEqual(0, test.Count);
            }
            Assert.IsFalse(File.Exists(tmp.TempPath));
        }
    }
}
VB.NET Copy Code
Using tmp As New TempFile()
            Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                Dim token As var = log.BeginTransaction()
                log.AddValue(token, 1, Guid.NewGuid().ToString())
                log.CommitTransaction(token)
                Dim test As var = New Dictionary(Of Integer, String)()
                Dim offset As Long = 0
                log.ReplayLog(test, offset)
                Assert.AreEqual(1, test.Count)
            End Using
            Dim bytes As Byte() = tmp.ReadAllBytes()

            Dim TestVariants As var = New Converter(Of KeyValuePair(Of Integer, Byte()), Byte())() {Function(kv)
            kv.Value(kv.Key) = kv.Value(kv.Key) Xor &Hff
            Return kv.Value

End Function, Function(kv)
            kv.Value(kv.Key) = &Hff
            Return kv.Value

End Function, Function(kv)
            Dim b As Byte() = kv.Value
            Array.Resize(b, kv.Key)
            Return b

End Function}

            Dim corruptionIx As Integer = 0
            While corruptionIx < bytes.Length
                For Each testcase As var In TestVariants
                    Dim corrupt As Byte() = testcase(New KeyValuePair(Of Integer, Byte())(corruptionIx, DirectCast(bytes.Clone(), Byte())))
                    tmp.WriteAllBytes(corrupt)

                    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                        Dim test As var = New Dictionary(Of Integer, String)()
                        log.ReplayLog(test)
                        Assert.AreEqual(0, test.Count)
                    End Using
                    Assert.IsFalse(File.Exists(tmp.TempPath))
                Next
                System.Math.Max(System.Threading.Interlocked.Increment(corruptionIx),corruptionIx - 1)
            End While
        End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TransactionLog<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionLog<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see TransactionLog<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | AddValue | The provided key/value pair was added in the provided transaction
Public Method | BeginTransaction | Notifies the log that a transaction is begining and create a token for this transaction scope.
Public Method | Close | Flushes any pending writes and closes the writer.
Public Method | CommitTransaction | Commits the provided transaction
Public Method | MergeLog | Merges the contents of the log with an existing ordered key/value pair collection.
Public Method | RemoveValue | The provided key/value pair was removed in the provided transaction
Public Method | ReplayLog | Overloaded. Replay the entire log file to the provided dictionary interface
Public Method | RollbackTransaction | Abandons the provided transaction
Public Method | TruncateLog | Truncate the log and remove all existing entries
Public Method | UpdateValue | The provided key/value pair was updated in the provided transaction
Top

See Also

Reference

TransactionLog<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : AddValue Method

token
key
value

Glossary Item Box

The provided key/value pair was added in the provided transaction

Syntax

Visual Basic (Declaration)
Public Sub AddValue( _
   ByRef token As TransactionToken, _
   ByVal key As TKey, _
   ByVal value As TValue _
)
C#
public void AddValue(
   ref TransactionToken token,
   TKey key,
   TValue value
)

Parameters

token
key
value

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
{
    using (var log = new TransactionLog<int, string>(Options(tmp)))
    {
        var token = log.BeginTransaction();
        log.AddValue(ref token, 1, Guid.NewGuid().ToString());
        log.CommitTransaction(ref token);
        var test = new Dictionary<int, string>();
        long offset = 0;
        log.ReplayLog(test, ref offset);
        Assert.AreEqual(1, test.Count);
    }
    byte[] bytes = tmp.ReadAllBytes();

    var TestVariants =
        new Converter<KeyValuePair<int, byte[]>, byte[]>[]
            {
                kv => { kv.Value[kv.Key] ^= 0xff; return kv.Value; },
                kv => { kv.Value[kv.Key] = 0xff; return kv.Value; },
                kv => { byte[] b = kv.Value; Array.Resize(ref b, kv.Key); return b; },
            };

    for (int corruptionIx = 0; corruptionIx < bytes.Length; corruptionIx++)
    {
        foreach (var testcase in TestVariants)
        {
            byte[] corrupt = testcase(new KeyValuePair<int, byte[]>(corruptionIx, (byte[]) bytes.Clone()));
            tmp.WriteAllBytes(corrupt);

            using (var log = new TransactionLog<int, string>(Options(tmp)))
            {
                var test = new Dictionary<int, string>();
                log.ReplayLog(test);
                Assert.AreEqual(0, test.Count);
            }
            Assert.IsFalse(File.Exists(tmp.TempPath));
        }
    }
}
VB.NET Copy Code
Using tmp As New TempFile()
            Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                Dim token As var = log.BeginTransaction()
                log.AddValue(token, 1, Guid.NewGuid().ToString())
                log.CommitTransaction(token)
                Dim test As var = New Dictionary(Of Integer, String)()
                Dim offset As Long = 0
                log.ReplayLog(test, offset)
                Assert.AreEqual(1, test.Count)
            End Using
            Dim bytes As Byte() = tmp.ReadAllBytes()

            Dim TestVariants As var = New Converter(Of KeyValuePair(Of Integer, Byte()), Byte())() {Function(kv)
            kv.Value(kv.Key) = kv.Value(kv.Key) Xor &Hff
            Return kv.Value

End Function, Function(kv)
            kv.Value(kv.Key) = &Hff
            Return kv.Value

End Function, Function(kv)
            Dim b As Byte() = kv.Value
            Array.Resize(b, kv.Key)
            Return b

End Function}

            Dim corruptionIx As Integer = 0
            While corruptionIx < bytes.Length
                For Each testcase As var In TestVariants
                    Dim corrupt As Byte() = testcase(New KeyValuePair(Of Integer, Byte())(corruptionIx, DirectCast(bytes.Clone(), Byte())))
                    tmp.WriteAllBytes(corrupt)

                    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                        Dim test As var = New Dictionary(Of Integer, String)()
                        log.ReplayLog(test)
                        Assert.AreEqual(0, test.Count)
                    End Using
                    Assert.IsFalse(File.Exists(tmp.TempPath))
                Next
                System.Math.Max(System.Threading.Interlocked.Increment(corruptionIx),corruptionIx - 1)
            End While
        End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members
TransactionToken

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BeginTransaction Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : BeginTransaction Method

Glossary Item Box

Notifies the log that a transaction is begining and create a token for this transaction scope.

Syntax

Visual Basic (Declaration)
Public Function BeginTransaction() As TransactionToken
C#
public TransactionToken BeginTransaction()

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
{
    using (var log = new TransactionLog<int, string>(Options(tmp)))
    {
        var token = log.BeginTransaction();
        log.AddValue(ref token, 1, Guid.NewGuid().ToString());
        log.CommitTransaction(ref token);
        var test = new Dictionary<int, string>();
        long offset = 0;
        log.ReplayLog(test, ref offset);
        Assert.AreEqual(1, test.Count);
    }
    byte[] bytes = tmp.ReadAllBytes();

    var TestVariants =
        new Converter<KeyValuePair<int, byte[]>, byte[]>[]
            {
                kv => { kv.Value[kv.Key] ^= 0xff; return kv.Value; },
                kv => { kv.Value[kv.Key] = 0xff; return kv.Value; },
                kv => { byte[] b = kv.Value; Array.Resize(ref b, kv.Key); return b; },
            };

    for (int corruptionIx = 0; corruptionIx < bytes.Length; corruptionIx++)
    {
        foreach (var testcase in TestVariants)
        {
            byte[] corrupt = testcase(new KeyValuePair<int, byte[]>(corruptionIx, (byte[]) bytes.Clone()));
            tmp.WriteAllBytes(corrupt);

            using (var log = new TransactionLog<int, string>(Options(tmp)))
            {
                var test = new Dictionary<int, string>();
                log.ReplayLog(test);
                Assert.AreEqual(0, test.Count);
            }
            Assert.IsFalse(File.Exists(tmp.TempPath));
        }
    }
}
VB.NET Copy Code
Using tmp As New TempFile()
            Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                Dim token As var = log.BeginTransaction()
                log.AddValue(token, 1, Guid.NewGuid().ToString())
                log.CommitTransaction(token)
                Dim test As var = New Dictionary(Of Integer, String)()
                Dim offset As Long = 0
                log.ReplayLog(test, offset)
                Assert.AreEqual(1, test.Count)
            End Using
            Dim bytes As Byte() = tmp.ReadAllBytes()

            Dim TestVariants As var = New Converter(Of KeyValuePair(Of Integer, Byte()), Byte())() {Function(kv)
            kv.Value(kv.Key) = kv.Value(kv.Key) Xor &Hff
            Return kv.Value

End Function, Function(kv)
            kv.Value(kv.Key) = &Hff
            Return kv.Value

End Function, Function(kv)
            Dim b As Byte() = kv.Value
            Array.Resize(b, kv.Key)
            Return b

End Function}

            Dim corruptionIx As Integer = 0
            While corruptionIx < bytes.Length
                For Each testcase As var In TestVariants
                    Dim corrupt As Byte() = testcase(New KeyValuePair(Of Integer, Byte())(corruptionIx, DirectCast(bytes.Clone(), Byte())))
                    tmp.WriteAllBytes(corrupt)

                    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                        Dim test As var = New Dictionary(Of Integer, String)()
                        log.ReplayLog(test)
                        Assert.AreEqual(0, test.Count)
                    End Using
                    Assert.IsFalse(File.Exists(tmp.TempPath))
                Next
                System.Math.Max(System.Threading.Interlocked.Increment(corruptionIx),corruptionIx - 1)
            End While
        End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members
TransactionToken

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : Close Method

Glossary Item Box

Flushes any pending writes and closes the writer.

Syntax

Visual Basic (Declaration)
Public Sub Close()
C#
public void Close()

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
{
    var opts = Options(tmp);
    using (var log = new TransactionLog<int, string>(opts))
    {
        var token = log.BeginTransaction();
        log.AddValue(ref token, 1, "test");
        log.CommitTransaction(ref token);
        token = log.BeginTransaction();
        log.AddValue(ref token, 2, "test");
        log.CommitTransaction(ref token);
        token = log.BeginTransaction();
        log.AddValue(ref token, 3, "test");
        log.CommitTransaction(ref token);
        log.Close();
    }

    using (var log = new TransactionLog<int, string>(opts))
    {
        var test = new Dictionary<int, string>();
        log.ReplayLog(test);
        Assert.AreEqual(3, test.Count);
        for (int i = 1; i <= 3; i++)
            Assert.AreEqual("test", test[i]);
    }
}
VB.NET Copy Code
Using tmp As New TempFile()
    Dim opts As var = Options(tmp)
    Using log As var = New TransactionLog(Of Integer, String)(opts)
        Dim token As var = log.BeginTransaction()
        log.AddValue(token, 1, "test")
        log.CommitTransaction(token)
        token = log.BeginTransaction()
        log.AddValue(token, 2, "test")
        log.CommitTransaction(token)
        token = log.BeginTransaction()
        log.AddValue(token, 3, "test")
        log.CommitTransaction(token)
        log.Close()
    End Using

    Using log As var = New TransactionLog(Of Integer, String)(opts)
        Dim test As var = New Dictionary(Of Integer, String)()
        log.ReplayLog(test)
        Assert.AreEqual(3, test.Count)
        Dim i As Integer = 1
        While i <= 3
            Assert.AreEqual("test", test(i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommitTransaction Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : CommitTransaction Method

token

Glossary Item Box

Commits the provided transaction

Syntax

Visual Basic (Declaration)
Public Sub CommitTransaction( _
   ByRef token As TransactionToken _
)
C#
public void CommitTransaction(
   ref TransactionToken token
)

Parameters

token

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
{
    using (var log = new TransactionLog<int, string>(Options(tmp)))
    {
        var token = log.BeginTransaction();
        log.AddValue(ref token, 1, Guid.NewGuid().ToString());
        log.CommitTransaction(ref token);
        var test = new Dictionary<int, string>();
        long offset = 0;
        log.ReplayLog(test, ref offset);
        Assert.AreEqual(1, test.Count);
    }
    byte[] bytes = tmp.ReadAllBytes();

    var TestVariants =
        new Converter<KeyValuePair<int, byte[]>, byte[]>[]
            {
                kv => { kv.Value[kv.Key] ^= 0xff; return kv.Value; },
                kv => { kv.Value[kv.Key] = 0xff; return kv.Value; },
                kv => { byte[] b = kv.Value; Array.Resize(ref b, kv.Key); return b; },
            };

    for (int corruptionIx = 0; corruptionIx < bytes.Length; corruptionIx++)
    {
        foreach (var testcase in TestVariants)
        {
            byte[] corrupt = testcase(new KeyValuePair<int, byte[]>(corruptionIx, (byte[]) bytes.Clone()));
            tmp.WriteAllBytes(corrupt);

            using (var log = new TransactionLog<int, string>(Options(tmp)))
            {
                var test = new Dictionary<int, string>();
                log.ReplayLog(test);
                Assert.AreEqual(0, test.Count);
            }
            Assert.IsFalse(File.Exists(tmp.TempPath));
        }
    }
}
VB.NET Copy Code
Using tmp As New TempFile()
            Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                Dim token As var = log.BeginTransaction()
                log.AddValue(token, 1, Guid.NewGuid().ToString())
                log.CommitTransaction(token)
                Dim test As var = New Dictionary(Of Integer, String)()
                Dim offset As Long = 0
                log.ReplayLog(test, offset)
                Assert.AreEqual(1, test.Count)
            End Using
            Dim bytes As Byte() = tmp.ReadAllBytes()

            Dim TestVariants As var = New Converter(Of KeyValuePair(Of Integer, Byte()), Byte())() {Function(kv)
            kv.Value(kv.Key) = kv.Value(kv.Key) Xor &Hff
            Return kv.Value

End Function, Function(kv)
            kv.Value(kv.Key) = &Hff
            Return kv.Value

End Function, Function(kv)
            Dim b As Byte() = kv.Value
            Array.Resize(b, kv.Key)
            Return b

End Function}

            Dim corruptionIx As Integer = 0
            While corruptionIx < bytes.Length
                For Each testcase As var In TestVariants
                    Dim corrupt As Byte() = testcase(New KeyValuePair(Of Integer, Byte())(corruptionIx, DirectCast(bytes.Clone(), Byte())))
                    tmp.WriteAllBytes(corrupt)

                    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                        Dim test As var = New Dictionary(Of Integer, String)()
                        log.ReplayLog(test)
                        Assert.AreEqual(0, test.Count)
                    End Using
                    Assert.IsFalse(File.Exists(tmp.TempPath))
                Next
                System.Math.Max(System.Threading.Interlocked.Increment(corruptionIx),corruptionIx - 1)
            End While
        End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members
TransactionToken

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MergeLog Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : MergeLog Method

keyComparer
existing

Glossary Item Box

Merges the contents of the log with an existing ordered key/value pair collection.

Syntax

Visual Basic (Declaration)
Public Function MergeLog( _
   ByVal keyComparer As IComparer(Of TKey), _
   ByVal existing As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public IEnumerable<KeyValuePair<TKey,TValue>> MergeLog(
   IComparer<TKey> keyComparer,
   IEnumerable<KeyValuePair<TKey,TValue>> existing
)

Parameters

keyComparer
existing

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RemoveValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : RemoveValue Method

token
key

Glossary Item Box

The provided key/value pair was removed in the provided transaction

Syntax

Visual Basic (Declaration)
Public Sub RemoveValue( _
   ByRef token As TransactionToken, _
   ByVal key As TKey _
)
C#
public void RemoveValue(
   ref TransactionToken token,
   TKey key
)

Parameters

token
key

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
using (var log = new TransactionLog<int, string>(Options(tmp)))
{
    var token = log.BeginTransaction();
    log.RemoveValue(ref token, 1);
    log.CommitTransaction(ref token);

    var test = new Dictionary<int, string>();
    test.Add(1, null);
    log.ReplayLog(test);

    Assert.AreEqual(0, test.Count);
}
VB.NET Copy Code
Using tmp As New TempFile()
    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
        Dim token As var = log.BeginTransaction()
        log.RemoveValue(token, 1)
        log.CommitTransaction(token)

        Dim test As var = New Dictionary(Of Integer, String)()
        test.Add(1, Nothing)
        log.ReplayLog(test)

        Assert.AreEqual(0, test.Count)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members
TransactionToken

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplayLog Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : ReplayLog Method

Glossary Item Box

Replay the entire log file to the provided dictionary interface

Overload List

Overload | Description
ReplayLog(IDictionary<TKey,TValue>) | Replay the entire log file to the provided dictionary interface
ReplayLog(IDictionary<TKey,TValue>,Int64) | Replay the log file from the position provided and output the new log position

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplayLog(IDictionary<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class > ReplayLog Method : ReplayLog(IDictionary<TKey,TValue>) Method

target

Glossary Item Box

Replay the entire log file to the provided dictionary interface

Syntax

Visual Basic (Declaration)
Public Overloads Sub ReplayLog( _
   ByVal target As IDictionary(Of TKey,TValue) _
)
C#
public void ReplayLog(
   IDictionary<TKey,TValue> target
)

Parameters

target

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
{
    using (var log = new TransactionLog<int, string>(Options(tmp)))
    {
        var token = log.BeginTransaction();
        log.AddValue(ref token, 1, Guid.NewGuid().ToString());
        log.CommitTransaction(ref token);
        var test = new Dictionary<int, string>();
        long offset = 0;
        log.ReplayLog(test, ref offset);
        Assert.AreEqual(1, test.Count);
    }
    byte[] bytes = tmp.ReadAllBytes();

    var TestVariants =
        new Converter<KeyValuePair<int, byte[]>, byte[]>[]
            {
                kv => { kv.Value[kv.Key] ^= 0xff; return kv.Value; },
                kv => { kv.Value[kv.Key] = 0xff; return kv.Value; },
                kv => { byte[] b = kv.Value; Array.Resize(ref b, kv.Key); return b; },
            };

    for (int corruptionIx = 0; corruptionIx < bytes.Length; corruptionIx++)
    {
        foreach (var testcase in TestVariants)
        {
            byte[] corrupt = testcase(new KeyValuePair<int, byte[]>(corruptionIx, (byte[]) bytes.Clone()));
            tmp.WriteAllBytes(corrupt);

            using (var log = new TransactionLog<int, string>(Options(tmp)))
            {
                var test = new Dictionary<int, string>();
                log.ReplayLog(test);
                Assert.AreEqual(0, test.Count);
            }
            Assert.IsFalse(File.Exists(tmp.TempPath));
        }
    }
}
VB.NET Copy Code
Using tmp As New TempFile()
            Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                Dim token As var = log.BeginTransaction()
                log.AddValue(token, 1, Guid.NewGuid().ToString())
                log.CommitTransaction(token)
                Dim test As var = New Dictionary(Of Integer, String)()
                Dim offset As Long = 0
                log.ReplayLog(test, offset)
                Assert.AreEqual(1, test.Count)
            End Using
            Dim bytes As Byte() = tmp.ReadAllBytes()

            Dim TestVariants As var = New Converter(Of KeyValuePair(Of Integer, Byte()), Byte())() {Function(kv)
            kv.Value(kv.Key) = kv.Value(kv.Key) Xor &Hff
            Return kv.Value

End Function, Function(kv)
            kv.Value(kv.Key) = &Hff
            Return kv.Value

End Function, Function(kv)
            Dim b As Byte() = kv.Value
            Array.Resize(b, kv.Key)
            Return b

End Function}

            Dim corruptionIx As Integer = 0
            While corruptionIx < bytes.Length
                For Each testcase As var In TestVariants
                    Dim corrupt As Byte() = testcase(New KeyValuePair(Of Integer, Byte())(corruptionIx, DirectCast(bytes.Clone(), Byte())))
                    tmp.WriteAllBytes(corrupt)

                    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                        Dim test As var = New Dictionary(Of Integer, String)()
                        log.ReplayLog(test)
                        Assert.AreEqual(0, test.Count)
                    End Using
                    Assert.IsFalse(File.Exists(tmp.TempPath))
                Next
                System.Math.Max(System.Threading.Interlocked.Increment(corruptionIx),corruptionIx - 1)
            End While
        End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members
Overload List

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplayLog(IDictionary<TKey,TValue>,Int64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class > ReplayLog Method : ReplayLog(IDictionary<TKey,TValue>,Int64) Method

target
position

Glossary Item Box

Replay the log file from the position provided and output the new log position

Syntax

Visual Basic (Declaration)
Public Overloads Sub ReplayLog( _
   ByVal target As IDictionary(Of TKey,TValue), _
   ByRef position As Long _
)
C#
public void ReplayLog(
   IDictionary<TKey,TValue> target,
   ref long position
)

Parameters

target
position

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
{
    using (var log = new TransactionLog<int, string>(Options(tmp)))
    {
        var token = log.BeginTransaction();
        log.AddValue(ref token, 1, Guid.NewGuid().ToString());
        log.CommitTransaction(ref token);
        var test = new Dictionary<int, string>();
        long offset = 0;
        log.ReplayLog(test, ref offset);
        Assert.AreEqual(1, test.Count);
    }
    byte[] bytes = tmp.ReadAllBytes();

    var TestVariants =
        new Converter<KeyValuePair<int, byte[]>, byte[]>[]
            {
                kv => { kv.Value[kv.Key] ^= 0xff; return kv.Value; },
                kv => { kv.Value[kv.Key] = 0xff; return kv.Value; },
                kv => { byte[] b = kv.Value; Array.Resize(ref b, kv.Key); return b; },
            };

    for (int corruptionIx = 0; corruptionIx < bytes.Length; corruptionIx++)
    {
        foreach (var testcase in TestVariants)
        {
            byte[] corrupt = testcase(new KeyValuePair<int, byte[]>(corruptionIx, (byte[]) bytes.Clone()));
            tmp.WriteAllBytes(corrupt);

            using (var log = new TransactionLog<int, string>(Options(tmp)))
            {
                var test = new Dictionary<int, string>();
                log.ReplayLog(test);
                Assert.AreEqual(0, test.Count);
            }
            Assert.IsFalse(File.Exists(tmp.TempPath));
        }
    }
}
VB.NET Copy Code
Using tmp As New TempFile()
            Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                Dim token As var = log.BeginTransaction()
                log.AddValue(token, 1, Guid.NewGuid().ToString())
                log.CommitTransaction(token)
                Dim test As var = New Dictionary(Of Integer, String)()
                Dim offset As Long = 0
                log.ReplayLog(test, offset)
                Assert.AreEqual(1, test.Count)
            End Using
            Dim bytes As Byte() = tmp.ReadAllBytes()

            Dim TestVariants As var = New Converter(Of KeyValuePair(Of Integer, Byte()), Byte())() {Function(kv)
            kv.Value(kv.Key) = kv.Value(kv.Key) Xor &Hff
            Return kv.Value

End Function, Function(kv)
            kv.Value(kv.Key) = &Hff
            Return kv.Value

End Function, Function(kv)
            Dim b As Byte() = kv.Value
            Array.Resize(b, kv.Key)
            Return b

End Function}

            Dim corruptionIx As Integer = 0
            While corruptionIx < bytes.Length
                For Each testcase As var In TestVariants
                    Dim corrupt As Byte() = testcase(New KeyValuePair(Of Integer, Byte())(corruptionIx, DirectCast(bytes.Clone(), Byte())))
                    tmp.WriteAllBytes(corrupt)

                    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
                        Dim test As var = New Dictionary(Of Integer, String)()
                        log.ReplayLog(test)
                        Assert.AreEqual(0, test.Count)
                    End Using
                    Assert.IsFalse(File.Exists(tmp.TempPath))
                Next
                System.Math.Max(System.Threading.Interlocked.Increment(corruptionIx),corruptionIx - 1)
            End While
        End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members
Overload List

Used By

TransactionLog.ReplayLog(IDictionary)

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RollbackTransaction Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : RollbackTransaction Method

token

Glossary Item Box

Abandons the provided transaction

Syntax

Visual Basic (Declaration)
Public Sub RollbackTransaction( _
   ByRef token As TransactionToken _
)
C#
public void RollbackTransaction(
   ref TransactionToken token
)

Parameters

token

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
using (var log = new TransactionLog<int, string>(Options(tmp)))
{
    var token = log.BeginTransaction();
    log.AddValue(ref token, 1, "test");
    log.RollbackTransaction(ref token);

    var test = new Dictionary<int, string>();
    log.ReplayLog(test);
    Assert.AreEqual(0, test.Count);
}
VB.NET Copy Code
Using tmp As New TempFile()
    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
        Dim token As var = log.BeginTransaction()
        log.AddValue(token, 1, "test")
        log.RollbackTransaction(token)

        Dim test As var = New Dictionary(Of Integer, String)()
        log.ReplayLog(test)
        Assert.AreEqual(0, test.Count)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members
TransactionToken

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TruncateLog() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : TruncateLog() Method

Glossary Item Box

Truncate the log and remove all existing entries

Syntax

Visual Basic (Declaration)
Public Sub TruncateLog()
C#
public void TruncateLog()

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
using (var log = new TransactionLog<int, string>(Options(tmp)))
{
    var token = log.BeginTransaction();
    log.AddValue(ref token, 1, "test");
    log.CommitTransaction(ref token);

    var test = new Dictionary<int, string>();
    log.ReplayLog(test);

    Assert.AreEqual(1, test.Count);
    Assert.IsTrue(test.ContainsKey(1));
    Assert.AreEqual("test", test[1]);

    log.TruncateLog();
    test.Clear();
    log.ReplayLog(test);

    Assert.AreEqual(0, test.Count);
}
VB.NET Copy Code
Using tmp As New TempFile()
    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
        Dim token As var = log.BeginTransaction()
        log.AddValue(token, 1, "test")
        log.CommitTransaction(token)

        Dim test As var = New Dictionary(Of Integer, String)()
        log.ReplayLog(test)

        Assert.AreEqual(1, test.Count)
        Assert.IsTrue(test.ContainsKey(1))
        Assert.AreEqual("test", test(1))

        log.TruncateLog()
        test.Clear()
        log.ReplayLog(test)

        Assert.AreEqual(0, test.Count)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UpdateValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : UpdateValue Method

token
key
value

Glossary Item Box

The provided key/value pair was updated in the provided transaction

Syntax

Visual Basic (Declaration)
Public Sub UpdateValue( _
   ByRef token As TransactionToken, _
   ByVal key As TKey, _
   ByVal value As TValue _
)
C#
public void UpdateValue(
   ref TransactionToken token,
   TKey key,
   TValue value
)

Parameters

token
key
value

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile tmp = new TempFile())
using (var log = new TransactionLog<int, string>(Options(tmp)))
{
    var token = log.BeginTransaction();
    log.UpdateValue(ref token, 1, "test");
    log.CommitTransaction(ref token);

    var test = new Dictionary<int, string>();
    test.Add(1, null);
    log.ReplayLog(test);

    Assert.AreEqual(1, test.Count);
    Assert.IsTrue(test.ContainsKey(1));
    Assert.AreEqual("test", test[1]);
}
VB.NET Copy Code
Using tmp As New TempFile()
    Using log As var = New TransactionLog(Of Integer, String)(Options(tmp))
        Dim token As var = log.BeginTransaction()
        log.UpdateValue(token, 1, "test")
        log.CommitTransaction(token)

        Dim test As var = New Dictionary(Of Integer, String)()
        test.Add(1, Nothing)
        log.ReplayLog(test)

        Assert.AreEqual(1, test.Count)
        Assert.IsTrue(test.ContainsKey(1))
        Assert.AreEqual("test", test(1))
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members
TransactionToken

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TransactionLog<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionLog<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see TransactionLog<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | FileName | Returns the file name of the current transaction log file
Public Property | Size | Returns the current size of the log file in bytes
Top

See Also

Reference

TransactionLog<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileName Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : FileName Property

Glossary Item Box

Returns the file name of the current transaction log file

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileName As String
C#
public string FileName {get;}

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Size Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : Size Property

Glossary Item Box

Returns the current size of the log file in bytes

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Size As Long
C#
public long Size {get;}

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    temp.Delete();
    var opt = new TransactionLogOptions<int, string>(temp.TempPath,
                                                  PrimitiveSerializer.Int32,
                                                  PrimitiveSerializer.String);
    //FileName
    Assert.AreEqual(temp.TempPath, opt.FileName);
    //Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32));
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.String));
    //FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough | FileOptions.Asynchronous, opt.FileOptions |= FileOptions.Asynchronous);
    //Read Only
    Assert.AreEqual(false, opt.ReadOnly);
    Assert.AreEqual(true, opt.ReadOnly = true);
    //File Buffer
    Assert.AreEqual(8, opt.FileBuffer);
    Assert.AreEqual(0x40000, opt.FileBuffer = 0x40000);
    //Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()));

    using(TransactionLog<int, string> log = new TransactionLog<int,string>(opt))
        Assert.AreEqual(0, log.Size);
}
VB.NET Copy Code
Using temp As New TempFile()
    temp.Delete()
    Dim opt As var = New TransactionLogOptions(Of Integer, String)(temp.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String])
    'FileName
    Assert.AreEqual(temp.TempPath, opt.FileName)
    'Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32))
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.[String]))
    'FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough Or FileOptions.Asynchronous, opt.FileOptions = opt.FileOptions Or FileOptions.Asynchronous)
    'Read Only
    Assert.AreEqual(False, opt.[ReadOnly])
    Assert.AreEqual(True, opt.[ReadOnly] = True)
    'File Buffer
    Assert.AreEqual(8, opt.FileBuffer)
    Assert.AreEqual(&H40000, opt.FileBuffer = &H40000)
    'Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()))

    Using log As New TransactionLog(Of Integer, String)(opt)
        Assert.AreEqual(0, log.Size)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members

Used By

TransactionLog.Close()

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
TransactionLogOptions<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionLogOptions<TKey,TValue> Class

Glossary Item Box

Options used to initialize a TransactionLog

Syntax

Visual Basic (Declaration)
Public Class TransactionLogOptions
    (Of TKey,TValue)
C#
public class TransactionLogOptions<TKey,TValue>

Type Parameters

TKey
TValue

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
//Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
//Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
//Logged 2,398,000,000 bytes in: 00:00:36.7621027

string newpath = Path.Combine(@"C:\Temp\LogTest\", Guid.NewGuid() + ".tmp");
using (TempFile tmp = TempFile.Attach(newpath))
{
    byte[] bytes;
    DateTime start;
    //bytes = new byte[128];
    //new Random().NextBytes(bytes);

    //start = DateTime.UtcNow;
    //using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    //{
    //    for (int i = 0; i <= 16777216; i++)
    //        io.Write(bytes, 0, 128);
    //}
    //Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    //tmp.Delete();

    var options = new TransactionLogOptions<Guid, byte[]>(
        tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes)
        {
            FileBuffer = ushort.MaxValue,
            FileOptions = FileOptions.None | FileOptions.SequentialScan,
        };

    Guid[] ids = new Guid[1000000];
    for (int i = 0; i < ids.Length; i++)
        ids[i] = Guid.NewGuid();

    bytes = new byte[100];
    new Random().NextBytes(bytes);

    start = DateTime.UtcNow;

    using (var log = new TransactionLog<Guid, byte[]>(options))
    {
        foreach(Guid id in ids)
        {
            var token = log.BeginTransaction();
            for (int i = 0; i < 20; i++)
                log.AddValue(ref token, id, bytes);
            log.CommitTransaction(ref token);
        }
    }

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
}
VB.NET Copy Code
'Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
'Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
'Logged 2,398,000,000 bytes in: 00:00:36.7621027

Dim newpath As String = Path.Combine("C:\Temp\LogTest\", Guid.NewGuid() + ".tmp")
Using tmp As TempFile = TempFile.Attach(newpath)
    Dim bytes As Byte()
    Dim start As DateTime
    'bytes = new byte[128];
    'new Random().NextBytes(bytes);

    'start = DateTime.UtcNow;
    'using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    '{
    '    for (int i = 0; i <= 16777216; i++)
    '        io.Write(bytes, 0, 128);
    '}
    'Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    'tmp.Delete();

    Dim options As var = New TransactionLogOptions(Of Guid, Byte())(tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes) With { _
        Key .FileBuffer = UShort.MaxValue, _
        Key .FileOptions = FileOptions.None Or FileOptions.SequentialScan _
    }

    Dim ids As Guid() = New Guid(1000000) {}
    Dim i As Integer = 0
    While i < ids.Length
        ids(i) = Guid.NewGuid()
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    bytes = New Byte(100) {}
    New Random().NextBytes(bytes)

    start = DateTime.UtcNow

    Using log As var = New TransactionLog(Of Guid, Byte())(options)
        For Each id As Guid In ids
            Dim token As var = log.BeginTransaction()
            Dim i As Integer = 0
            While i < 20
                log.AddValue(token, id, bytes)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
            log.CommitTransaction(token)
        Next
    End Using

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start)
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.TransactionLogOptions<TKey,TValue>

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TransactionLogOptions<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionLogOptions<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by TransactionLogOptions<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | TransactionLogOptions<TKey,TValue> Constructor | Options used to initialize a TransactionLog
Top

Public Properties

 | Name | Description
Public Property | FileBuffer | The file buffer size, CAUTION: values above 16 bytes may leave data in memory
Public Property | FileName | The file name to read/write the log
Public Property | FileOptions | The file open options for appending to a log, default = WriteThrough
Public Property | KeySerializer | The serializer for the TKey type
Public Property | ReadOnly | Gets or sets if the transaction log is treated as read-only
Public Property | ValueSerializer | The serializer for the TValue type
Top

Public Methods

 | Name | Description
Public Method | Clone | Creates a shallow clone of the instance
Top

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactionLogOptions<TKey,TValue> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLogOptions<TKey,TValue> Class : TransactionLogOptions<TKey,TValue> Constructor

fileName
keySerializer
valueSerializer

Glossary Item Box

Options used to initialize a TransactionLog

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal fileName As String, _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue) _
)
C#
public TransactionLogOptions<TKey,TValue>(
   string fileName,
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer
)

Parameters

fileName
keySerializer
valueSerializer

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
//Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
//Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
//Logged 2,398,000,000 bytes in: 00:00:36.7621027

string newpath = Path.Combine(@"C:\Temp\LogTest\", Guid.NewGuid() + ".tmp");
using (TempFile tmp = TempFile.Attach(newpath))
{
    byte[] bytes;
    DateTime start;
    //bytes = new byte[128];
    //new Random().NextBytes(bytes);

    //start = DateTime.UtcNow;
    //using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    //{
    //    for (int i = 0; i <= 16777216; i++)
    //        io.Write(bytes, 0, 128);
    //}
    //Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    //tmp.Delete();

    var options = new TransactionLogOptions<Guid, byte[]>(
        tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes)
        {
            FileBuffer = ushort.MaxValue,
            FileOptions = FileOptions.None | FileOptions.SequentialScan,
        };

    Guid[] ids = new Guid[1000000];
    for (int i = 0; i < ids.Length; i++)
        ids[i] = Guid.NewGuid();

    bytes = new byte[100];
    new Random().NextBytes(bytes);

    start = DateTime.UtcNow;

    using (var log = new TransactionLog<Guid, byte[]>(options))
    {
        foreach(Guid id in ids)
        {
            var token = log.BeginTransaction();
            for (int i = 0; i < 20; i++)
                log.AddValue(ref token, id, bytes);
            log.CommitTransaction(ref token);
        }
    }

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
}
VB.NET Copy Code
'Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
'Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
'Logged 2,398,000,000 bytes in: 00:00:36.7621027

Dim newpath As String = Path.Combine("C:\Temp\LogTest\", Guid.NewGuid() + ".tmp")
Using tmp As TempFile = TempFile.Attach(newpath)
    Dim bytes As Byte()
    Dim start As DateTime
    'bytes = new byte[128];
    'new Random().NextBytes(bytes);

    'start = DateTime.UtcNow;
    'using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    '{
    '    for (int i = 0; i <= 16777216; i++)
    '        io.Write(bytes, 0, 128);
    '}
    'Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    'tmp.Delete();

    Dim options As var = New TransactionLogOptions(Of Guid, Byte())(tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes) With { _
        Key .FileBuffer = UShort.MaxValue, _
        Key .FileOptions = FileOptions.None Or FileOptions.SequentialScan _
    }

    Dim ids As Guid() = New Guid(1000000) {}
    Dim i As Integer = 0
    While i < ids.Length
        ids(i) = Guid.NewGuid()
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    bytes = New Byte(100) {}
    New Random().NextBytes(bytes)

    start = DateTime.UtcNow

    Using log As var = New TransactionLog(Of Guid, Byte())(options)
        For Each id As Guid In ids
            Dim token As var = log.BeginTransaction()
            Dim i As Integer = 0
            While i < 20
                log.AddValue(token, id, bytes)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
            log.CommitTransaction(token)
        Next
    End Using

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start)
End Using

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
TransactionLogOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TransactionLogOptions<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionLogOptions<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see TransactionLogOptions<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Clone | Creates a shallow clone of the instance
Top

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLogOptions<TKey,TValue> Class : Clone Method

Glossary Item Box

Creates a shallow clone of the instance

Syntax

Visual Basic (Declaration)
Public Function Clone() As TransactionLogOptions(Of TKey,TValue)
C#
public TransactionLogOptions<TKey,TValue> Clone()

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    temp.Delete();
    var opt = new TransactionLogOptions<int, string>(temp.TempPath,
                                                  PrimitiveSerializer.Int32,
                                                  PrimitiveSerializer.String);
    //FileName
    Assert.AreEqual(temp.TempPath, opt.FileName);
    //Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32));
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.String));
    //FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough | FileOptions.Asynchronous, opt.FileOptions |= FileOptions.Asynchronous);
    //Read Only
    Assert.AreEqual(false, opt.ReadOnly);
    Assert.AreEqual(true, opt.ReadOnly = true);
    //File Buffer
    Assert.AreEqual(8, opt.FileBuffer);
    Assert.AreEqual(0x40000, opt.FileBuffer = 0x40000);
    //Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()));

    using(TransactionLog<int, string> log = new TransactionLog<int,string>(opt))
        Assert.AreEqual(0, log.Size);
}
VB.NET Copy Code
Using temp As New TempFile()
    temp.Delete()
    Dim opt As var = New TransactionLogOptions(Of Integer, String)(temp.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String])
    'FileName
    Assert.AreEqual(temp.TempPath, opt.FileName)
    'Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32))
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.[String]))
    'FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough Or FileOptions.Asynchronous, opt.FileOptions = opt.FileOptions Or FileOptions.Asynchronous)
    'Read Only
    Assert.AreEqual(False, opt.[ReadOnly])
    Assert.AreEqual(True, opt.[ReadOnly] = True)
    'File Buffer
    Assert.AreEqual(8, opt.FileBuffer)
    Assert.AreEqual(&H40000, opt.FileBuffer = &H40000)
    'Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()))

    Using log As New TransactionLog(Of Integer, String)(opt)
        Assert.AreEqual(0, log.Size)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
TransactionLogOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TransactionLogOptions<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionLogOptions<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see TransactionLogOptions<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | FileBuffer | The file buffer size, CAUTION: values above 16 bytes may leave data in memory
Public Property | FileName | The file name to read/write the log
Public Property | FileOptions | The file open options for appending to a log, default = WriteThrough
Public Property | KeySerializer | The serializer for the TKey type
Public Property | ReadOnly | Gets or sets if the transaction log is treated as read-only
Public Property | ValueSerializer | The serializer for the TValue type
Top

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileBuffer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLogOptions<TKey,TValue> Class : FileBuffer Property

Glossary Item Box

The file buffer size, CAUTION: values above 16 bytes may leave data in memory

Syntax

Visual Basic (Declaration)
Public Property FileBuffer As Integer
C#
public int FileBuffer {get; set;}

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
//Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
//Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
//Logged 2,398,000,000 bytes in: 00:00:36.7621027

string newpath = Path.Combine(@"C:\Temp\LogTest\", Guid.NewGuid() + ".tmp");
using (TempFile tmp = TempFile.Attach(newpath))
{
    byte[] bytes;
    DateTime start;
    //bytes = new byte[128];
    //new Random().NextBytes(bytes);

    //start = DateTime.UtcNow;
    //using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    //{
    //    for (int i = 0; i <= 16777216; i++)
    //        io.Write(bytes, 0, 128);
    //}
    //Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    //tmp.Delete();

    var options = new TransactionLogOptions<Guid, byte[]>(
        tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes)
        {
            FileBuffer = ushort.MaxValue,
            FileOptions = FileOptions.None | FileOptions.SequentialScan,
        };

    Guid[] ids = new Guid[1000000];
    for (int i = 0; i < ids.Length; i++)
        ids[i] = Guid.NewGuid();

    bytes = new byte[100];
    new Random().NextBytes(bytes);

    start = DateTime.UtcNow;

    using (var log = new TransactionLog<Guid, byte[]>(options))
    {
        foreach(Guid id in ids)
        {
            var token = log.BeginTransaction();
            for (int i = 0; i < 20; i++)
                log.AddValue(ref token, id, bytes);
            log.CommitTransaction(ref token);
        }
    }

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
}
VB.NET Copy Code
'Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
'Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
'Logged 2,398,000,000 bytes in: 00:00:36.7621027

Dim newpath As String = Path.Combine("C:\Temp\LogTest\", Guid.NewGuid() + ".tmp")
Using tmp As TempFile = TempFile.Attach(newpath)
    Dim bytes As Byte()
    Dim start As DateTime
    'bytes = new byte[128];
    'new Random().NextBytes(bytes);

    'start = DateTime.UtcNow;
    'using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    '{
    '    for (int i = 0; i <= 16777216; i++)
    '        io.Write(bytes, 0, 128);
    '}
    'Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    'tmp.Delete();

    Dim options As var = New TransactionLogOptions(Of Guid, Byte())(tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes) With { _
        Key .FileBuffer = UShort.MaxValue, _
        Key .FileOptions = FileOptions.None Or FileOptions.SequentialScan _
    }

    Dim ids As Guid() = New Guid(1000000) {}
    Dim i As Integer = 0
    While i < ids.Length
        ids(i) = Guid.NewGuid()
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    bytes = New Byte(100) {}
    New Random().NextBytes(bytes)

    start = DateTime.UtcNow

    Using log As var = New TransactionLog(Of Guid, Byte())(options)
        For Each id As Guid In ids
            Dim token As var = log.BeginTransaction()
            Dim i As Integer = 0
            While i < 20
                log.AddValue(token, id, bytes)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
            log.CommitTransaction(token)
        Next
    End Using

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start)
End Using

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
TransactionLogOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLogOptions<TKey,TValue> Class : FileName Property

Glossary Item Box

The file name to read/write the log

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileName As String
C#
public string FileName {get;}

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    temp.Delete();
    var opt = new TransactionLogOptions<int, string>(temp.TempPath,
                                                  PrimitiveSerializer.Int32,
                                                  PrimitiveSerializer.String);
    //FileName
    Assert.AreEqual(temp.TempPath, opt.FileName);
    //Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32));
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.String));
    //FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough | FileOptions.Asynchronous, opt.FileOptions |= FileOptions.Asynchronous);
    //Read Only
    Assert.AreEqual(false, opt.ReadOnly);
    Assert.AreEqual(true, opt.ReadOnly = true);
    //File Buffer
    Assert.AreEqual(8, opt.FileBuffer);
    Assert.AreEqual(0x40000, opt.FileBuffer = 0x40000);
    //Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()));

    using(TransactionLog<int, string> log = new TransactionLog<int,string>(opt))
        Assert.AreEqual(0, log.Size);
}
VB.NET Copy Code
Using temp As New TempFile()
    temp.Delete()
    Dim opt As var = New TransactionLogOptions(Of Integer, String)(temp.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String])
    'FileName
    Assert.AreEqual(temp.TempPath, opt.FileName)
    'Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32))
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.[String]))
    'FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough Or FileOptions.Asynchronous, opt.FileOptions = opt.FileOptions Or FileOptions.Asynchronous)
    'Read Only
    Assert.AreEqual(False, opt.[ReadOnly])
    Assert.AreEqual(True, opt.[ReadOnly] = True)
    'File Buffer
    Assert.AreEqual(8, opt.FileBuffer)
    Assert.AreEqual(&H40000, opt.FileBuffer = &H40000)
    'Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()))

    Using log As New TransactionLog(Of Integer, String)(opt)
        Assert.AreEqual(0, log.Size)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
TransactionLogOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs

Used By

TransactionLog.Close()


%%PageItemTitle%%

[image]
CSharpTest.Net
FileOptions Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLogOptions<TKey,TValue> Class : FileOptions Property

Glossary Item Box

The file open options for appending to a log, default = WriteThrough

Syntax

Visual Basic (Declaration)
Public Property FileOptions As FileOptions
C#
public FileOptions FileOptions {get; set;}

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
//Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
//Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
//Logged 2,398,000,000 bytes in: 00:00:36.7621027

string newpath = Path.Combine(@"C:\Temp\LogTest\", Guid.NewGuid() + ".tmp");
using (TempFile tmp = TempFile.Attach(newpath))
{
    byte[] bytes;
    DateTime start;
    //bytes = new byte[128];
    //new Random().NextBytes(bytes);

    //start = DateTime.UtcNow;
    //using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    //{
    //    for (int i = 0; i <= 16777216; i++)
    //        io.Write(bytes, 0, 128);
    //}
    //Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    //tmp.Delete();

    var options = new TransactionLogOptions<Guid, byte[]>(
        tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes)
        {
            FileBuffer = ushort.MaxValue,
            FileOptions = FileOptions.None | FileOptions.SequentialScan,
        };

    Guid[] ids = new Guid[1000000];
    for (int i = 0; i < ids.Length; i++)
        ids[i] = Guid.NewGuid();

    bytes = new byte[100];
    new Random().NextBytes(bytes);

    start = DateTime.UtcNow;

    using (var log = new TransactionLog<Guid, byte[]>(options))
    {
        foreach(Guid id in ids)
        {
            var token = log.BeginTransaction();
            for (int i = 0; i < 20; i++)
                log.AddValue(ref token, id, bytes);
            log.CommitTransaction(ref token);
        }
    }

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
}
VB.NET Copy Code
'Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
'Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
'Logged 2,398,000,000 bytes in: 00:00:36.7621027

Dim newpath As String = Path.Combine("C:\Temp\LogTest\", Guid.NewGuid() + ".tmp")
Using tmp As TempFile = TempFile.Attach(newpath)
    Dim bytes As Byte()
    Dim start As DateTime
    'bytes = new byte[128];
    'new Random().NextBytes(bytes);

    'start = DateTime.UtcNow;
    'using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    '{
    '    for (int i = 0; i <= 16777216; i++)
    '        io.Write(bytes, 0, 128);
    '}
    'Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    'tmp.Delete();

    Dim options As var = New TransactionLogOptions(Of Guid, Byte())(tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes) With { _
        Key .FileBuffer = UShort.MaxValue, _
        Key .FileOptions = FileOptions.None Or FileOptions.SequentialScan _
    }

    Dim ids As Guid() = New Guid(1000000) {}
    Dim i As Integer = 0
    While i < ids.Length
        ids(i) = Guid.NewGuid()
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    bytes = New Byte(100) {}
    New Random().NextBytes(bytes)

    start = DateTime.UtcNow

    Using log As var = New TransactionLog(Of Guid, Byte())(options)
        For Each id As Guid In ids
            Dim token As var = log.BeginTransaction()
            Dim i As Integer = 0
            While i < 20
                log.AddValue(token, id, bytes)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
            log.CommitTransaction(token)
        Next
    End Using

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start)
End Using

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
TransactionLogOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
KeySerializer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLogOptions<TKey,TValue> Class : KeySerializer Property

Glossary Item Box

The serializer for the TKey type

Syntax

Visual Basic (Declaration)
Public ReadOnly Property KeySerializer As ISerializer(Of TKey)
C#
public ISerializer<TKey> KeySerializer {get;}

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    temp.Delete();
    var opt = new TransactionLogOptions<int, string>(temp.TempPath,
                                                  PrimitiveSerializer.Int32,
                                                  PrimitiveSerializer.String);
    //FileName
    Assert.AreEqual(temp.TempPath, opt.FileName);
    //Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32));
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.String));
    //FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough | FileOptions.Asynchronous, opt.FileOptions |= FileOptions.Asynchronous);
    //Read Only
    Assert.AreEqual(false, opt.ReadOnly);
    Assert.AreEqual(true, opt.ReadOnly = true);
    //File Buffer
    Assert.AreEqual(8, opt.FileBuffer);
    Assert.AreEqual(0x40000, opt.FileBuffer = 0x40000);
    //Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()));

    using(TransactionLog<int, string> log = new TransactionLog<int,string>(opt))
        Assert.AreEqual(0, log.Size);
}
VB.NET Copy Code
Using temp As New TempFile()
    temp.Delete()
    Dim opt As var = New TransactionLogOptions(Of Integer, String)(temp.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String])
    'FileName
    Assert.AreEqual(temp.TempPath, opt.FileName)
    'Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32))
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.[String]))
    'FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough Or FileOptions.Asynchronous, opt.FileOptions = opt.FileOptions Or FileOptions.Asynchronous)
    'Read Only
    Assert.AreEqual(False, opt.[ReadOnly])
    Assert.AreEqual(True, opt.[ReadOnly] = True)
    'File Buffer
    Assert.AreEqual(8, opt.FileBuffer)
    Assert.AreEqual(&H40000, opt.FileBuffer = &H40000)
    'Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()))

    Using log As New TransactionLog(Of Integer, String)(opt)
        Assert.AreEqual(0, log.Size)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
TransactionLogOptions<TKey,TValue> Members
ISerializer

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadOnly Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLogOptions<TKey,TValue> Class : ReadOnly Property

Glossary Item Box

Gets or sets if the transaction log is treated as read-only

Syntax

Visual Basic (Declaration)
Public Property ReadOnly As Boolean
C#
public bool ReadOnly {get; set;}

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    temp.Delete();
    var opt = new TransactionLogOptions<int, string>(temp.TempPath,
                                                  PrimitiveSerializer.Int32,
                                                  PrimitiveSerializer.String);
    //FileName
    Assert.AreEqual(temp.TempPath, opt.FileName);
    //Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32));
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.String));
    //FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough | FileOptions.Asynchronous, opt.FileOptions |= FileOptions.Asynchronous);
    //Read Only
    Assert.AreEqual(false, opt.ReadOnly);
    Assert.AreEqual(true, opt.ReadOnly = true);
    //File Buffer
    Assert.AreEqual(8, opt.FileBuffer);
    Assert.AreEqual(0x40000, opt.FileBuffer = 0x40000);
    //Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()));

    using(TransactionLog<int, string> log = new TransactionLog<int,string>(opt))
        Assert.AreEqual(0, log.Size);
}
VB.NET Copy Code
Using temp As New TempFile()
    temp.Delete()
    Dim opt As var = New TransactionLogOptions(Of Integer, String)(temp.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String])
    'FileName
    Assert.AreEqual(temp.TempPath, opt.FileName)
    'Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32))
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.[String]))
    'FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough Or FileOptions.Asynchronous, opt.FileOptions = opt.FileOptions Or FileOptions.Asynchronous)
    'Read Only
    Assert.AreEqual(False, opt.[ReadOnly])
    Assert.AreEqual(True, opt.[ReadOnly] = True)
    'File Buffer
    Assert.AreEqual(8, opt.FileBuffer)
    Assert.AreEqual(&H40000, opt.FileBuffer = &H40000)
    'Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()))

    Using log As New TransactionLog(Of Integer, String)(opt)
        Assert.AreEqual(0, log.Size)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
TransactionLogOptions<TKey,TValue> Members

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ValueSerializer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLogOptions<TKey,TValue> Class : ValueSerializer Property

Glossary Item Box

The serializer for the TValue type

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ValueSerializer As ISerializer(Of TValue)
C#
public ISerializer<TValue> ValueSerializer {get;}

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    temp.Delete();
    var opt = new TransactionLogOptions<int, string>(temp.TempPath,
                                                  PrimitiveSerializer.Int32,
                                                  PrimitiveSerializer.String);
    //FileName
    Assert.AreEqual(temp.TempPath, opt.FileName);
    //Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32));
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.String));
    //FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough | FileOptions.Asynchronous, opt.FileOptions |= FileOptions.Asynchronous);
    //Read Only
    Assert.AreEqual(false, opt.ReadOnly);
    Assert.AreEqual(true, opt.ReadOnly = true);
    //File Buffer
    Assert.AreEqual(8, opt.FileBuffer);
    Assert.AreEqual(0x40000, opt.FileBuffer = 0x40000);
    //Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()));

    using(TransactionLog<int, string> log = new TransactionLog<int,string>(opt))
        Assert.AreEqual(0, log.Size);
}
VB.NET Copy Code
Using temp As New TempFile()
    temp.Delete()
    Dim opt As var = New TransactionLogOptions(Of Integer, String)(temp.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String])
    'FileName
    Assert.AreEqual(temp.TempPath, opt.FileName)
    'Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32))
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.[String]))
    'FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough Or FileOptions.Asynchronous, opt.FileOptions = opt.FileOptions Or FileOptions.Asynchronous)
    'Read Only
    Assert.AreEqual(False, opt.[ReadOnly])
    Assert.AreEqual(True, opt.[ReadOnly] = True)
    'File Buffer
    Assert.AreEqual(8, opt.FileBuffer)
    Assert.AreEqual(&H40000, opt.FileBuffer = &H40000)
    'Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()))

    Using log As New TransactionLog(Of Integer, String)(opt)
        Assert.AreEqual(0, log.Size)
    End Using
End Using

Requirements

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

See Also

Reference

TransactionLogOptions<TKey,TValue> Class
TransactionLogOptions<TKey,TValue> Members
ISerializer

Source Code

BPlusTree/Collections/TransactionLog.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BPlusTree.DebugFormat<TKey,TValue> Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : BPlusTree.DebugFormat<TKey,TValue> Enumeration

Glossary Item Box

Print formatting for nodes

Syntax

Visual Basic (Declaration)
Public Enum BPlusTree.DebugFormat
   Inherits System.Enum
C#
public enum BPlusTree.DebugFormat : System.Enum

Members

Member | Description
Compact | Compact single line format
Formatted | Formatted new lines and tabbify, but reduced information
Full | Full information for all nodes

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.BPlusTree`2.DebugFormat<TKey,TValue>

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
BPlusTree.Print(TextWriter,BPlusTree.DebugFormat)

Source Code

BPlusTree/Collections/BPlusTree.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CachePolicy Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : CachePolicy Enumeration

Glossary Item Box

Determines the type of node caching used in the tree

Syntax

Visual Basic (Declaration)
Public Enum CachePolicy
   Inherits System.Enum
C#
public enum CachePolicy : System.Enum

Members

Member | Description
All | Keeps every loaded object in memory.
None | Does not cache, allways loads from storage.
Recent | Keeps a history of objects in memory (see CacheKeepAliveXXX properties)

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.CachePolicy

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
CachePolicy BPlusTreeOptions.CachePolicy


%%PageItemTitle%%

[image]
CSharpTest.Net
CreatePolicy Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : CreatePolicy Enumeration

Glossary Item Box

Determines if the file specified should be created

Syntax

Visual Basic (Declaration)
Public Enum CreatePolicy
   Inherits System.Enum
C#
public enum CreatePolicy : System.Enum

Members

Member | Description
Always | Creates a new file even if one already exists
IfNeeded | Creates a new file only if it does not exist
Never | Does not create a new file

Example

BPlusTree/BPlusTree.Test/TestBPlusTreeOptions.cs

C# Copy Code
ICloneable opt = new BPlusTree<int, int>.Options(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
{
    CreateFile = CreatePolicy.IfNeeded,
    BTreeOrder = 4
};
BPlusTree<int, int>.Options options = (BPlusTree<int, int>.Options)opt.Clone();

Assert.AreEqual(CreatePolicy.IfNeeded, options.CreateFile);
Assert.AreEqual(4, options.MaximumChildNodes);
Assert.AreEqual(4, options.MaximumValueNodes);
VB.NET Copy Code
Dim opt As ICloneable = New BPlusTree(Of Integer, Integer).Options(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32) With { _
    Key .CreateFile = CreatePolicy.IfNeeded, _
    Key .BTreeOrder = 4 _
}
Dim options As BPlusTree(Of Integer, Integer).Options = DirectCast(opt.Clone(), BPlusTree(Of Integer, Integer).Options)

Assert.AreEqual(CreatePolicy.IfNeeded, options.CreateFile)
Assert.AreEqual(4, options.MaximumChildNodes)
Assert.AreEqual(4, options.MaximumValueNodes)

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.CreatePolicy

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
CreatePolicy BPlusTreeOptions.CreateFile


%%PageItemTitle%%

[image]
CSharpTest.Net
ExistingLogAction Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : ExistingLogAction Enumeration

Glossary Item Box

Defines the action to perform when opening a BPlusTree with an existing log file.

Syntax

Visual Basic (Declaration)
Public Enum ExistingLogAction
   Inherits System.Enum
C#
public enum ExistingLogAction : System.Enum

Members

Member | Description
Default | Infers the default wether or not the data file was created. For newly created data files (CreatePolicy = Always, or IfNeeded and the file is missing) the default will be Truncate. When existing data files are opened the default will ReplayAndCommit.
Ignore | Ignore the existing entries in the log
Replay | Replay the log entries uncommitted
ReplayAndCommit | Replay the log entries and commit the changes to the store
Truncate | Ignore the existing entries and truncate the log

Example

BPlusTree/BPlusTree.Test/BasicTestsVersion2.cs

C# Copy Code
var options = (BPlusTree<int, string>.OptionsV2)Options;

Assert.AreEqual(ExistingLogAction.Default, options.ExistingLogAction);
options.ExistingLogAction = ExistingLogAction.Ignore;
Assert.AreEqual(ExistingLogAction.Ignore, options.ExistingLogAction);

Assert.AreEqual(-1, options.TransactionLogLimit);
options.TransactionLogLimit = int.MaxValue;
Assert.AreEqual(int.MaxValue, options.TransactionLogLimit);
VB.NET Copy Code
Dim options As var = DirectCast(Options, BPlusTree(Of Integer, String).OptionsV2)

Assert.AreEqual(ExistingLogAction.[Default], options.ExistingLogAction)
options.ExistingLogAction = ExistingLogAction.Ignore
Assert.AreEqual(ExistingLogAction.Ignore, options.ExistingLogAction)

Assert.AreEqual(-1, options.TransactionLogLimit)
options.TransactionLogLimit = Integer.MaxValue
Assert.AreEqual(Integer.MaxValue, options.TransactionLogLimit)

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.ExistingLogAction

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
ExistingLogAction BPlusTree.OptionsV2.ExistingLogAction


%%PageItemTitle%%

[image]
CSharpTest.Net
FileVersion Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : FileVersion Enumeration

Glossary Item Box

Determines the binary file format and backwards compatibility

Syntax

Visual Basic (Declaration)
Public Enum FileVersion
   Inherits System.Enum
C#
public enum FileVersion : System.Enum

Members

Member | Description
Version1 | Version 1 compatable
Version2 | Version 2 compatable

Example

BPlusTree/BPlusTree.Test/SampleCustomTypeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.Options options =
    new BPlusTree<KeyInfo, DataValue>.Options(new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);//we can simply just guess close
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;//obviously this is just for testing
Assert.AreEqual(FileVersion.Version1, options.FileVersion);

Random rand = new Random();
KeyInfo k1 = new KeyInfo(), k2 = new KeyInfo();

using (BPlusTree<KeyInfo, DataValue> tree = new BPlusTree<KeyInfo, DataValue>(options))
{
    byte[] data = new byte[255];

    rand.NextBytes(data);
    tree.Add(k1, new DataValue(k1, data));

    Assert.IsTrue(tree.ContainsKey(k1));
    Assert.IsFalse(tree.ContainsKey(k1.Next()));
    Assert.AreEqual(data, tree[k1].Bytes);

    rand.NextBytes(data);
    tree.Add(k2, new DataValue(k2, data));

    Assert.IsTrue(tree.ContainsKey(k2));
    Assert.IsFalse(tree.ContainsKey(k2.Next()));
    Assert.AreEqual(data, tree[k2].Bytes);
}
options.CreateFile = CreatePolicy.Never;
using (BPlusTree<KeyInfo, DataValue> tree = new BPlusTree<KeyInfo, DataValue>(options))
{
    Assert.IsTrue(tree.ContainsKey(k1));
    Assert.IsTrue(tree.ContainsKey(k2));
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).Options(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
options.CalcBTreeOrder(32, 300)
'we can simply just guess close
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
'obviously this is just for testing
Assert.AreEqual(FileVersion.Version1, options.FileVersion)

Dim rand As New Random()
Dim k1 As New KeyInfo(), k2 As New KeyInfo()

Using tree As New BPlusTree(Of KeyInfo, DataValue)(options)
    Dim data As Byte() = New Byte(255) {}

    rand.NextBytes(data)
    tree.Add(k1, New DataValue(k1, data))

    Assert.IsTrue(tree.ContainsKey(k1))
    Assert.IsFalse(tree.ContainsKey(k1.[Next]()))
    Assert.AreEqual(data, tree(k1).Bytes)

    rand.NextBytes(data)
    tree.Add(k2, New DataValue(k2, data))

    Assert.IsTrue(tree.ContainsKey(k2))
    Assert.IsFalse(tree.ContainsKey(k2.[Next]()))
    Assert.AreEqual(data, tree(k2).Bytes)
End Using
options.CreateFile = CreatePolicy.Never
Using tree As New BPlusTree(Of KeyInfo, DataValue)(options)
    Assert.IsTrue(tree.ContainsKey(k1))
    Assert.IsTrue(tree.ContainsKey(k2))
End Using

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.FileVersion

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
FileVersion BPlusTreeOptions.FileVersion
FileVersion BPlusTree.OptionsV2.FileVersion
FileVersion BPlusTree.Options.FileVersion


%%PageItemTitle%%

[image]
CSharpTest.Net
StoragePerformance Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : StoragePerformance Enumeration

Glossary Item Box

Defines the levels of durability the store will try to achieve. 'Uncommitted changes' in the descriptions below refers to all changes made to the tree since the last call to CommitChanges() on the BPlusTree class.

Syntax

Visual Basic (Declaration)
Public Enum StoragePerformance
   Inherits System.Enum
C#
public enum StoragePerformance : System.Enum

Members

Member | Description
CommitToCache | (8k rps) Every write will commit changes to the storage file immediately into system cache
CommitToDisk | (1k rps) Every write will commit changes to the storage file immediately bypassing system cache (Slowest/Safest)
Default | Defaults to using a transaction log in system cache for best performance/durability.
Fastest | (100k rps) Uncommitted changes will be lost, a crash durring commit may corrupt state.
LogFileInCache | (30k rps) Uses a system-cached transaction log to recover uncommitted changes after a process crash.
LogFileNoCache | (2k rps) Uses a cache-writethrough transaction log to recover uncommitted changes after a power outage or system crash.

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.StoragePerformance

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
StoragePerformance BPlusTree.OptionsV2.StoragePerformance


%%PageItemTitle%%

[image]
CSharpTest.Net
StorageType Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : StorageType Enumeration

Glossary Item Box

Defines the storage type to use

Syntax

Visual Basic (Declaration)
Public Enum StorageType
   Inherits System.Enum
C#
public enum StorageType : System.Enum

Members

Member | Description
Custom | Uses a custom data store, (Set by setting the StorageSystem property)
Disk | Uses a file to store data, (Set by setting the FileName property)
Memory | Uses in-memory storage

Example

BPlusTree/BPlusTree.Test/TestCustomStorage.cs

C# Copy Code
BPlusTreeOptions<int, string> options = Options;
Assert.AreEqual(StorageType.Custom, options.StorageType);
VB.NET Copy Code
Dim options As BPlusTreeOptions(Of Integer, String) = Options
Assert.AreEqual(StorageType.[Custom], options.StorageType)

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.StorageType

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
StorageType BPlusTreeOptions.StorageType


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactionToken Structure
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionToken Structure

Glossary Item Box

A value representing the state/identifer/object of a single transaction. The field's meaning is defined by the ITrasactionLog implementation and is otherwise treated as an opaque token identifier of the transaction.

Syntax

Visual Basic (Declaration)
Public Structure TransactionToken
   Inherits System.ValueType
C#
public struct TransactionToken : System.ValueType

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Collections.TransactionToken

Requirements

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

See Also

Reference

TransactionToken Members
CSharpTest.Net.Collections Namespace
TransactionToken ITransactionLog.BeginTransaction()
ITransactionLog.AddValue(TransactionToken,TKey,TValue)
ITransactionLog.UpdateValue(TransactionToken,TKey,TValue)
ITransactionLog.RemoveValue(TransactionToken,TKey)
ITransactionLog.CommitTransaction(TransactionToken)
ITransactionLog.RollbackTransaction(TransactionToken)
TransactionLog.AddValue(TransactionToken,TKey,TValue)
TransactionLog.UpdateValue(TransactionToken,TKey,TValue)
TransactionLog.RemoveValue(TransactionToken,TKey)
TransactionLog.CommitTransaction(TransactionToken)
TransactionLog.RollbackTransaction(TransactionToken)

Used By

TransactionToken TransactionLog.BeginTransaction()


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TransactionToken Structure Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionToken Structure

Glossary Item Box

The following tables list the members exposed by TransactionToken.

Public Fields

 | Name | Description
Public Field | Handle | Undefined
Public Field | Object | Undefined
Public Field | State | Undefined
Top

See Also

Reference

TransactionToken Structure
CSharpTest.Net.Collections Namespace
TransactionToken ITransactionLog.BeginTransaction()
ITransactionLog.AddValue(TransactionToken,TKey,TValue)
ITransactionLog.UpdateValue(TransactionToken,TKey,TValue)
ITransactionLog.RemoveValue(TransactionToken,TKey)
ITransactionLog.CommitTransaction(TransactionToken)
ITransactionLog.RollbackTransaction(TransactionToken)
TransactionLog.AddValue(TransactionToken,TKey,TValue)
TransactionLog.UpdateValue(TransactionToken,TKey,TValue)
TransactionLog.RemoveValue(TransactionToken,TKey)
TransactionLog.CommitTransaction(TransactionToken)
TransactionLog.RollbackTransaction(TransactionToken)

Used By

TransactionToken TransactionLog.BeginTransaction()


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TransactionToken Structure Fields
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : TransactionToken Structure

Glossary Item Box

For a list of all members of this type, see TransactionToken members.

Public Fields

 | Name | Description
Public Field | Handle | Undefined
Public Field | Object | Undefined
Public Field | State | Undefined
Top

See Also

Reference

TransactionToken Structure
CSharpTest.Net.Collections Namespace
TransactionToken ITransactionLog.BeginTransaction()
ITransactionLog.AddValue(TransactionToken,TKey,TValue)
ITransactionLog.UpdateValue(TransactionToken,TKey,TValue)
ITransactionLog.RemoveValue(TransactionToken,TKey)
ITransactionLog.CommitTransaction(TransactionToken)
ITransactionLog.RollbackTransaction(TransactionToken)
TransactionLog.AddValue(TransactionToken,TKey,TValue)
TransactionLog.UpdateValue(TransactionToken,TKey,TValue)
TransactionLog.RemoveValue(TransactionToken,TKey)
TransactionLog.CommitTransaction(TransactionToken)
TransactionLog.RollbackTransaction(TransactionToken)

Used By

TransactionToken TransactionLog.BeginTransaction()


%%PageItemTitle%%

[image]
CSharpTest.Net
Handle Field
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionToken Structure : Handle Field

Glossary Item Box

Undefined

Syntax

Visual Basic (Declaration)
Public Handle As Long
C#
public long Handle

Requirements

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

See Also

Reference

TransactionToken Structure
TransactionToken Members

Used By

TransactionToken TransactionLog.BeginTransaction()
TransactionLog.RollbackTransaction(TransactionToken)


%%PageItemTitle%%

[image]
CSharpTest.Net
Object Field
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionToken Structure : Object Field

Glossary Item Box

Undefined

Syntax

Visual Basic (Declaration)
Public Object As Object
C#
public object Object

Requirements

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

See Also

Reference

TransactionToken Structure
TransactionToken Members

Used By

TransactionLog.CommitTransaction(TransactionToken)
TransactionLog.RollbackTransaction(TransactionToken)


%%PageItemTitle%%

[image]
CSharpTest.Net
State Field
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionToken Structure : State Field

Glossary Item Box

Undefined

Syntax

Visual Basic (Declaration)
Public State As Integer
C#
public int State

Requirements

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

See Also

Reference

TransactionToken Structure
TransactionToken Members

Used By

TransactionToken TransactionLog.BeginTransaction()
TransactionLog.CommitTransaction(TransactionToken)
TransactionLog.RollbackTransaction(TransactionToken)


%%PageItemTitle%%

[image]
CSharpTest.Net
INodeStorage Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : INodeStorage Interface

Glossary Item Box

Represents a persistance mechanic for node data

Syntax

Visual Basic (Declaration)
Public Interface INodeStorage
   Inherits CSharpTest.Net.Serialization.ISerializer(Of IStorageHandle)
C#
public interface INodeStorage : CSharpTest.Net.Serialization.ISerializer<IStorageHandle>

Requirements

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

See Also

Reference

INodeStorage Members
CSharpTest.Net.Collections Namespace
INodeStorage BPlusTreeOptions.StorageSystem


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
INodeStorage Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : INodeStorage Interface

Glossary Item Box

The following tables list the members exposed by INodeStorage.

Public Methods

 | Name | Description
Method | Create | Creates a node handle that will represent a new node instance
Method | Destroy | Destroys the node that was formally stored by the specified handle
Method | OpenRoot | Returns an immutable handle to the root node, sets isNew to true if no data exists
Method | Reset | Destroys the entire contents of the storage system except for the root handle which remains valid
Method | TryGetNode<TNode> | Retrieves a single node from storage
Method | Update<TNode> | Updates the node of the specified handle with the instance given
Top

See Also

Reference

INodeStorage Interface
CSharpTest.Net.Collections Namespace
INodeStorage BPlusTreeOptions.StorageSystem


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
INodeStorage Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : INodeStorage Interface

Glossary Item Box

For a list of all members of this type, see INodeStorage members.

Public Methods

 | Name | Description
Method | Create | Creates a node handle that will represent a new node instance
Method | Destroy | Destroys the node that was formally stored by the specified handle
Method | OpenRoot | Returns an immutable handle to the root node, sets isNew to true if no data exists
Method | Reset | Destroys the entire contents of the storage system except for the root handle which remains valid
Method | TryGetNode<TNode> | Retrieves a single node from storage
Method | Update<TNode> | Updates the node of the specified handle with the instance given
Top

See Also

Reference

INodeStorage Interface
CSharpTest.Net.Collections Namespace
INodeStorage BPlusTreeOptions.StorageSystem


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > INodeStorage Interface : Create Method

Glossary Item Box

Creates a node handle that will represent a new node instance

Syntax

Visual Basic (Declaration)
Function Create() As IStorageHandle
C#
IStorageHandle Create()

Requirements

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

See Also

Reference

INodeStorage Interface
INodeStorage Members
IStorageHandle


%%PageItemTitle%%

[image]
CSharpTest.Net
Destroy Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > INodeStorage Interface : Destroy Method

handle

Glossary Item Box

Destroys the node that was formally stored by the specified handle

Syntax

Visual Basic (Declaration)
Sub Destroy( _
   ByVal handle As IStorageHandle _
)
C#
void Destroy(
   IStorageHandle handle
)

Parameters

handle

Requirements

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

See Also

Reference

INodeStorage Interface
INodeStorage Members
IStorageHandle

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)


%%PageItemTitle%%

[image]
CSharpTest.Net
OpenRoot Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > INodeStorage Interface : OpenRoot Method

isNew

Glossary Item Box

Returns an immutable handle to the root node, sets isNew to true if no data exists

Syntax

Visual Basic (Declaration)
Function OpenRoot( _
   ByRef isNew As Boolean _
) As IStorageHandle
C#
IStorageHandle OpenRoot(
   out bool isNew
)

Parameters

isNew

Requirements

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

See Also

Reference

INodeStorage Interface
INodeStorage Members
IStorageHandle


%%PageItemTitle%%

[image]
CSharpTest.Net
Reset Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > INodeStorage Interface : Reset Method

Glossary Item Box

Destroys the entire contents of the storage system except for the root handle which remains valid

Syntax

Visual Basic (Declaration)
Sub Reset()
C#
void Reset()

Requirements

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

See Also

Reference

INodeStorage Interface
INodeStorage Members


%%PageItemTitle%%

TNode
[image]
CSharpTest.Net
TryGetNode<TNode> Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > INodeStorage Interface : TryGetNode<TNode> Method

handle
node
serializer

Glossary Item Box

Retrieves a single node from storage

Syntax

Visual Basic (Declaration)
Function TryGetNode(Of TNode)( _
   ByVal handle As IStorageHandle, _
   ByRef node As TNode, _
   ByVal serializer As ISerializer(Of TNode) _
) As Boolean
C#
bool TryGetNode<TNode>(
   IStorageHandle handle,
   out TNode node,
   ISerializer<TNode> serializer
)

Parameters

handle
node
serializer

Type Parameters

TNode

Requirements

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

See Also

Reference

INodeStorage Interface
INodeStorage Members
IStorageHandle
ISerializer


%%PageItemTitle%%

TNode
[image]
CSharpTest.Net
Update<TNode> Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > INodeStorage Interface : Update<TNode> Method

handle
serializer
node

Glossary Item Box

Updates the node of the specified handle with the instance given

Syntax

Visual Basic (Declaration)
Sub Update(Of TNode)( _
   ByVal handle As IStorageHandle, _
   ByVal serializer As ISerializer(Of TNode), _
   ByVal node As TNode _
)
C#
void Update<TNode>(
   IStorageHandle handle,
   ISerializer<TNode> serializer,
   TNode node
)

Parameters

handle
serializer
node

Type Parameters

TNode

Requirements

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

See Also

Reference

INodeStorage Interface
INodeStorage Members
IStorageHandle
ISerializer


%%PageItemTitle%%

[image]
CSharpTest.Net
INodeStoreWithCount Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : INodeStoreWithCount Interface

Glossary Item Box

An optional interface that allows storage provides to persist the record count

Syntax

Visual Basic (Declaration)
Public Interface INodeStoreWithCount
   Inherits INodeStorage, CSharpTest.Net.Interfaces.ITransactable, CSharpTest.Net.Serialization.ISerializer(Of IStorageHandle)
C#
public interface INodeStoreWithCount : INodeStorage, CSharpTest.Net.Interfaces.ITransactable, CSharpTest.Net.Serialization.ISerializer<IStorageHandle>

Requirements

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

See Also

Reference

INodeStoreWithCount Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
INodeStoreWithCount Interface Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : INodeStoreWithCount Interface

Glossary Item Box

The following tables list the members exposed by INodeStoreWithCount.

Public Properties

 | Name | Description
Property | Count | Used to retrieve the current record count after opening a store, -1 indicates an invalid entry. Prior to Commit() the count will be set to the actual record count.
Top

See Also

Reference

INodeStoreWithCount Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
INodeStoreWithCount Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : INodeStoreWithCount Interface

Glossary Item Box

For a list of all members of this type, see INodeStoreWithCount members.

Public Properties

 | Name | Description
Property | Count | Used to retrieve the current record count after opening a store, -1 indicates an invalid entry. Prior to Commit() the count will be set to the actual record count.
Top

See Also

Reference

INodeStoreWithCount Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > INodeStoreWithCount Interface : Count Property

Glossary Item Box

Used to retrieve the current record count after opening a store, -1 indicates an invalid entry. Prior to Commit() the count will be set to the actual record count.

Syntax

Visual Basic (Declaration)
Property Count As Integer
C#
int Count {get; set;}

Requirements

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

See Also

Reference

INodeStoreWithCount Interface
INodeStoreWithCount Members


%%PageItemTitle%%

[image]
CSharpTest.Net
IStorageHandle Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : IStorageHandle Interface

Glossary Item Box

Identifies a class as a reference to a node instance

Syntax

Visual Basic (Declaration)
Public Interface IStorageHandle
C#
public interface IStorageHandle

Requirements

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

See Also

Reference

IStorageHandle Members
CSharpTest.Net.Collections Namespace
IStorageHandle INodeStorage.OpenRoot(Boolean)
Boolean INodeStorage.TryGetNode(IStorageHandle,TNode,ISerializer)
IStorageHandle INodeStorage.Create()
INodeStorage.Destroy(IStorageHandle)
INodeStorage.Update(IStorageHandle,ISerializer,TNode)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IStorageHandle Interface Members
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : IStorageHandle Interface

Glossary Item Box

The following tables list the members exposed by IStorageHandle.

See Also

Reference

IStorageHandle Interface
CSharpTest.Net.Collections Namespace
IStorageHandle INodeStorage.OpenRoot(Boolean)
Boolean INodeStorage.TryGetNode(IStorageHandle,TNode,ISerializer)
IStorageHandle INodeStorage.Create()
INodeStorage.Destroy(IStorageHandle)
INodeStorage.Update(IStorageHandle,ISerializer,TNode)


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
ITransactionLog<TKey,TValue> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : ITransactionLog<TKey,TValue> Interface

Glossary Item Box

Represents a transaction log of writes to a dictionary.

Syntax

Visual Basic (Declaration)
Public Interface ITransactionLog
    (Of TKey,TValue)
C#
public interface ITransactionLog<TKey,TValue>

Type Parameters

TKey
TValue

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ITransactionLog<TKey,TValue> Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : ITransactionLog<TKey,TValue> Interface

Glossary Item Box

The following tables list the members exposed by ITransactionLog<TKey,TValue>.

Public Properties

 | Name | Description
Property | FileName | Returns the filename being currently used for transaction logging
Property | Size | Returns the current size of the log file in bytes
Top

Public Methods

 | Name | Description
Method | AddValue | The provided key/value pair was added in the provided transaction
Method | BeginTransaction | Notifies the log that a transaction is begining and create a token for this transaction scope.
Method | CommitTransaction | Commits the provided transaction
Method | MergeLog | Merges the contents of the log with an existing ordered key/value pair collection.
Method | RemoveValue | The provided key/value pair was removed in the provided transaction
Method | ReplayLog | Overloaded. Replay the entire log file to the provided dictionary interface
Method | RollbackTransaction | Abandons the provided transaction
Method | TruncateLog | Truncate the log and remove all existing entries
Method | UpdateValue | The provided key/value pair was updated in the provided transaction
Top

See Also

Reference

ITransactionLog<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ITransactionLog<TKey,TValue> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : ITransactionLog<TKey,TValue> Interface

Glossary Item Box

For a list of all members of this type, see ITransactionLog<TKey,TValue> members.

Public Methods

 | Name | Description
Method | AddValue | The provided key/value pair was added in the provided transaction
Method | BeginTransaction | Notifies the log that a transaction is begining and create a token for this transaction scope.
Method | CommitTransaction | Commits the provided transaction
Method | MergeLog | Merges the contents of the log with an existing ordered key/value pair collection.
Method | RemoveValue | The provided key/value pair was removed in the provided transaction
Method | ReplayLog | Overloaded. Replay the entire log file to the provided dictionary interface
Method | RollbackTransaction | Abandons the provided transaction
Method | TruncateLog | Truncate the log and remove all existing entries
Method | UpdateValue | The provided key/value pair was updated in the provided transaction
Top

See Also

Reference

ITransactionLog<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
AddValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : AddValue Method

token
key
value

Glossary Item Box

The provided key/value pair was added in the provided transaction

Syntax

Visual Basic (Declaration)
Sub AddValue( _
   ByRef token As TransactionToken, _
   ByVal key As TKey, _
   ByVal value As TValue _
)
C#
void AddValue(
   ref TransactionToken token,
   TKey key,
   TValue value
)

Parameters

token
key
value

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members
TransactionToken


%%PageItemTitle%%

[image]
CSharpTest.Net
BeginTransaction Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : BeginTransaction Method

Glossary Item Box

Notifies the log that a transaction is begining and create a token for this transaction scope.

Syntax

Visual Basic (Declaration)
Function BeginTransaction() As TransactionToken
C#
TransactionToken BeginTransaction()

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members
TransactionToken


%%PageItemTitle%%

[image]
CSharpTest.Net
CommitTransaction Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : CommitTransaction Method

token

Glossary Item Box

Commits the provided transaction

Syntax

Visual Basic (Declaration)
Sub CommitTransaction( _
   ByRef token As TransactionToken _
)
C#
void CommitTransaction(
   ref TransactionToken token
)

Parameters

token

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members
TransactionToken


%%PageItemTitle%%

[image]
CSharpTest.Net
MergeLog Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : MergeLog Method

keyComparer
existing

Glossary Item Box

Merges the contents of the log with an existing ordered key/value pair collection.

Syntax

Visual Basic (Declaration)
Function MergeLog( _
   ByVal keyComparer As IComparer(Of TKey), _
   ByVal existing As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
IEnumerable<KeyValuePair<TKey,TValue>> MergeLog(
   IComparer<TKey> keyComparer,
   IEnumerable<KeyValuePair<TKey,TValue>> existing
)

Parameters

keyComparer
existing

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
RemoveValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : RemoveValue Method

token
key

Glossary Item Box

The provided key/value pair was removed in the provided transaction

Syntax

Visual Basic (Declaration)
Sub RemoveValue( _
   ByRef token As TransactionToken, _
   ByVal key As TKey _
)
C#
void RemoveValue(
   ref TransactionToken token,
   TKey key
)

Parameters

token
key

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members
TransactionToken


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplayLog Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : ReplayLog Method

Glossary Item Box

Replay the entire log file to the provided dictionary interface

Overload List

Overload | Description
ReplayLog(IDictionary<TKey,TValue>) | Replay the entire log file to the provided dictionary interface
ReplayLog(IDictionary<TKey,TValue>,Int64) | Replay the log file from the position provided and output the new log position

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplayLog(IDictionary<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface > ReplayLog Method : ReplayLog(IDictionary<TKey,TValue>) Method

target

Glossary Item Box

Replay the entire log file to the provided dictionary interface

Syntax

Visual Basic (Declaration)
Overloads Sub ReplayLog( _
   ByVal target As IDictionary(Of TKey,TValue) _
)
C#
void ReplayLog(
   IDictionary<TKey,TValue> target
)

Parameters

target

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplayLog(IDictionary<TKey,TValue>,Int64) Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface > ReplayLog Method : ReplayLog(IDictionary<TKey,TValue>,Int64) Method

target
position

Glossary Item Box

Replay the log file from the position provided and output the new log position

Syntax

Visual Basic (Declaration)
Overloads Sub ReplayLog( _
   ByVal target As IDictionary(Of TKey,TValue), _
   ByRef position As Long _
)
C#
void ReplayLog(
   IDictionary<TKey,TValue> target,
   ref long position
)

Parameters

target
position

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
RollbackTransaction Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : RollbackTransaction Method

token

Glossary Item Box

Abandons the provided transaction

Syntax

Visual Basic (Declaration)
Sub RollbackTransaction( _
   ByRef token As TransactionToken _
)
C#
void RollbackTransaction(
   ref TransactionToken token
)

Parameters

token

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members
TransactionToken


%%PageItemTitle%%

[image]
CSharpTest.Net
TruncateLog Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : TruncateLog Method

Glossary Item Box

Truncate the log and remove all existing entries

Syntax

Visual Basic (Declaration)
Sub TruncateLog()
C#
void TruncateLog()

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members

Used By

BPlusTree.Rollback()


%%PageItemTitle%%

[image]
CSharpTest.Net
UpdateValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : UpdateValue Method

token
key
value

Glossary Item Box

The provided key/value pair was updated in the provided transaction

Syntax

Visual Basic (Declaration)
Sub UpdateValue( _
   ByRef token As TransactionToken, _
   ByVal key As TKey, _
   ByVal value As TValue _
)
C#
void UpdateValue(
   ref TransactionToken token,
   TKey key,
   TValue value
)

Parameters

token
key
value

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members
TransactionToken


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ITransactionLog<TKey,TValue> Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace : ITransactionLog<TKey,TValue> Interface

Glossary Item Box

For a list of all members of this type, see ITransactionLog<TKey,TValue> members.

Public Properties

 | Name | Description
Property | FileName | Returns the filename being currently used for transaction logging
Property | Size | Returns the current size of the log file in bytes
Top

See Also

Reference

ITransactionLog<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
FileName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : FileName Property

Glossary Item Box

Returns the filename being currently used for transaction logging

Syntax

Visual Basic (Declaration)
ReadOnly Property FileName As String
C#
string FileName {get;}

Example

BPlusTree/BPlusTree.Test/TestBackupAndRecovery.cs

C# Copy Code
using (TempFile savelog = new TempFile())
using (TempFile temp = new TempFile())
{
    var options = GetOptions(temp);
    options.FileBlockSize = 512;
    options.StoragePerformance = StoragePerformance.Fastest;
    options.CalcBTreeOrder(Marshal.SizeOf(typeof(Guid)), Marshal.SizeOf(typeof(TestInfo)));
    options.TransactionLog = new TransactionLog<Guid, TestInfo>(
        new TransactionLogOptions<Guid, TestInfo>(
            options.TransactionLogFileName,
            options.KeySerializer,
            options.ValueSerializer
            )
        );

    //Now recover...
    Dictionary<Guid, TestInfo> first = new Dictionary<Guid, TestInfo>();
    Dictionary<Guid, TestInfo> sample;

    using (var tree = new BPlusTree<Guid, TestInfo>(options))
    {
        tree.EnableCount();
        Insert(tree, first, 1, 100, TimeSpan.FromMinutes(1));
        tree.Commit();

        Assert.AreEqual(100, tree.Count);

        sample = new Dictionary<Guid, TestInfo>(first);
        Insert(tree, sample, 7, 5000, TimeSpan.FromMinutes(1));

        Assert.AreEqual(35100, tree.Count);

        for (int i = 0; i < 1; i++)
        {
            foreach (var rec in tree)
            {
                var value = rec.Value;
                value.UpdateCount++;
                value.ReadCount++;
                tree[rec.Key] = value;
            }
        }

        File.Copy(options.TransactionLog.FileName, savelog.TempPath, true);
        tree.Rollback();

        TestInfo.AssertEquals(first, tree);
    }

    //file still has initial committed data
    TestInfo.AssertEquals(first, BPlusTree<Guid, TestInfo>.EnumerateFile(options));

    //restore the log and verify all data.
    File.Copy(savelog.TempPath, options.TransactionLog.FileName, true);
    using (var tree = new BPlusTree<Guid, TestInfo>(options))
    {
        TestInfo.AssertEquals(sample, tree);
    }

    //file still has initial committed data
    TestInfo.AssertEquals(sample, BPlusTree<Guid, TestInfo>.EnumerateFile(options));
}
VB.NET Copy Code
Using savelog As New TempFile()
    Using temp As New TempFile()
        Dim options As var = GetOptions(temp)
        options.FileBlockSize = 512
        options.StoragePerformance = StoragePerformance.Fastest
        options.CalcBTreeOrder(Marshal.SizeOf(GetType(Guid)), Marshal.SizeOf(GetType(TestInfo)))
        options.TransactionLog = New TransactionLog(Of Guid, TestInfo)(New TransactionLogOptions(Of Guid, TestInfo)(options.TransactionLogFileName, options.KeySerializer, options.ValueSerializer))

        'Now recover...
        Dim first As New Dictionary(Of Guid, TestInfo)()
        Dim sample As Dictionary(Of Guid, TestInfo)

        Using tree As var = New BPlusTree(Of Guid, TestInfo)(options)
            tree.EnableCount()
            Insert(tree, first, 1, 100, TimeSpan.FromMinutes(1))
            tree.Commit()

            Assert.AreEqual(100, tree.Count)

            sample = New Dictionary(Of Guid, TestInfo)(first)
            Insert(tree, sample, 7, 5000, TimeSpan.FromMinutes(1))

            Assert.AreEqual(35100, tree.Count)

            Dim i As Integer = 0
            While i < 1
                For Each rec As var In tree
                    Dim value As var = rec.Value
                    System.Math.Max(System.Threading.Interlocked.Increment(value.UpdateCount),value.UpdateCount - 1)
                    System.Math.Max(System.Threading.Interlocked.Increment(value.ReadCount),value.ReadCount - 1)
                    tree(rec.Key) = value
                Next
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While

            File.Copy(options.TransactionLog.FileName, savelog.TempPath, True)
            tree.Rollback()

            TestInfo.AssertEquals(first, tree)
        End Using

        'file still has initial committed data
        TestInfo.AssertEquals(first, BPlusTree(Of Guid, TestInfo).EnumerateFile(options))

        'restore the log and verify all data.
        File.Copy(savelog.TempPath, options.TransactionLog.FileName, True)
        Using tree As var = New BPlusTree(Of Guid, TestInfo)(options)
            TestInfo.AssertEquals(sample, tree)
        End Using

        'file still has initial committed data
        TestInfo.AssertEquals(sample, BPlusTree(Of Guid, TestInfo).EnumerateFile(options))
    End Using
End Using

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Size Property
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > ITransactionLog<TKey,TValue> Interface : Size Property

Glossary Item Box

Returns the current size of the log file in bytes

Syntax

Visual Basic (Declaration)
ReadOnly Property Size As Long
C#
long Size {get;}

Requirements

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

See Also

Reference

ITransactionLog<TKey,TValue> Interface
ITransactionLog<TKey,TValue> Members


%%phrase%%

CSharpTest.Net.Library Assembly
See Also Send Feedback Download Help File

Glossary Item Box

Namespaces

Namespace | Description
(Global) |
CSharpTest.Net |
CSharpTest.Net.AppConfig |
CSharpTest.Net.Bases |
CSharpTest.Net.Cloning |
CSharpTest.Net.Collections |
CSharpTest.Net.Commands |
CSharpTest.Net.Crypto |
CSharpTest.Net.Data |
CSharpTest.Net.Delegates |
CSharpTest.Net.Formatting |
CSharpTest.Net.Html |
CSharpTest.Net.Http |
CSharpTest.Net.Interfaces |
CSharpTest.Net.IO |
CSharpTest.Net.IpcChannel |
CSharpTest.Net.Processes |
CSharpTest.Net.Reflection |
CSharpTest.Net.Serialization |
CSharpTest.Net.Serialization.StorageClasses |
CSharpTest.Net.Services |
CSharpTest.Net.Synchronization |
CSharpTest.Net.Threading |
CSharpTest.Net.Utils |
CSharpTest.Net.WinForms |


%%ItemTitle%%

(Global) Namespace (CSharpTest.Net.Library)
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : (Global) Namespace

Glossary Item Box

Classes

 | Class | Description
Class | Check | provides a set of runtime validations for inputs

Delegates

 | Delegate | Description
Delegate | Check.ExceptionBuilder | Used to delay creation of the excpetion until the condition fails.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
Check Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace : Check Class

Glossary Item Box

provides a set of runtime validations for inputs

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class Check
C#
public static class Check

Inheritance Hierarchy

System.Object
Check

Requirements

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

See Also

Reference

Check Members
(Global) Namespace

Source Code

Shared/Check.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Check Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace : Check Class

Glossary Item Box

The following tables list the members exposed by Check.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | ArraySize<T> | Verifies that the array is not empty and has at least min, but not more than max items. throws ArgumentNullExcpetion throws ArgumentOutOfRangeException
static (Shared in Visual Basic) | Assert | Overloaded. Verifies that the condition is true and if it fails constructs the specified type of exception and throws.
static (Shared in Visual Basic) | InRange<T> | Verifies that the value is min, max, or between the two. throws ArgumentOutOfRangeException
static (Shared in Visual Basic) | IsAssignable | Overloaded. Returns (T)value if the object provided can be assinged to a variable of type T throws ArgumentException
static (Shared in Visual Basic) | IsEqual<T> | Verifies that the two values are the same throws ArgumentException
static (Shared in Visual Basic) | NotEmpty | Overloaded. Verfies that the string is not null and not empty and returns the string. throws ArgumentNullException, ArgumentOutOfRangeException
static (Shared in Visual Basic) | NotEqual<T> | Verifies that the two values are NOT the same throws ArgumentException
static (Shared in Visual Basic) | NotNull<T> | Verifies that value is not null and returns the value or throws ArgumentNullException
Top

See Also

Reference

Check Class
(Global) Namespace

Source Code

Shared/Check.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Check Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace : Check Class

Glossary Item Box

For a list of all members of this type, see Check members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | ArraySize<T> | Verifies that the array is not empty and has at least min, but not more than max items. throws ArgumentNullExcpetion throws ArgumentOutOfRangeException
static (Shared in Visual Basic) | Assert | Overloaded. Verifies that the condition is true and if it fails constructs the specified type of exception and throws.
static (Shared in Visual Basic) | InRange<T> | Verifies that the value is min, max, or between the two. throws ArgumentOutOfRangeException
static (Shared in Visual Basic) | IsAssignable | Overloaded. Returns (T)value if the object provided can be assinged to a variable of type T throws ArgumentException
static (Shared in Visual Basic) | IsEqual<T> | Verifies that the two values are the same throws ArgumentException
static (Shared in Visual Basic) | NotEmpty | Overloaded. Verfies that the string is not null and not empty and returns the string. throws ArgumentNullException, ArgumentOutOfRangeException
static (Shared in Visual Basic) | NotEqual<T> | Verifies that the two values are NOT the same throws ArgumentException
static (Shared in Visual Basic) | NotNull<T> | Verifies that value is not null and returns the value or throws ArgumentNullException
Top

See Also

Reference

Check Class
(Global) Namespace

Source Code

Shared/Check.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
ArraySize<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class : ArraySize<T> Method

value
min
max

Glossary Item Box

Verifies that the array is not empty and has at least min, but not more than max items. throws ArgumentNullExcpetion throws ArgumentOutOfRangeException

Syntax

Visual Basic (Declaration)
Public Shared Function ArraySize(Of T)( _
   ByVal value() As T, _
   ByVal min As Integer, _
   ByVal max As Integer _
) As T()
C#
public static T[] ArraySize<T>(
   T[] value,
   int min,
   int max
)

Parameters

value
min
max

Type Parameters

T

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

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

See Also

Reference

Check Class
Check Members

Source Code

Shared/Check.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class : Assert Method

Glossary Item Box

Verifies that the condition is true and if it fails constructs the specified type of exception and throws.

Overload List

Overload | Description
Assert<TException>(Boolean) | Verifies that the condition is true and if it fails constructs the specified type of exception and throws.
Assert<TException>(Boolean,String) | Verifies that the condition is true and if it fails constructs the specified type of exception with any arguments provided and throws.
Assert(Boolean,ExceptionBuilder) | Verifies that the condition is true and if it fails throws the execption returned by fnExceptionBuilder()
Assert<TException>(Boolean,String,Exception) | Verifies that the condition is true and if it fails constructs the specified type of exception with any arguments provided and throws.

Requirements

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

See Also

Reference

Check Class
Check Members


%%PageItemTitle%%

TException
[image]
CSharpTest.Net
Assert<TException>(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > Assert Method : Assert<TException>(Boolean) Method

condition

Glossary Item Box

Verifies that the condition is true and if it fails constructs the specified type of exception and throws.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert(Of TException As {New, Exception})( _
   ByVal condition As Boolean _
)
C#
public static void Assert<TException>(
   bool condition
)
where TException: new(), Exception

Parameters

condition

Type Parameters

TException

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Source Code

Shared/Check.cs


%%PageItemTitle%%

TException
[image]
CSharpTest.Net
Assert<TException>(Boolean,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > Assert Method : Assert<TException>(Boolean,String) Method

condition
message

Glossary Item Box

Verifies that the condition is true and if it fails constructs the specified type of exception with any arguments provided and throws.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert(Of TException As {New, Exception})( _
   ByVal condition As Boolean, _
   ByVal message As String _
)
C#
public static void Assert<TException>(
   bool condition,
   string message
)
where TException: new(), Exception

Parameters

condition
message

Type Parameters

TException

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Source Code

Shared/Check.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(Boolean,ExceptionBuilder) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > Assert Method : Assert(Boolean,ExceptionBuilder) Method

condition
fnExceptionBuilder

Glossary Item Box

Verifies that the condition is true and if it fails throws the execption returned by fnExceptionBuilder()

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal condition As Boolean, _
   ByVal fnExceptionBuilder As Check.ExceptionBuilder _
)
C#
public static void Assert(
   bool condition,
   Check.ExceptionBuilder fnExceptionBuilder
)

Parameters

condition
fnExceptionBuilder

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List
Check.ExceptionBuilder

Source Code

Shared/Check.cs


%%PageItemTitle%%

TException
[image]
CSharpTest.Net
Assert<TException>(Boolean,String,Exception) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > Assert Method : Assert<TException>(Boolean,String,Exception) Method

condition
message
innerException

Glossary Item Box

Verifies that the condition is true and if it fails constructs the specified type of exception with any arguments provided and throws.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert(Of TException As {New, Exception})( _
   ByVal condition As Boolean, _
   ByVal message As String, _
   ByVal innerException As Exception _
)
C#
public static void Assert<TException>(
   bool condition,
   string message,
   Exception innerException
)
where TException: new(), Exception

Parameters

condition
message
innerException

Type Parameters

TException

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Source Code

Shared/Check.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
InRange<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class : InRange<T> Method

value
min
max

Glossary Item Box

Verifies that the value is min, max, or between the two. throws ArgumentOutOfRangeException

Syntax

Visual Basic (Declaration)
Public Shared Function InRange(Of T As IComparable(Of T))( _
   ByVal value As T, _
   ByVal min As T, _
   ByVal max As T _
) As T
C#
public static T InRange<T>(
   T value,
   T min,
   T max
)
where T: IComparable<T>

Parameters

value
min
max

Type Parameters

T

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

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

See Also

Reference

Check Class
Check Members

Source Code

Shared/Check.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsAssignable Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class : IsAssignable Method

Glossary Item Box

Returns (T)value if the object provided can be assinged to a variable of type T throws ArgumentException

Overload List

Overload | Description
IsAssignable<T>(Object) | Returns (T)value if the object provided can be assinged to a variable of type T throws ArgumentException
IsAssignable(Type,Object) | Returns value if the object provided can be assinged to a variable of type toType throws ArgumentException
IsAssignable(Type,Type) | Throws ArgumentException if the type fromType cannot be assigned to variable of type toType

Requirements

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

See Also

Reference

Check Class
Check Members


%%PageItemTitle%%

T
[image]
CSharpTest.Net
IsAssignable<T>(Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > IsAssignable Method : IsAssignable<T>(Object) Method

value

Glossary Item Box

Returns (T)value if the object provided can be assinged to a variable of type T throws ArgumentException

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function IsAssignable(Of T)( _
   ByVal value As Object _
) As T
C#
public static T IsAssignable<T>(
   object value
)

Parameters

value

Type Parameters

T

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Source Code

Shared/Check.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsAssignable(Type,Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > IsAssignable Method : IsAssignable(Type,Object) Method

toType
fromValue

Glossary Item Box

Returns value if the object provided can be assinged to a variable of type toType throws ArgumentException

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function IsAssignable( _
   ByVal toType As Type, _
   ByVal fromValue As Object _
) As Object
C#
public static object IsAssignable(
   Type toType,
   object fromValue
)

Parameters

toType
fromValue

Exceptions

Exception | Description
System.ArgumentException | The exception that is thrown when one of the arguments provided to a method is not valid.

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Used By

T Check.IsAssignable(Object)

Source Code

Shared/Check.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsAssignable(Type,Type) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > IsAssignable Method : IsAssignable(Type,Type) Method

toType
fromType

Glossary Item Box

Throws ArgumentException if the type fromType cannot be assigned to variable of type toType

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub IsAssignable( _
   ByVal toType As Type, _
   ByVal fromType As Type _
)
C#
public static void IsAssignable(
   Type toType,
   Type fromType
)

Parameters

toType
fromType

Exceptions

Exception | Description
System.ArgumentException | The exception that is thrown when one of the arguments provided to a method is not valid.

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Used By

Object Check.IsAssignable(Type,Object)

Source Code

Shared/Check.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
IsEqual<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class : IsEqual<T> Method

a
b

Glossary Item Box

Verifies that the two values are the same throws ArgumentException

Syntax

Visual Basic (Declaration)
Public Shared Sub IsEqual(Of T As IEquatable(Of T))( _
   ByVal a As T, _
   ByVal b As T _
)
C#
public static void IsEqual<T>(
   T a,
   T b
)
where T: IEquatable<T>

Parameters

a
b

Type Parameters

T

Exceptions

Exception | Description
System.ArgumentException | The exception that is thrown when one of the arguments provided to a method is not valid.

Requirements

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

See Also

Reference

Check Class
Check Members

Source Code

Shared/Check.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NotEmpty Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class : NotEmpty Method

Glossary Item Box

Verfies that the string is not null and not empty and returns the string. throws ArgumentNullException, ArgumentOutOfRangeException

Overload List

Overload | Description
NotEmpty(String) | Verfies that the string is not null and not empty and returns the string. throws ArgumentNullException, ArgumentOutOfRangeException
NotEmpty(Guid) | Verfies that the Guid is not empty. throws ArgumentOutOfRangeException
NotEmpty<T>(T) | Verfies that the collection is not null and not empty and returns the collection. throws ArgumentNullException, ArgumentOutOfRangeException

Requirements

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

See Also

Reference

Check Class
Check Members


%%PageItemTitle%%

[image]
CSharpTest.Net
NotEmpty(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > NotEmpty Method : NotEmpty(String) Method

value

Glossary Item Box

Verfies that the string is not null and not empty and returns the string. throws ArgumentNullException, ArgumentOutOfRangeException

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function NotEmpty( _
   ByVal value As String _
) As String
C#
public static string NotEmpty(
   string value
)

Parameters

value

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Source Code

Shared/Check.cs

Used By

IpcEventChannel.RaiseLocal(String,String[])
PropertySerializer.AddMember(String)
PropertyType PropertyType.TraverseProperties(Type,String[])
PropertyValue PropertyValue.TraverseProperties(Object,String[])
Boolean RegistryStorage.Read(String,String,String)
RegistryStorage.Write(String,String,String)
RegistryStorage.Delete(String,String)
Boolean IsolatedStorage.Read(String,String,String)
IsolatedStorage.Write(String,String,String)
IsolatedStorage.Delete(String,String)
Boolean FileStorage.Read(String,String,String)
FileStorage.Write(String,String,String)
FileStorage.Delete(String,String)
Boolean DictionaryStorage.Read(String,String,String)
DictionaryStorage.Write(String,String,String)
DictionaryStorage.Delete(String,String)
SvcControlManager.SetServiceExeArgs(String,String[])
SvcControlManager SvcControlManager.Create(String,String,Boolean,ServiceStartMode,String,String[],String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
NotEmpty(Guid) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > NotEmpty Method : NotEmpty(Guid) Method

value

Glossary Item Box

Verfies that the Guid is not empty. throws ArgumentOutOfRangeException

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function NotEmpty( _
   ByVal value As Guid _
) As Guid
C#
public static Guid NotEmpty(
   Guid value
)

Parameters

value

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Source Code

Shared/Check.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
NotEmpty<T>(T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class > NotEmpty Method : NotEmpty<T>(T) Method

value

Glossary Item Box

Verfies that the collection is not null and not empty and returns the collection. throws ArgumentNullException, ArgumentOutOfRangeException

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function NotEmpty(Of T As IEnumerable)( _
   ByVal value As T _
) As T
C#
public static T NotEmpty<T>(
   T value
)
where T: IEnumerable

Parameters

value

Type Parameters

T

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

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

See Also

Reference

Check Class
Check Members
Overload List

Source Code

Shared/Check.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
NotEqual<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class : NotEqual<T> Method

a
b

Glossary Item Box

Verifies that the two values are NOT the same throws ArgumentException

Syntax

Visual Basic (Declaration)
Public Shared Sub NotEqual(Of T As IEquatable(Of T))( _
   ByVal a As T, _
   ByVal b As T _
)
C#
public static void NotEqual<T>(
   T a,
   T b
)
where T: IEquatable<T>

Parameters

a
b

Type Parameters

T

Exceptions

Exception | Description
System.ArgumentException | The exception that is thrown when one of the arguments provided to a method is not valid.

Requirements

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

See Also

Reference

Check Class
Check Members

Source Code

Shared/Check.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
NotNull<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace > Check Class : NotNull<T> Method

value

Glossary Item Box

Verifies that value is not null and returns the value or throws ArgumentNullException

Syntax

Visual Basic (Declaration)
Public Shared Function NotNull(Of T)( _
   ByVal value As T _
) As T
C#
public static T NotNull<T>(
   T value
)

Parameters

value

Type Parameters

T

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Requirements

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

See Also

Reference

Check Class
Check Members

Source Code

Shared/Check.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Check.ExceptionBuilder Delegate
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > (Global) Namespace : Check.ExceptionBuilder Delegate

Glossary Item Box

Used to delay creation of the excpetion until the condition fails.

Syntax

Visual Basic (Declaration)
Public Delegate Function Check.ExceptionBuilder() As Exception
C#
public delegate Exception Check.ExceptionBuilder()

Requirements

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

See Also

Reference

Check.ExceptionBuilder Members
(Global) Namespace
Check.Assert(Boolean,Check.ExceptionBuilder)

Source Code

Shared/Check.cs


%%ItemTitle%%

CSharpTest.Net Namespace (CSharpTest.Net.Library)
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net Namespace

Glossary Item Box

Classes

 | Class | Description
Class | Constants | This class name is actually wrong... These values are only constant for the life the current app domain ;)
Class | DebugAssertionFailedException | Exception class: DebugAssertionFailedException Debug Assertion Failed: {0}
Class | LurchTableCorruptionException | Exception class: LurchTableCorruptionException The LurchTable internal datastructure appears to be corrupted.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
Constants Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : Constants Class

Glossary Item Box

This class name is actually wrong... These values are only constant for the life the current app domain ;)

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class Constants
C#
public static class Constants

Inheritance Hierarchy

System.Object
CSharpTest.Net.Constants

Requirements

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

See Also

Reference

Constants Members
CSharpTest.Net Namespace

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Constants Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : Constants Class

Glossary Item Box

The following tables list the members exposed by Constants.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | AppDomainName | Returns the current AppDomain's friendly name
static (Shared in Visual Basic) | ApplicationData | Returns the roaming user profile path for the currently running software application: {SpecialFolder.ApplicationData}\{CompanyName}\{ProductName}
static (Shared in Visual Basic) | CompanyName | Returns the company name of the entry assembly
static (Shared in Visual Basic) | DefaultLogFile | Returns a default log file name derived as: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}\{AppDomainName}.txt
static (Shared in Visual Basic) | EntryAssembly | Returns the entry-point assembly or the highest stack assembly
static (Shared in Visual Basic) | IsDebugging | Returns true if a debugger is attached to the process
static (Shared in Visual Basic) | IsUnitTest | Returns true if the current process is running a unit test
static (Shared in Visual Basic) | LocalApplicationData | Returns the non-roaming user profile path for the currently running software application: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}
static (Shared in Visual Basic) | ProcessFile | Returns the file path to the exe for this process
static (Shared in Visual Basic) | ProcessId | Returns the current process id
static (Shared in Visual Basic) | ProcessName | Returns the current process name without an extension
static (Shared in Visual Basic) | ProductName | Returns the product name of the entry assembly
static (Shared in Visual Basic) | ProductVersion | Returns the product version of the entry assembly
static (Shared in Visual Basic) | RegistrySoftwarePath | Returns the HKCU or HKLM path for this software application based on the process that is running: Software\{CompanyName}\{ProductName}
Public Field | UNKNOWN | Returns the string '[Unknown]'
Top

See Also

Reference

Constants Class
CSharpTest.Net Namespace

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
Constants Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : Constants Class

Glossary Item Box

For a list of all members of this type, see Constants members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | AppDomainName | Returns the current AppDomain's friendly name
static (Shared in Visual Basic) | ApplicationData | Returns the roaming user profile path for the currently running software application: {SpecialFolder.ApplicationData}\{CompanyName}\{ProductName}
static (Shared in Visual Basic) | CompanyName | Returns the company name of the entry assembly
static (Shared in Visual Basic) | DefaultLogFile | Returns a default log file name derived as: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}\{AppDomainName}.txt
static (Shared in Visual Basic) | EntryAssembly | Returns the entry-point assembly or the highest stack assembly
static (Shared in Visual Basic) | IsDebugging | Returns true if a debugger is attached to the process
static (Shared in Visual Basic) | IsUnitTest | Returns true if the current process is running a unit test
static (Shared in Visual Basic) | LocalApplicationData | Returns the non-roaming user profile path for the currently running software application: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}
static (Shared in Visual Basic) | ProcessFile | Returns the file path to the exe for this process
static (Shared in Visual Basic) | ProcessId | Returns the current process id
static (Shared in Visual Basic) | ProcessName | Returns the current process name without an extension
static (Shared in Visual Basic) | ProductName | Returns the product name of the entry assembly
static (Shared in Visual Basic) | ProductVersion | Returns the product version of the entry assembly
static (Shared in Visual Basic) | RegistrySoftwarePath | Returns the HKCU or HKLM path for this software application based on the process that is running: Software\{CompanyName}\{ProductName}
Public Field | UNKNOWN | Returns the string '[Unknown]'
Top

See Also

Reference

Constants Class
CSharpTest.Net Namespace

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AppDomainName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : AppDomainName Field

Glossary Item Box

Returns the current AppDomain's friendly name

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly AppDomainName As String
C#
public static readonly string AppDomainName

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ApplicationData Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : ApplicationData Field

Glossary Item Box

Returns the roaming user profile path for the currently running software application: {SpecialFolder.ApplicationData}\{CompanyName}\{ProductName}

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly ApplicationData As String
C#
public static readonly string ApplicationData

Example

Library/Library.Test/TestSerializers.cs

C# Copy Code
if(Directory.Exists(Constants.ApplicationData)) Directory.Delete(Constants.ApplicationData, true);
if (Directory.Exists(Constants.LocalApplicationData)) Directory.Delete(Constants.LocalApplicationData, true);
VB.NET Copy Code
If Directory.Exists(Constants.ApplicationData) Then
    Directory.Delete(Constants.ApplicationData, True)
End If
If Directory.Exists(Constants.LocalApplicationData) Then
    Directory.Delete(Constants.LocalApplicationData, True)
End If

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CompanyName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : CompanyName Field

Glossary Item Box

Returns the company name of the entry assembly

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly CompanyName As String
C#
public static readonly string CompanyName

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultLogFile Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : DefaultLogFile Field

Glossary Item Box

Returns a default log file name derived as: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}\{AppDomainName}.txt

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly DefaultLogFile As String
C#
public static readonly string DefaultLogFile

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EntryAssembly Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : EntryAssembly Field

Glossary Item Box

Returns the entry-point assembly or the highest stack assembly

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly EntryAssembly As Assembly
C#
public static readonly Assembly EntryAssembly

Requirements

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

See Also

Reference

Constants Class
Constants Members

Used By

ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsDebugging Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : IsDebugging Field

Glossary Item Box

Returns true if a debugger is attached to the process

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly IsDebugging As Boolean
C#
public static readonly bool IsDebugging

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsUnitTest Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : IsUnitTest Field

Glossary Item Box

Returns true if the current process is running a unit test

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly IsUnitTest As Boolean
C#
public static readonly bool IsUnitTest

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalApplicationData Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : LocalApplicationData Field

Glossary Item Box

Returns the non-roaming user profile path for the currently running software application: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly LocalApplicationData As String
C#
public static readonly string LocalApplicationData

Example

Library/Library.Test/TestSerializers.cs

C# Copy Code
if(Directory.Exists(Constants.ApplicationData)) Directory.Delete(Constants.ApplicationData, true);
if (Directory.Exists(Constants.LocalApplicationData)) Directory.Delete(Constants.LocalApplicationData, true);
VB.NET Copy Code
If Directory.Exists(Constants.ApplicationData) Then
    Directory.Delete(Constants.ApplicationData, True)
End If
If Directory.Exists(Constants.LocalApplicationData) Then
    Directory.Delete(Constants.LocalApplicationData, True)
End If

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessFile Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : ProcessFile Field

Glossary Item Box

Returns the file path to the exe for this process

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly ProcessFile As String
C#
public static readonly string ProcessFile

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessId Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : ProcessId Field

Glossary Item Box

Returns the current process id

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly ProcessId As Integer
C#
public static readonly int ProcessId

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : ProcessName Field

Glossary Item Box

Returns the current process name without an extension

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly ProcessName As String
C#
public static readonly string ProcessName

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProductName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : ProductName Field

Glossary Item Box

Returns the product name of the entry assembly

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly ProductName As String
C#
public static readonly string ProductName

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProductVersion Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : ProductVersion Field

Glossary Item Box

Returns the product version of the entry assembly

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly ProductVersion As Version
C#
public static readonly Version ProductVersion

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegistrySoftwarePath Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : RegistrySoftwarePath Field

Glossary Item Box

Returns the HKCU or HKLM path for this software application based on the process that is running: Software\{CompanyName}\{ProductName}

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly RegistrySoftwarePath As String
C#
public static readonly string RegistrySoftwarePath

Example

Library/Library.Test/TestSerializers.cs

C# Copy Code
try {
    Registry.CurrentUser.DeleteSubKeyTree(Path.GetDirectoryName(Constants.RegistrySoftwarePath));
} catch (ArgumentException) { }
VB.NET Copy Code
Try
    Registry.CurrentUser.DeleteSubKeyTree(Path.GetDirectoryName(Constants.RegistrySoftwarePath))
Catch generatedExceptionName As ArgumentException
End Try

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UNKNOWN Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > Constants Class : UNKNOWN Field

Glossary Item Box

Returns the string '[Unknown]'

Syntax

Visual Basic (Declaration)
Public Const UNKNOWN As String
C#
public const string UNKNOWN

Requirements

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

See Also

Reference

Constants Class
Constants Members

Source Code

Library/Utils/Constants.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugAssertionFailedException Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : DebugAssertionFailedException Class

Glossary Item Box

Exception class: DebugAssertionFailedException Debug Assertion Failed: {0}

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class DebugAssertionFailedException
   Inherits System.ApplicationException
C#
[SerializableAttribute()]
public class DebugAssertionFailedException : System.ApplicationException

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>(
    false, 0, 1, false, 1);

using (ILockStrategy lck = factory.Create())
{
    using (lck.Write())
    using (lck.Write()) //second lock, allow recurse 1 time as per constructor
    {
        try { using (lck.Write()) { Assert.Fail(); } }
        catch (Exception ex)
        {
            Assert.IsTrue(ex is DebugAssertionFailedException);//nesting prohibited by debug lock
        }
    }

    using (lck.Read())
    using (lck.Read()) //second lock, allow recurse 1 time as per constructor
    {
        try { using (lck.Read()) { Assert.Fail(); } }
        catch (Exception ex)
        {
            Assert.IsTrue(ex is DebugAssertionFailedException);//nesting prohibited by debug lock
        }
    }
}
VB.NET Copy Code
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)

Using lck As ILockStrategy = factory.Create()
    Using lck.Write()
        Using lck.Write()
            'second lock, allow recurse 1 time as per constructor
            Try
                Using lck.Write()
                    Assert.Fail()
                End Using
            Catch ex As Exception
                    'nesting prohibited by debug lock
                Assert.IsTrue(TypeOf ex Is DebugAssertionFailedException)
            End Try
        End Using
    End Using

    Using lck.Read()
        Using lck.Read()
            'second lock, allow recurse 1 time as per constructor
            Try
                Using lck.Read()
                    Assert.Fail()
                End Using
            Catch ex As Exception
                    'nesting prohibited by debug lock
                Assert.IsTrue(TypeOf ex Is DebugAssertionFailedException)
            End Try
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
System.Exception
System.ApplicationException
CSharpTest.Net.DebugAssertionFailedException

Requirements

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

See Also

Reference

DebugAssertionFailedException Members
CSharpTest.Net Namespace

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DebugAssertionFailedException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : DebugAssertionFailedException Class

Glossary Item Box

The following tables list the members exposed by DebugAssertionFailedException.

Public Constructors

 | Name | Description
Public Constructor | DebugAssertionFailedException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws Debug Assertion Failed: {0}
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

DebugAssertionFailedException Class
CSharpTest.Net Namespace

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugAssertionFailedException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > DebugAssertionFailedException Class : DebugAssertionFailedException Constructor

Glossary Item Box

Overload List

Overload | Description
DebugAssertionFailedException Constructor(SerializationInfo,StreamingContext) | Serialization constructor
DebugAssertionFailedException Constructor(Exception,Int32,String) | Constructs the exception from an hresult and message bypassing the message formatting
DebugAssertionFailedException Constructor(String) | Debug Assertion Failed: {0}
DebugAssertionFailedException Constructor(String,Exception) | Debug Assertion Failed: {0}

Requirements

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

See Also

Reference

DebugAssertionFailedException Class
DebugAssertionFailedException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugAssertionFailedException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > DebugAssertionFailedException Class > DebugAssertionFailedException Constructor : DebugAssertionFailedException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Serialization constructor

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected DebugAssertionFailedException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

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

See Also

Reference

DebugAssertionFailedException Class
DebugAssertionFailedException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugAssertionFailedException Constructor(Exception,Int32,String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > DebugAssertionFailedException Class > DebugAssertionFailedException Constructor : DebugAssertionFailedException Constructor(Exception,Int32,String)

innerException
hResult
message

Glossary Item Box

Constructs the exception from an hresult and message bypassing the message formatting

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal innerException As Exception, _
   ByVal hResult As Integer, _
   ByVal message As String _
)
C#
protected DebugAssertionFailedException(
   Exception innerException,
   int hResult,
   string message
)

Parameters

innerException
hResult
message

Requirements

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

See Also

Reference

DebugAssertionFailedException Class
DebugAssertionFailedException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugAssertionFailedException Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > DebugAssertionFailedException Class > DebugAssertionFailedException Constructor : DebugAssertionFailedException Constructor(String)

message

Glossary Item Box

Debug Assertion Failed: {0}

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal message As String _
)
C#
public DebugAssertionFailedException(
   string message
)

Parameters

message

Requirements

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

See Also

Reference

DebugAssertionFailedException Class
DebugAssertionFailedException Members
Overload List

Used By

DebugAssertionFailedException.Assert(Boolean,String)

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugAssertionFailedException Constructor(String,Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > DebugAssertionFailedException Class > DebugAssertionFailedException Constructor : DebugAssertionFailedException Constructor(String,Exception)

message
innerException

Glossary Item Box

Debug Assertion Failed: {0}

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal message As String, _
   ByVal innerException As Exception _
)
C#
public DebugAssertionFailedException(
   string message,
   Exception innerException
)

Parameters

message
innerException

Requirements

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

See Also

Reference

DebugAssertionFailedException Class
DebugAssertionFailedException Members
Overload List

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DebugAssertionFailedException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : DebugAssertionFailedException Class

Glossary Item Box

For a list of all members of this type, see DebugAssertionFailedException members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws Debug Assertion Failed: {0}
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

DebugAssertionFailedException Class
CSharpTest.Net Namespace

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > DebugAssertionFailedException Class : Assert Method

condition
message

Glossary Item Box

if(condition == false) throws Debug Assertion Failed: {0}

Syntax

Visual Basic (Declaration)
Public Shared Sub Assert( _
   ByVal condition As Boolean, _
   ByVal message As String _
)
C#
public static void Assert(
   bool condition,
   string message
)

Parameters

condition
message

Exceptions

Exception | Description
DebugAssertionFailedException | Exception class: DebugAssertionFailedException Debug Assertion Failed: {0}

Requirements

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

See Also

Reference

DebugAssertionFailedException Class
DebugAssertionFailedException Members

Source Code

Library/Resources.Designer.cs

Used By

DebugLocking.Dispose()
Boolean DebugLocking.TryRead(Int32)
DebugLocking.ReleaseRead()
Boolean DebugLocking.TryWrite(Int32)
DebugLocking.ReleaseWrite()
LockCounterFactory.GlobalAssertNoLocks()
DebugLockFactory.LocalAssertNoLocks()


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTableCorruptionException Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : LurchTableCorruptionException Class

Glossary Item Box

Exception class: LurchTableCorruptionException The LurchTable internal datastructure appears to be corrupted.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class LurchTableCorruptionException
   Inherits System.ApplicationException
C#
[SerializableAttribute()]
public class LurchTableCorruptionException : System.ApplicationException

Inheritance Hierarchy

System.Object
System.Exception
System.ApplicationException
CSharpTest.Net.LurchTableCorruptionException

Requirements

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

See Also

Reference

LurchTableCorruptionException Members
CSharpTest.Net Namespace

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LurchTableCorruptionException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : LurchTableCorruptionException Class

Glossary Item Box

The following tables list the members exposed by LurchTableCorruptionException.

Public Constructors

 | Name | Description
Public Constructor | LurchTableCorruptionException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws The LurchTable internal datastructure appears to be corrupted.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

LurchTableCorruptionException Class
CSharpTest.Net Namespace

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTableCorruptionException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > LurchTableCorruptionException Class : LurchTableCorruptionException Constructor

Glossary Item Box

Overload List

Overload | Description
LurchTableCorruptionException Constructor(SerializationInfo,StreamingContext) | Serialization constructor
LurchTableCorruptionException Constructor(Exception,Int32,String) | Constructs the exception from an hresult and message bypassing the message formatting
LurchTableCorruptionException Constructor() | The LurchTable internal datastructure appears to be corrupted.
LurchTableCorruptionException Constructor(Exception) | The LurchTable internal datastructure appears to be corrupted.

Requirements

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

See Also

Reference

LurchTableCorruptionException Class
LurchTableCorruptionException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTableCorruptionException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > LurchTableCorruptionException Class > LurchTableCorruptionException Constructor : LurchTableCorruptionException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Serialization constructor

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected LurchTableCorruptionException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

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

See Also

Reference

LurchTableCorruptionException Class
LurchTableCorruptionException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTableCorruptionException Constructor(Exception,Int32,String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > LurchTableCorruptionException Class > LurchTableCorruptionException Constructor : LurchTableCorruptionException Constructor(Exception,Int32,String)

innerException
hResult
message

Glossary Item Box

Constructs the exception from an hresult and message bypassing the message formatting

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal innerException As Exception, _
   ByVal hResult As Integer, _
   ByVal message As String _
)
C#
protected LurchTableCorruptionException(
   Exception innerException,
   int hResult,
   string message
)

Parameters

innerException
hResult
message

Requirements

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

See Also

Reference

LurchTableCorruptionException Class
LurchTableCorruptionException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTableCorruptionException Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > LurchTableCorruptionException Class > LurchTableCorruptionException Constructor : LurchTableCorruptionException Constructor()

Glossary Item Box

The LurchTable internal datastructure appears to be corrupted.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public LurchTableCorruptionException()

Requirements

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

See Also

Reference

LurchTableCorruptionException Class
LurchTableCorruptionException Members
Overload List

Used By

LurchTable.Initialize()
Boolean LurchTable.TryDequeue(Predicate>,KeyValuePair)
LurchTableCorruptionException.Assert(Boolean)

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTableCorruptionException Constructor(Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > LurchTableCorruptionException Class > LurchTableCorruptionException Constructor : LurchTableCorruptionException Constructor(Exception)

innerException

Glossary Item Box

The LurchTable internal datastructure appears to be corrupted.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal innerException As Exception _
)
C#
public LurchTableCorruptionException(
   Exception innerException
)

Parameters

innerException

Requirements

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

See Also

Reference

LurchTableCorruptionException Class
LurchTableCorruptionException Members
Overload List

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LurchTableCorruptionException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : LurchTableCorruptionException Class

Glossary Item Box

For a list of all members of this type, see LurchTableCorruptionException members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | if(condition == false) throws The LurchTable internal datastructure appears to be corrupted.
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

LurchTableCorruptionException Class
CSharpTest.Net Namespace

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace > LurchTableCorruptionException Class : Assert Method

condition

Glossary Item Box

if(condition == false) throws The LurchTable internal datastructure appears to be corrupted.

Syntax

Visual Basic (Declaration)
Public Shared Sub Assert( _
   ByVal condition As Boolean _
)
C#
public static void Assert(
   bool condition
)

Parameters

condition

Exceptions

Exception | Description
LurchTableCorruptionException | Exception class: LurchTableCorruptionException The LurchTable internal datastructure appears to be corrupted.

Requirements

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

See Also

Reference

LurchTableCorruptionException Class
LurchTableCorruptionException Members

Source Code

Library/Resources.Designer.cs


%%ItemTitle%%

CSharpTest.Net.AppConfig Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.AppConfig Namespace

Glossary Item Box

Classes

 | Class | Description
Class | UserSettingsSection | Provides a store for user settings in the same format as appSettings
Class | UserSettingsSubSection | Provides a store for user settings in the same format as appSettings
Class | UserSettingsSubSectionCollection | Provides a collection of name keyed sections that contain more key/value settings

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingsSection Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSection Class

Glossary Item Box

Provides a store for user settings in the same format as appSettings

Object Model

UserSettingsSection ClassUserSettingsSection ClassUserSettingsSubSectionCollection ClassUserSettingsSubSection ClassUserSettingsSection Class

Syntax

Visual Basic (Declaration)
Public NotInheritable Class UserSettingsSection
   Inherits System.Configuration.ConfigurationSection
C#
public sealed class UserSettingsSection : System.Configuration.ConfigurationSection

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings = UserSettingsSection.DefaultSettings;
Assert.IsNull(settings);

Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.IsNotNull(settings);
Assert.IsNotNull(settings.Settings);
Assert.IsNotNull(settings.Sections);

settings.Settings.Add("a", "b");
settings["1"] = "2";
Assert.AreEqual("2", settings["1"]);
settings["1"] = "3";
Assert.AreEqual("3", settings["1"]);
cfg.Save();

ConfigurationManager.RefreshSection("userSettings");
Assert.IsNotNull(UserSettingsSection.DefaultSettings);
Assert.AreEqual("b", UserSettingsSection.DefaultSettings["a"]);
Assert.IsNotNull(UserSettingsSection.UserSettings);
Assert.AreEqual("b", UserSettingsSection.UserSettings["a"]);

UserSettingsSection copy = new UserSettingsSection();

settings["a"] = "b";
settings["1"] = "2";
settings.Sections.Add("child.test").Settings.Add("AA", "BB");

copy.CopyFrom(settings);
Assert.AreEqual("b", settings["a"]);
Assert.AreEqual("2", settings["1"]);
Assert.AreEqual("BB", settings.Sections["child.test"]["AA"]);
VB.NET Copy Code
Dim settings As UserSettingsSection = UserSettingsSection.DefaultSettings
Assert.IsNull(settings)

Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.IsNotNull(settings)
Assert.IsNotNull(settings.Settings)
Assert.IsNotNull(settings.Sections)

settings.Settings.Add("a", "b")
settings("1") = "2"
Assert.AreEqual("2", settings("1"))
settings("1") = "3"
Assert.AreEqual("3", settings("1"))
cfg.Save()

ConfigurationManager.RefreshSection("userSettings")
Assert.IsNotNull(UserSettingsSection.DefaultSettings)
Assert.AreEqual("b", UserSettingsSection.DefaultSettings("a"))
Assert.IsNotNull(UserSettingsSection.UserSettings)
Assert.AreEqual("b", UserSettingsSection.UserSettings("a"))

Dim copy As New UserSettingsSection()

settings("a") = "b"
settings("1") = "2"
settings.Sections.Add("child.test").Settings.Add("AA", "BB")

copy.CopyFrom(settings)
Assert.AreEqual("b", settings("a"))
Assert.AreEqual("2", settings("1"))
Assert.AreEqual("BB", settings.Sections("child.test")("AA"))

Inheritance Hierarchy

System.Object
System.Configuration.ConfigurationElement
System.Configuration.ConfigurationSection
CSharpTest.Net.AppConfig.UserSettingsSection

Requirements

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

See Also

Reference

UserSettingsSection Members
CSharpTest.Net.AppConfig Namespace

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs

Used By

UserSettingsSection UserSettingsSection.UserSettingsFrom(Configuration)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
UserSettingsSection Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSection Class

Glossary Item Box

The following tables list the members exposed by UserSettingsSection.

Public Constructors

 | Name | Description
Public Constructor | UserSettingsSection Constructor |
Top

Public Fields

 | Name | Description
Public Field | SECTION_NAME | The name of the user section: userSettings
Top

Public Properties

 | Name | Description
static (Shared in Visual Basic) | DefaultSettings | if available, returns the default userSettings from the app's configuration file
Public Property | ElementInformation | Gets an System.Configuration.ElementInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Public Property | Item | Gets or sets a key/value pair in the collection of settings
Public Property | LockAllAttributesExcept | Gets the collection of locked attributes. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllElementsExcept | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAttributes | Gets the collection of locked attributes (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockElements | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockItem | Gets or sets a value indicating whether the element is locked. (Inherited from System.Configuration.ConfigurationElement)
Public Property | OriginalVersion | Describes the version of the application that originally wrote the configuration
Public Property | SectionInformation | Gets a System.Configuration.SectionInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationSection object. (Inherited from System.Configuration.ConfigurationSection)
Public Property | Sections | Retrieves a collection of named sections within the userSettings container
Public Property | Settings | Retrieves the collection of key/value settings
Public Property | UpgradedDate | The last date/time the settings were upgraded from the upgradedVersion
Public Property | UpgradedVersion | The version that the user settings were previously updagraded from
static (Shared in Visual Basic) | UserSettings | Retrieves the current UserSettingsSection from the default configuration
Top

Protected Properties

 | Name | Description
Protected Property | EvaluationContext | Gets the System.Configuration.ContextInformation object for the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Top

Public Methods

 | Name | Description
Public Method | CopyFrom | Deep copy of all settings from one configuration to another.
Public Method | IsReadOnly | Gets a value indicating whether the System.Configuration.ConfigurationElement object is read-only. (Inherited from System.Configuration.ConfigurationElement)
static (Shared in Visual Basic) | UpgradeUserSettings | Searches for old user settings from previous versions and copies them into the configuration provided.
static (Shared in Visual Basic) | UserSettingsFrom | Retrieves the current UserSettingsSection from the specified configuration, if none exists a new one is created. If a previous version of the userSettings exists they will be copied to the UserSettingsSection.
Top

Protected Methods

 | Name | Description
Protected Method | ListErrors | Adds the invalid-property errors in this System.Configuration.ConfigurationElement object, and in all subelements, to the passed list. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedAttribute | Overridden. Overloaded to ignore namespace declaration and useage so that we can identify the XSD file that should be used.
Protected Method | OnDeserializeUnrecognizedElement | Gets a value indicating whether an unknown element is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnRequiredPropertyNotFound | Throws an exception when a required property is not found. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PostDeserialize | Called after deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PreSerialize | Overridden. Overloaded to insert namespace declaration of xml schema and include our own schema file aut0magically. This is a development aid that is not enforced durring read of the xml.
Protected Method | SetPropertyValue | Sets a property to the specified value. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

UserSettingsSection Class
CSharpTest.Net.AppConfig Namespace

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs

Used By

UserSettingsSection UserSettingsSection.UserSettingsFrom(Configuration)


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingsSection Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : UserSettingsSection Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public UserSettingsSection()

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings = UserSettingsSection.DefaultSettings;
Assert.IsNull(settings);

Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.IsNotNull(settings);
Assert.IsNotNull(settings.Settings);
Assert.IsNotNull(settings.Sections);

settings.Settings.Add("a", "b");
settings["1"] = "2";
Assert.AreEqual("2", settings["1"]);
settings["1"] = "3";
Assert.AreEqual("3", settings["1"]);
cfg.Save();

ConfigurationManager.RefreshSection("userSettings");
Assert.IsNotNull(UserSettingsSection.DefaultSettings);
Assert.AreEqual("b", UserSettingsSection.DefaultSettings["a"]);
Assert.IsNotNull(UserSettingsSection.UserSettings);
Assert.AreEqual("b", UserSettingsSection.UserSettings["a"]);

UserSettingsSection copy = new UserSettingsSection();

settings["a"] = "b";
settings["1"] = "2";
settings.Sections.Add("child.test").Settings.Add("AA", "BB");

copy.CopyFrom(settings);
Assert.AreEqual("b", settings["a"]);
Assert.AreEqual("2", settings["1"]);
Assert.AreEqual("BB", settings.Sections["child.test"]["AA"]);
VB.NET Copy Code
Dim settings As UserSettingsSection = UserSettingsSection.DefaultSettings
Assert.IsNull(settings)

Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.IsNotNull(settings)
Assert.IsNotNull(settings.Settings)
Assert.IsNotNull(settings.Sections)

settings.Settings.Add("a", "b")
settings("1") = "2"
Assert.AreEqual("2", settings("1"))
settings("1") = "3"
Assert.AreEqual("3", settings("1"))
cfg.Save()

ConfigurationManager.RefreshSection("userSettings")
Assert.IsNotNull(UserSettingsSection.DefaultSettings)
Assert.AreEqual("b", UserSettingsSection.DefaultSettings("a"))
Assert.IsNotNull(UserSettingsSection.UserSettings)
Assert.AreEqual("b", UserSettingsSection.UserSettings("a"))

Dim copy As New UserSettingsSection()

settings("a") = "b"
settings("1") = "2"
settings.Sections.Add("child.test").Settings.Add("AA", "BB")

copy.CopyFrom(settings)
Assert.AreEqual("b", settings("a"))
Assert.AreEqual("2", settings("1"))
Assert.AreEqual("BB", settings.Sections("child.test")("AA"))

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Used By

UserSettingsSection UserSettingsSection.UserSettingsFrom(Configuration)

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
UserSettingsSection Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSection Class

Glossary Item Box

For a list of all members of this type, see UserSettingsSection members.

Public Methods

 | Name | Description
Public Method | CopyFrom | Deep copy of all settings from one configuration to another.
Public Method | IsReadOnly | Gets a value indicating whether the System.Configuration.ConfigurationElement object is read-only. (Inherited from System.Configuration.ConfigurationElement)
static (Shared in Visual Basic) | UpgradeUserSettings | Searches for old user settings from previous versions and copies them into the configuration provided.
static (Shared in Visual Basic) | UserSettingsFrom | Retrieves the current UserSettingsSection from the specified configuration, if none exists a new one is created. If a previous version of the userSettings exists they will be copied to the UserSettingsSection.
Top

Protected Methods

 | Name | Description
Protected Method | ListErrors | Adds the invalid-property errors in this System.Configuration.ConfigurationElement object, and in all subelements, to the passed list. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedAttribute | Overridden. Overloaded to ignore namespace declaration and useage so that we can identify the XSD file that should be used.
Protected Method | OnDeserializeUnrecognizedElement | Gets a value indicating whether an unknown element is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnRequiredPropertyNotFound | Throws an exception when a required property is not found. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PostDeserialize | Called after deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PreSerialize | Overridden. Overloaded to insert namespace declaration of xml schema and include our own schema file aut0magically. This is a development aid that is not enforced durring read of the xml.
Protected Method | SetPropertyValue | Sets a property to the specified value. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

UserSettingsSection Class
CSharpTest.Net.AppConfig Namespace

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs

Used By

UserSettingsSection UserSettingsSection.UserSettingsFrom(Configuration)


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyFrom Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : CopyFrom Method

otherSection

Glossary Item Box

Deep copy of all settings from one configuration to another.

Syntax

Visual Basic (Declaration)
Public Sub CopyFrom( _
   ByVal otherSection As UserSettingsSection _
)
C#
public void CopyFrom(
   UserSettingsSection otherSection
)

Parameters

otherSection

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings = UserSettingsSection.DefaultSettings;
Assert.IsNull(settings);

Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.IsNotNull(settings);
Assert.IsNotNull(settings.Settings);
Assert.IsNotNull(settings.Sections);

settings.Settings.Add("a", "b");
settings["1"] = "2";
Assert.AreEqual("2", settings["1"]);
settings["1"] = "3";
Assert.AreEqual("3", settings["1"]);
cfg.Save();

ConfigurationManager.RefreshSection("userSettings");
Assert.IsNotNull(UserSettingsSection.DefaultSettings);
Assert.AreEqual("b", UserSettingsSection.DefaultSettings["a"]);
Assert.IsNotNull(UserSettingsSection.UserSettings);
Assert.AreEqual("b", UserSettingsSection.UserSettings["a"]);

UserSettingsSection copy = new UserSettingsSection();

settings["a"] = "b";
settings["1"] = "2";
settings.Sections.Add("child.test").Settings.Add("AA", "BB");

copy.CopyFrom(settings);
Assert.AreEqual("b", settings["a"]);
Assert.AreEqual("2", settings["1"]);
Assert.AreEqual("BB", settings.Sections["child.test"]["AA"]);
VB.NET Copy Code
Dim settings As UserSettingsSection = UserSettingsSection.DefaultSettings
Assert.IsNull(settings)

Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.IsNotNull(settings)
Assert.IsNotNull(settings.Settings)
Assert.IsNotNull(settings.Sections)

settings.Settings.Add("a", "b")
settings("1") = "2"
Assert.AreEqual("2", settings("1"))
settings("1") = "3"
Assert.AreEqual("3", settings("1"))
cfg.Save()

ConfigurationManager.RefreshSection("userSettings")
Assert.IsNotNull(UserSettingsSection.DefaultSettings)
Assert.AreEqual("b", UserSettingsSection.DefaultSettings("a"))
Assert.IsNotNull(UserSettingsSection.UserSettings)
Assert.AreEqual("b", UserSettingsSection.UserSettings("a"))

Dim copy As New UserSettingsSection()

settings("a") = "b"
settings("1") = "2"
settings.Sections.Add("child.test").Settings.Add("AA", "BB")

copy.CopyFrom(settings)
Assert.AreEqual("b", settings("a"))
Assert.AreEqual("2", settings("1"))
Assert.AreEqual("BB", settings.Sections("child.test")("AA"))

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnDeserializeUnrecognizedAttribute Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : OnDeserializeUnrecognizedAttribute Method

name
value

Glossary Item Box

Overloaded to ignore namespace declaration and useage so that we can identify the XSD file that should be used.

Syntax

Visual Basic (Declaration)
Protected Overrides NotOverridable Function OnDeserializeUnrecognizedAttribute( _
   ByVal name As String, _
   ByVal value As String _
) As Boolean
C#
protected override bool OnDeserializeUnrecognizedAttribute(
   string name,
   string value
)

Parameters

name
value

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members
Base Implementation in OnDeserializeUnrecognizedAttribute


%%PageItemTitle%%

[image]
CSharpTest.Net
PreSerialize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : PreSerialize Method

writer

Glossary Item Box

Overloaded to insert namespace declaration of xml schema and include our own schema file aut0magically. This is a development aid that is not enforced durring read of the xml.

Syntax

Visual Basic (Declaration)
Protected Overrides NotOverridable Sub PreSerialize( _
   ByVal writer As XmlWriter _
)
C#
protected override void PreSerialize(
   XmlWriter writer
)

Parameters

writer

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members
Base Implementation in PreSerialize


%%PageItemTitle%%

[image]
CSharpTest.Net
UpgradeUserSettings Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : UpgradeUserSettings Method

config
The configuration to inspect for previous versions
settings
The destination UserSettingsSection object

Glossary Item Box

Searches for old user settings from previous versions and copies them into the configuration provided.

Syntax

Visual Basic (Declaration)
Public Shared Sub UpgradeUserSettings( _
   ByVal config As Configuration, _
   ByVal settings As UserSettingsSection _
)
C#
public static void UpgradeUserSettings(
   Configuration config,
   UserSettingsSection settings
)

Parameters

config
The configuration to inspect for previous versions
settings
The destination UserSettingsSection object

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs

Used By

UserSettingsSection UserSettingsSection.UserSettingsFrom(Configuration)


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingsFrom Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : UserSettingsFrom Method

config

Glossary Item Box

Retrieves the current UserSettingsSection from the specified configuration, if none exists a new one is created. If a previous version of the userSettings exists they will be copied to the UserSettingsSection.

Syntax

Visual Basic (Declaration)
Public Shared Function UserSettingsFrom( _
   ByVal config As Configuration _
) As UserSettingsSection
C#
public static UserSettingsSection UserSettingsFrom(
   Configuration config
)

Parameters

config

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
UserSettingsSection Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSection Class

Glossary Item Box

For a list of all members of this type, see UserSettingsSection members.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | DefaultSettings | if available, returns the default userSettings from the app's configuration file
Public Property | ElementInformation | Gets an System.Configuration.ElementInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Public Property | Item | Gets or sets a key/value pair in the collection of settings
Public Property | LockAllAttributesExcept | Gets the collection of locked attributes. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllElementsExcept | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAttributes | Gets the collection of locked attributes (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockElements | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockItem | Gets or sets a value indicating whether the element is locked. (Inherited from System.Configuration.ConfigurationElement)
Public Property | OriginalVersion | Describes the version of the application that originally wrote the configuration
Public Property | SectionInformation | Gets a System.Configuration.SectionInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationSection object. (Inherited from System.Configuration.ConfigurationSection)
Public Property | Sections | Retrieves a collection of named sections within the userSettings container
Public Property | Settings | Retrieves the collection of key/value settings
Public Property | UpgradedDate | The last date/time the settings were upgraded from the upgradedVersion
Public Property | UpgradedVersion | The version that the user settings were previously updagraded from
static (Shared in Visual Basic) | UserSettings | Retrieves the current UserSettingsSection from the default configuration
Top

Protected Properties

 | Name | Description
Protected Property | EvaluationContext | Gets the System.Configuration.ContextInformation object for the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

UserSettingsSection Class
CSharpTest.Net.AppConfig Namespace

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs

Used By

UserSettingsSection UserSettingsSection.UserSettingsFrom(Configuration)


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultSettings Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : DefaultSettings Property

Glossary Item Box

if available, returns the default userSettings from the app's configuration file

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property DefaultSettings As UserSettingsSection
C#
public static UserSettingsSection DefaultSettings {get;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings = UserSettingsSection.DefaultSettings;
Assert.IsNull(settings);

Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.IsNotNull(settings);
Assert.IsNotNull(settings.Settings);
Assert.IsNotNull(settings.Sections);

settings.Settings.Add("a", "b");
settings["1"] = "2";
Assert.AreEqual("2", settings["1"]);
settings["1"] = "3";
Assert.AreEqual("3", settings["1"]);
cfg.Save();

ConfigurationManager.RefreshSection("userSettings");
Assert.IsNotNull(UserSettingsSection.DefaultSettings);
Assert.AreEqual("b", UserSettingsSection.DefaultSettings["a"]);
Assert.IsNotNull(UserSettingsSection.UserSettings);
Assert.AreEqual("b", UserSettingsSection.UserSettings["a"]);

UserSettingsSection copy = new UserSettingsSection();

settings["a"] = "b";
settings["1"] = "2";
settings.Sections.Add("child.test").Settings.Add("AA", "BB");

copy.CopyFrom(settings);
Assert.AreEqual("b", settings["a"]);
Assert.AreEqual("2", settings["1"]);
Assert.AreEqual("BB", settings.Sections["child.test"]["AA"]);
VB.NET Copy Code
Dim settings As UserSettingsSection = UserSettingsSection.DefaultSettings
Assert.IsNull(settings)

Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.IsNotNull(settings)
Assert.IsNotNull(settings.Settings)
Assert.IsNotNull(settings.Sections)

settings.Settings.Add("a", "b")
settings("1") = "2"
Assert.AreEqual("2", settings("1"))
settings("1") = "3"
Assert.AreEqual("3", settings("1"))
cfg.Save()

ConfigurationManager.RefreshSection("userSettings")
Assert.IsNotNull(UserSettingsSection.DefaultSettings)
Assert.AreEqual("b", UserSettingsSection.DefaultSettings("a"))
Assert.IsNotNull(UserSettingsSection.UserSettings)
Assert.AreEqual("b", UserSettingsSection.UserSettings("a"))

Dim copy As New UserSettingsSection()

settings("a") = "b"
settings("1") = "2"
settings.Sections.Add("child.test").Settings.Add("AA", "BB")

copy.CopyFrom(settings)
Assert.AreEqual("b", settings("a"))
Assert.AreEqual("2", settings("1"))
Assert.AreEqual("BB", settings.Sections("child.test")("AA"))

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item(String) Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : Item(String) Property

name

Glossary Item Box

Gets or sets a key/value pair in the collection of settings

Syntax

Visual Basic (Declaration)
Public Overloads Shadows Property Item( _
   ByVal name As String _
) As String
C#
public new string Item(
   string name
) {get; set;}

Parameters

name

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OriginalVersion Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : OriginalVersion Property

Glossary Item Box

Describes the version of the application that originally wrote the configuration

Syntax

Visual Basic (Declaration)
Public Property OriginalVersion As String
C#
public string OriginalVersion {get; set;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings;
Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
settings["a"] = "b";

string origPath = cfg.FilePath;
string dir = Path.GetDirectoryName(cfg.FilePath);
string version = Path.GetFileName(dir).Trim('\\');
dir = dir.TrimEnd('\\') + "1";

Directory.CreateDirectory(dir);
cfg.SaveAs(Path.Combine(dir, Path.GetFileName(origPath)));
File.Delete(origPath);

ConfigurationManager.RefreshSection("userSettings");
cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));
settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.AreEqual("b", settings["a"]);

Assert.AreEqual(version + "1", settings.OriginalVersion);
Assert.AreEqual(version + "1", settings.UpgradedVersion);
string date = DateTime.Now.ToString("yyyy-MM-dd");
Assert.AreEqual(date, settings.UpgradedDate.Substring(0, date.Length));
VB.NET Copy Code
Dim settings As UserSettingsSection
Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
settings("a") = "b"

Dim origPath As String = cfg.FilePath
Dim dir As String = Path.GetDirectoryName(cfg.FilePath)
Dim version As String = Path.GetFileName(dir).Trim("\"C)
dir = dir.TrimEnd("\"C) + "1"

Directory.CreateDirectory(dir)
cfg.SaveAs(Path.Combine(dir, Path.GetFileName(origPath)))
File.Delete(origPath)

ConfigurationManager.RefreshSection("userSettings")
cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))
settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.AreEqual("b", settings("a"))

Assert.AreEqual(version + "1", settings.OriginalVersion)
Assert.AreEqual(version + "1", settings.UpgradedVersion)
Dim [date] As String = DateTime.Now.ToString("yyyy-MM-dd")
Assert.AreEqual([date], settings.UpgradedDate.Substring(0, [date].Length))

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs
Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Sections Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : Sections Property

Glossary Item Box

Retrieves a collection of named sections within the userSettings container

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Sections As UserSettingsSubSectionCollection
C#
public UserSettingsSubSectionCollection Sections {get;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members
UserSettingsSubSectionCollection

Used By

UserSettingsSection.CopyFrom(UserSettingsSection)

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Settings Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : Settings Property

Glossary Item Box

Retrieves the collection of key/value settings

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Settings As KeyValueConfigurationCollection
C#
public KeyValueConfigurationCollection Settings {get;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings = UserSettingsSection.DefaultSettings;
Assert.IsNull(settings);

Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.IsNotNull(settings);
Assert.IsNotNull(settings.Settings);
Assert.IsNotNull(settings.Sections);

settings.Settings.Add("a", "b");
settings["1"] = "2";
Assert.AreEqual("2", settings["1"]);
settings["1"] = "3";
Assert.AreEqual("3", settings["1"]);
cfg.Save();

ConfigurationManager.RefreshSection("userSettings");
Assert.IsNotNull(UserSettingsSection.DefaultSettings);
Assert.AreEqual("b", UserSettingsSection.DefaultSettings["a"]);
Assert.IsNotNull(UserSettingsSection.UserSettings);
Assert.AreEqual("b", UserSettingsSection.UserSettings["a"]);

UserSettingsSection copy = new UserSettingsSection();

settings["a"] = "b";
settings["1"] = "2";
settings.Sections.Add("child.test").Settings.Add("AA", "BB");

copy.CopyFrom(settings);
Assert.AreEqual("b", settings["a"]);
Assert.AreEqual("2", settings["1"]);
Assert.AreEqual("BB", settings.Sections["child.test"]["AA"]);
VB.NET Copy Code
Dim settings As UserSettingsSection = UserSettingsSection.DefaultSettings
Assert.IsNull(settings)

Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.IsNotNull(settings)
Assert.IsNotNull(settings.Settings)
Assert.IsNotNull(settings.Sections)

settings.Settings.Add("a", "b")
settings("1") = "2"
Assert.AreEqual("2", settings("1"))
settings("1") = "3"
Assert.AreEqual("3", settings("1"))
cfg.Save()

ConfigurationManager.RefreshSection("userSettings")
Assert.IsNotNull(UserSettingsSection.DefaultSettings)
Assert.AreEqual("b", UserSettingsSection.DefaultSettings("a"))
Assert.IsNotNull(UserSettingsSection.UserSettings)
Assert.AreEqual("b", UserSettingsSection.UserSettings("a"))

Dim copy As New UserSettingsSection()

settings("a") = "b"
settings("1") = "2"
settings.Sections.Add("child.test").Settings.Add("AA", "BB")

copy.CopyFrom(settings)
Assert.AreEqual("b", settings("a"))
Assert.AreEqual("2", settings("1"))
Assert.AreEqual("BB", settings.Sections("child.test")("AA"))

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Used By

UserSettingsSection.CopyFrom(UserSettingsSection)

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UpgradedDate Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : UpgradedDate Property

Glossary Item Box

The last date/time the settings were upgraded from the upgradedVersion

Syntax

Visual Basic (Declaration)
Public Property UpgradedDate As String
C#
public string UpgradedDate {get; set;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings;
Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
settings["a"] = "b";

string origPath = cfg.FilePath;
string dir = Path.GetDirectoryName(cfg.FilePath);
string version = Path.GetFileName(dir).Trim('\\');
dir = dir.TrimEnd('\\') + "1";

Directory.CreateDirectory(dir);
cfg.SaveAs(Path.Combine(dir, Path.GetFileName(origPath)));
File.Delete(origPath);

ConfigurationManager.RefreshSection("userSettings");
cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));
settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.AreEqual("b", settings["a"]);

Assert.AreEqual(version + "1", settings.OriginalVersion);
Assert.AreEqual(version + "1", settings.UpgradedVersion);
string date = DateTime.Now.ToString("yyyy-MM-dd");
Assert.AreEqual(date, settings.UpgradedDate.Substring(0, date.Length));
VB.NET Copy Code
Dim settings As UserSettingsSection
Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
settings("a") = "b"

Dim origPath As String = cfg.FilePath
Dim dir As String = Path.GetDirectoryName(cfg.FilePath)
Dim version As String = Path.GetFileName(dir).Trim("\"C)
dir = dir.TrimEnd("\"C) + "1"

Directory.CreateDirectory(dir)
cfg.SaveAs(Path.Combine(dir, Path.GetFileName(origPath)))
File.Delete(origPath)

ConfigurationManager.RefreshSection("userSettings")
cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))
settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.AreEqual("b", settings("a"))

Assert.AreEqual(version + "1", settings.OriginalVersion)
Assert.AreEqual(version + "1", settings.UpgradedVersion)
Dim [date] As String = DateTime.Now.ToString("yyyy-MM-dd")
Assert.AreEqual([date], settings.UpgradedDate.Substring(0, [date].Length))

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs
Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UpgradedVersion Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : UpgradedVersion Property

Glossary Item Box

The version that the user settings were previously updagraded from

Syntax

Visual Basic (Declaration)
Public Property UpgradedVersion As String
C#
public string UpgradedVersion {get; set;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings;
Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
settings["a"] = "b";

string origPath = cfg.FilePath;
string dir = Path.GetDirectoryName(cfg.FilePath);
string version = Path.GetFileName(dir).Trim('\\');
dir = dir.TrimEnd('\\') + "1";

Directory.CreateDirectory(dir);
cfg.SaveAs(Path.Combine(dir, Path.GetFileName(origPath)));
File.Delete(origPath);

ConfigurationManager.RefreshSection("userSettings");
cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));
settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.AreEqual("b", settings["a"]);

Assert.AreEqual(version + "1", settings.OriginalVersion);
Assert.AreEqual(version + "1", settings.UpgradedVersion);
string date = DateTime.Now.ToString("yyyy-MM-dd");
Assert.AreEqual(date, settings.UpgradedDate.Substring(0, date.Length));
VB.NET Copy Code
Dim settings As UserSettingsSection
Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
settings("a") = "b"

Dim origPath As String = cfg.FilePath
Dim dir As String = Path.GetDirectoryName(cfg.FilePath)
Dim version As String = Path.GetFileName(dir).Trim("\"C)
dir = dir.TrimEnd("\"C) + "1"

Directory.CreateDirectory(dir)
cfg.SaveAs(Path.Combine(dir, Path.GetFileName(origPath)))
File.Delete(origPath)

ConfigurationManager.RefreshSection("userSettings")
cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))
settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.AreEqual("b", settings("a"))

Assert.AreEqual(version + "1", settings.OriginalVersion)
Assert.AreEqual(version + "1", settings.UpgradedVersion)
Dim [date] As String = DateTime.Now.ToString("yyyy-MM-dd")
Assert.AreEqual([date], settings.UpgradedDate.Substring(0, [date].Length))

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs
Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettings Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : UserSettings Property

Glossary Item Box

Retrieves the current UserSettingsSection from the default configuration

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property UserSettings As UserSettingsSection
C#
public static UserSettingsSection UserSettings {get;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings = UserSettingsSection.DefaultSettings;
Assert.IsNull(settings);

Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.IsNotNull(settings);
Assert.IsNotNull(settings.Settings);
Assert.IsNotNull(settings.Sections);

settings.Settings.Add("a", "b");
settings["1"] = "2";
Assert.AreEqual("2", settings["1"]);
settings["1"] = "3";
Assert.AreEqual("3", settings["1"]);
cfg.Save();

ConfigurationManager.RefreshSection("userSettings");
Assert.IsNotNull(UserSettingsSection.DefaultSettings);
Assert.AreEqual("b", UserSettingsSection.DefaultSettings["a"]);
Assert.IsNotNull(UserSettingsSection.UserSettings);
Assert.AreEqual("b", UserSettingsSection.UserSettings["a"]);

UserSettingsSection copy = new UserSettingsSection();

settings["a"] = "b";
settings["1"] = "2";
settings.Sections.Add("child.test").Settings.Add("AA", "BB");

copy.CopyFrom(settings);
Assert.AreEqual("b", settings["a"]);
Assert.AreEqual("2", settings["1"]);
Assert.AreEqual("BB", settings.Sections["child.test"]["AA"]);
VB.NET Copy Code
Dim settings As UserSettingsSection = UserSettingsSection.DefaultSettings
Assert.IsNull(settings)

Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.IsNotNull(settings)
Assert.IsNotNull(settings.Settings)
Assert.IsNotNull(settings.Sections)

settings.Settings.Add("a", "b")
settings("1") = "2"
Assert.AreEqual("2", settings("1"))
settings("1") = "3"
Assert.AreEqual("3", settings("1"))
cfg.Save()

ConfigurationManager.RefreshSection("userSettings")
Assert.IsNotNull(UserSettingsSection.DefaultSettings)
Assert.AreEqual("b", UserSettingsSection.DefaultSettings("a"))
Assert.IsNotNull(UserSettingsSection.UserSettings)
Assert.AreEqual("b", UserSettingsSection.UserSettings("a"))

Dim copy As New UserSettingsSection()

settings("a") = "b"
settings("1") = "2"
settings.Sections.Add("child.test").Settings.Add("AA", "BB")

copy.CopyFrom(settings)
Assert.AreEqual("b", settings("a"))
Assert.AreEqual("2", settings("1"))
Assert.AreEqual("BB", settings.Sections("child.test")("AA"))

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
UserSettingsSection Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSection Class

Glossary Item Box

For a list of all members of this type, see UserSettingsSection members.

Public Fields

 | Name | Description
Public Field | SECTION_NAME | The name of the user section: userSettings
Top

See Also

Reference

UserSettingsSection Class
CSharpTest.Net.AppConfig Namespace

Source Code

Library/AppConfig/UserSettingsSection.Upgrade.cs

Used By

UserSettingsSection UserSettingsSection.UserSettingsFrom(Configuration)


%%PageItemTitle%%

[image]
CSharpTest.Net
SECTION_NAME Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : SECTION_NAME Field

Glossary Item Box

The name of the user section: userSettings

Syntax

Visual Basic (Declaration)
Public Const SECTION_NAME As String
C#
public const string SECTION_NAME

Requirements

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

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingsSubSection Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSubSection Class

Glossary Item Box

Provides a store for user settings in the same format as appSettings

Syntax

Visual Basic (Declaration)
Public NotInheritable Class UserSettingsSubSection
   Inherits System.Configuration.ConfigurationElement
C#
public sealed class UserSettingsSubSection : System.Configuration.ConfigurationElement

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection section = new UserSettingsSubSection();

section.Name = "a";
Assert.AreEqual("a", section.Name);

Assert.IsNotNull(section.Settings);

Assert.IsNull(section["a"]);
section["a"] = "b";
Assert.AreEqual("b", section["a"]);
section["a"] = "c";
Assert.AreEqual("c", section["a"]);

UserSettingsSubSection section2 = new UserSettingsSubSection();
section2.Name = "b";
Assert.AreNotEqual(0, section.CompareTo(section2));
section2.Name = "a";
Assert.AreEqual(0, section.CompareTo(section2));

section["a"] = "b";
section.Settings.Add("hello", "world");
section2.Settings.Add("hello", "universe");
Assert.AreEqual("universe", section2["hello"]);

section2.CopyFrom(section);
Assert.AreEqual("b", section2["a"]);
Assert.AreEqual("world", section2["hello"]);
VB.NET Copy Code
Dim section As New UserSettingsSubSection()

section.Name = "a"
Assert.AreEqual("a", section.Name)

Assert.IsNotNull(section.Settings)

Assert.IsNull(section("a"))
section("a") = "b"
Assert.AreEqual("b", section("a"))
section("a") = "c"
Assert.AreEqual("c", section("a"))

Dim section2 As New UserSettingsSubSection()
section2.Name = "b"
Assert.AreNotEqual(0, section.CompareTo(section2))
section2.Name = "a"
Assert.AreEqual(0, section.CompareTo(section2))

section("a") = "b"
section.Settings.Add("hello", "world")
section2.Settings.Add("hello", "universe")
Assert.AreEqual("universe", section2("hello"))

section2.CopyFrom(section)
Assert.AreEqual("b", section2("a"))
Assert.AreEqual("world", section2("hello"))

Inheritance Hierarchy

System.Object
System.Configuration.ConfigurationElement
CSharpTest.Net.AppConfig.UserSettingsSubSection

Requirements

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

See Also

Reference

UserSettingsSubSection Members
CSharpTest.Net.AppConfig Namespace
UserSettingsSubSection UserSettingsSubSectionCollection.Item

Source Code

Library/AppConfig/UserSettingsSubSection.cs

Used By

UserSettingsSubSection UserSettingsSubSectionCollection.Add(String)
UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
UserSettingsSubSection Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSubSection Class

Glossary Item Box

The following tables list the members exposed by UserSettingsSubSection.

Public Constructors

 | Name | Description
Public Constructor | UserSettingsSubSection Constructor |
Top

Public Properties

 | Name | Description
Public Property | ElementInformation | Gets an System.Configuration.ElementInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Public Property | Item | Gets or sets a key/value pair in the collection of settings
Public Property | LockAllAttributesExcept | Gets the collection of locked attributes. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllElementsExcept | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAttributes | Gets the collection of locked attributes (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockElements | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockItem | Gets or sets a value indicating whether the element is locked. (Inherited from System.Configuration.ConfigurationElement)
Public Property | Name | Returns the key name of the section within the userSettings collection
Public Property | Settings | Retrieves the collection of key/value settings
Top

Protected Properties

 | Name | Description
Protected Property | EvaluationContext | Gets the System.Configuration.ContextInformation object for the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Top

Public Methods

 | Name | Description
Public Method | CompareTo | Provides key comparison between two sections
Public Method | CopyFrom | Deep copy of all settings from one configuration to another.
Public Method | IsReadOnly | Gets a value indicating whether the System.Configuration.ConfigurationElement object is read-only. (Inherited from System.Configuration.ConfigurationElement)
Top

Protected Methods

 | Name | Description
Protected Method | ListErrors | Adds the invalid-property errors in this System.Configuration.ConfigurationElement object, and in all subelements, to the passed list. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedAttribute | Gets a value indicating whether an unknown attribute is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedElement | Gets a value indicating whether an unknown element is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnRequiredPropertyNotFound | Throws an exception when a required property is not found. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PostDeserialize | Called after deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PreSerialize | Called before serialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | SetPropertyValue | Sets a property to the specified value. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

UserSettingsSubSection Class
CSharpTest.Net.AppConfig Namespace
UserSettingsSubSection UserSettingsSubSectionCollection.Item

Source Code

Library/AppConfig/UserSettingsSubSection.cs

Used By

UserSettingsSubSection UserSettingsSubSectionCollection.Add(String)
UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingsSubSection Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSection Class : UserSettingsSubSection Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public UserSettingsSubSection()

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection section = new UserSettingsSubSection();

section.Name = "a";
Assert.AreEqual("a", section.Name);

Assert.IsNotNull(section.Settings);

Assert.IsNull(section["a"]);
section["a"] = "b";
Assert.AreEqual("b", section["a"]);
section["a"] = "c";
Assert.AreEqual("c", section["a"]);

UserSettingsSubSection section2 = new UserSettingsSubSection();
section2.Name = "b";
Assert.AreNotEqual(0, section.CompareTo(section2));
section2.Name = "a";
Assert.AreEqual(0, section.CompareTo(section2));

section["a"] = "b";
section.Settings.Add("hello", "world");
section2.Settings.Add("hello", "universe");
Assert.AreEqual("universe", section2["hello"]);

section2.CopyFrom(section);
Assert.AreEqual("b", section2["a"]);
Assert.AreEqual("world", section2["hello"]);
VB.NET Copy Code
Dim section As New UserSettingsSubSection()

section.Name = "a"
Assert.AreEqual("a", section.Name)

Assert.IsNotNull(section.Settings)

Assert.IsNull(section("a"))
section("a") = "b"
Assert.AreEqual("b", section("a"))
section("a") = "c"
Assert.AreEqual("c", section("a"))

Dim section2 As New UserSettingsSubSection()
section2.Name = "b"
Assert.AreNotEqual(0, section.CompareTo(section2))
section2.Name = "a"
Assert.AreEqual(0, section.CompareTo(section2))

section("a") = "b"
section.Settings.Add("hello", "world")
section2.Settings.Add("hello", "universe")
Assert.AreEqual("universe", section2("hello"))

section2.CopyFrom(section)
Assert.AreEqual("b", section2("a"))
Assert.AreEqual("world", section2("hello"))

Requirements

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

See Also

Reference

UserSettingsSubSection Class
UserSettingsSubSection Members

Source Code

Library/AppConfig/UserSettingsSubSection.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
UserSettingsSubSection Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSubSection Class

Glossary Item Box

For a list of all members of this type, see UserSettingsSubSection members.

Public Methods

 | Name | Description
Public Method | CompareTo | Provides key comparison between two sections
Public Method | CopyFrom | Deep copy of all settings from one configuration to another.
Public Method | IsReadOnly | Gets a value indicating whether the System.Configuration.ConfigurationElement object is read-only. (Inherited from System.Configuration.ConfigurationElement)
Top

Protected Methods

 | Name | Description
Protected Method | ListErrors | Adds the invalid-property errors in this System.Configuration.ConfigurationElement object, and in all subelements, to the passed list. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedAttribute | Gets a value indicating whether an unknown attribute is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedElement | Gets a value indicating whether an unknown element is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnRequiredPropertyNotFound | Throws an exception when a required property is not found. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PostDeserialize | Called after deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PreSerialize | Called before serialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | SetPropertyValue | Sets a property to the specified value. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

UserSettingsSubSection Class
CSharpTest.Net.AppConfig Namespace
UserSettingsSubSection UserSettingsSubSectionCollection.Item

Source Code

Library/AppConfig/UserSettingsSubSection.cs

Used By

UserSettingsSubSection UserSettingsSubSectionCollection.Add(String)
UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)


%%PageItemTitle%%

[image]
CSharpTest.Net
CompareTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSection Class : CompareTo Method

other

Glossary Item Box

Provides key comparison between two sections

Syntax

Visual Basic (Declaration)
Public Function CompareTo( _
   ByVal other As UserSettingsSubSection _
) As Integer
C#
public int CompareTo(
   UserSettingsSubSection other
)

Parameters

other

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection section = new UserSettingsSubSection();

section.Name = "a";
Assert.AreEqual("a", section.Name);

Assert.IsNotNull(section.Settings);

Assert.IsNull(section["a"]);
section["a"] = "b";
Assert.AreEqual("b", section["a"]);
section["a"] = "c";
Assert.AreEqual("c", section["a"]);

UserSettingsSubSection section2 = new UserSettingsSubSection();
section2.Name = "b";
Assert.AreNotEqual(0, section.CompareTo(section2));
section2.Name = "a";
Assert.AreEqual(0, section.CompareTo(section2));

section["a"] = "b";
section.Settings.Add("hello", "world");
section2.Settings.Add("hello", "universe");
Assert.AreEqual("universe", section2["hello"]);

section2.CopyFrom(section);
Assert.AreEqual("b", section2["a"]);
Assert.AreEqual("world", section2["hello"]);
VB.NET Copy Code
Dim section As New UserSettingsSubSection()

section.Name = "a"
Assert.AreEqual("a", section.Name)

Assert.IsNotNull(section.Settings)

Assert.IsNull(section("a"))
section("a") = "b"
Assert.AreEqual("b", section("a"))
section("a") = "c"
Assert.AreEqual("c", section("a"))

Dim section2 As New UserSettingsSubSection()
section2.Name = "b"
Assert.AreNotEqual(0, section.CompareTo(section2))
section2.Name = "a"
Assert.AreEqual(0, section.CompareTo(section2))

section("a") = "b"
section.Settings.Add("hello", "world")
section2.Settings.Add("hello", "universe")
Assert.AreEqual("universe", section2("hello"))

section2.CopyFrom(section)
Assert.AreEqual("b", section2("a"))
Assert.AreEqual("world", section2("hello"))

Requirements

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

See Also

Reference

UserSettingsSubSection Class
UserSettingsSubSection Members

Source Code

Library/AppConfig/UserSettingsSubSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyFrom Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSection Class : CopyFrom Method

other

Glossary Item Box

Deep copy of all settings from one configuration to another.

Syntax

Visual Basic (Declaration)
Public Sub CopyFrom( _
   ByVal other As UserSettingsSubSection _
)
C#
public void CopyFrom(
   UserSettingsSubSection other
)

Parameters

other

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection section = new UserSettingsSubSection();

section.Name = "a";
Assert.AreEqual("a", section.Name);

Assert.IsNotNull(section.Settings);

Assert.IsNull(section["a"]);
section["a"] = "b";
Assert.AreEqual("b", section["a"]);
section["a"] = "c";
Assert.AreEqual("c", section["a"]);

UserSettingsSubSection section2 = new UserSettingsSubSection();
section2.Name = "b";
Assert.AreNotEqual(0, section.CompareTo(section2));
section2.Name = "a";
Assert.AreEqual(0, section.CompareTo(section2));

section["a"] = "b";
section.Settings.Add("hello", "world");
section2.Settings.Add("hello", "universe");
Assert.AreEqual("universe", section2["hello"]);

section2.CopyFrom(section);
Assert.AreEqual("b", section2["a"]);
Assert.AreEqual("world", section2["hello"]);
VB.NET Copy Code
Dim section As New UserSettingsSubSection()

section.Name = "a"
Assert.AreEqual("a", section.Name)

Assert.IsNotNull(section.Settings)

Assert.IsNull(section("a"))
section("a") = "b"
Assert.AreEqual("b", section("a"))
section("a") = "c"
Assert.AreEqual("c", section("a"))

Dim section2 As New UserSettingsSubSection()
section2.Name = "b"
Assert.AreNotEqual(0, section.CompareTo(section2))
section2.Name = "a"
Assert.AreEqual(0, section.CompareTo(section2))

section("a") = "b"
section.Settings.Add("hello", "world")
section2.Settings.Add("hello", "universe")
Assert.AreEqual("universe", section2("hello"))

section2.CopyFrom(section)
Assert.AreEqual("b", section2("a"))
Assert.AreEqual("world", section2("hello"))

Requirements

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

See Also

Reference

UserSettingsSubSection Class
UserSettingsSubSection Members

Source Code

Library/AppConfig/UserSettingsSubSection.cs

Used By

UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
UserSettingsSubSection Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSubSection Class

Glossary Item Box

For a list of all members of this type, see UserSettingsSubSection members.

Public Properties

 | Name | Description
Public Property | ElementInformation | Gets an System.Configuration.ElementInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Public Property | Item | Gets or sets a key/value pair in the collection of settings
Public Property | LockAllAttributesExcept | Gets the collection of locked attributes. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllElementsExcept | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAttributes | Gets the collection of locked attributes (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockElements | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockItem | Gets or sets a value indicating whether the element is locked. (Inherited from System.Configuration.ConfigurationElement)
Public Property | Name | Returns the key name of the section within the userSettings collection
Public Property | Settings | Retrieves the collection of key/value settings
Top

Protected Properties

 | Name | Description
Protected Property | EvaluationContext | Gets the System.Configuration.ContextInformation object for the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

UserSettingsSubSection Class
CSharpTest.Net.AppConfig Namespace
UserSettingsSubSection UserSettingsSubSectionCollection.Item

Source Code

Library/AppConfig/UserSettingsSubSection.cs

Used By

UserSettingsSubSection UserSettingsSubSectionCollection.Add(String)
UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)


%%PageItemTitle%%

[image]
CSharpTest.Net
Item(String) Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSection Class : Item(String) Property

name

Glossary Item Box

Gets or sets a key/value pair in the collection of settings

Syntax

Visual Basic (Declaration)
Public Overloads Shadows Property Item( _
   ByVal name As String _
) As String
C#
public new string Item(
   string name
) {get; set;}

Parameters

name

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

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

See Also

Reference

UserSettingsSubSection Class
UserSettingsSubSection Members

Source Code

Library/AppConfig/UserSettingsSubSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSection Class : Name Property

Glossary Item Box

Returns the key name of the section within the userSettings collection

Syntax

Visual Basic (Declaration)
Public Property Name As String
C#
public string Name {get; set;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection a;
UserSettingsSubSectionCollection coll1 = new UserSettingsSubSectionCollection();
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType);

Assert.IsNull(coll1["a"]);
a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

coll1.Remove("a");
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);
coll1.Clear();
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

UserSettingsSubSectionCollection other = new UserSettingsSubSectionCollection();
other.CopyFrom(coll1);

Assert.IsNotNull(other["a"]);
Assert.AreEqual("a", other["a"].Name);
VB.NET Copy Code
Dim a As UserSettingsSubSection
Dim coll1 As New UserSettingsSubSectionCollection()
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType)

Assert.IsNull(coll1("a"))
a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

coll1.Remove("a")
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))
coll1.Clear()
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

Dim other As New UserSettingsSubSectionCollection()
other.CopyFrom(coll1)

Assert.IsNotNull(other("a"))
Assert.AreEqual("a", other("a").Name)

Requirements

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

See Also

Reference

UserSettingsSubSection Class
UserSettingsSubSection Members

Used By

Int32 UserSettingsSubSection.CompareTo(UserSettingsSubSection)
UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)

Source Code

Library/AppConfig/UserSettingsSubSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Settings Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSection Class : Settings Property

Glossary Item Box

Retrieves the collection of key/value settings

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Settings As KeyValueConfigurationCollection
C#
public KeyValueConfigurationCollection Settings {get;}

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSection settings = UserSettingsSection.DefaultSettings;
Assert.IsNull(settings);

Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Assert.IsNull(cfg.GetSection("userSettings"));

settings = UserSettingsSection.UserSettingsFrom(cfg);
Assert.IsNotNull(settings);
Assert.IsNotNull(settings.Settings);
Assert.IsNotNull(settings.Sections);

settings.Settings.Add("a", "b");
settings["1"] = "2";
Assert.AreEqual("2", settings["1"]);
settings["1"] = "3";
Assert.AreEqual("3", settings["1"]);
cfg.Save();

ConfigurationManager.RefreshSection("userSettings");
Assert.IsNotNull(UserSettingsSection.DefaultSettings);
Assert.AreEqual("b", UserSettingsSection.DefaultSettings["a"]);
Assert.IsNotNull(UserSettingsSection.UserSettings);
Assert.AreEqual("b", UserSettingsSection.UserSettings["a"]);

UserSettingsSection copy = new UserSettingsSection();

settings["a"] = "b";
settings["1"] = "2";
settings.Sections.Add("child.test").Settings.Add("AA", "BB");

copy.CopyFrom(settings);
Assert.AreEqual("b", settings["a"]);
Assert.AreEqual("2", settings["1"]);
Assert.AreEqual("BB", settings.Sections["child.test"]["AA"]);
VB.NET Copy Code
Dim settings As UserSettingsSection = UserSettingsSection.DefaultSettings
Assert.IsNull(settings)

Dim cfg As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Assert.IsNull(cfg.GetSection("userSettings"))

settings = UserSettingsSection.UserSettingsFrom(cfg)
Assert.IsNotNull(settings)
Assert.IsNotNull(settings.Settings)
Assert.IsNotNull(settings.Sections)

settings.Settings.Add("a", "b")
settings("1") = "2"
Assert.AreEqual("2", settings("1"))
settings("1") = "3"
Assert.AreEqual("3", settings("1"))
cfg.Save()

ConfigurationManager.RefreshSection("userSettings")
Assert.IsNotNull(UserSettingsSection.DefaultSettings)
Assert.AreEqual("b", UserSettingsSection.DefaultSettings("a"))
Assert.IsNotNull(UserSettingsSection.UserSettings)
Assert.AreEqual("b", UserSettingsSection.UserSettings("a"))

Dim copy As New UserSettingsSection()

settings("a") = "b"
settings("1") = "2"
settings.Sections.Add("child.test").Settings.Add("AA", "BB")

copy.CopyFrom(settings)
Assert.AreEqual("b", settings("a"))
Assert.AreEqual("2", settings("1"))
Assert.AreEqual("BB", settings.Sections("child.test")("AA"))

Requirements

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

See Also

Reference

UserSettingsSubSection Class
UserSettingsSubSection Members

Used By

UserSettingsSubSection.CopyFrom(UserSettingsSubSection)

Source Code

Library/AppConfig/UserSettingsSubSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingsSubSectionCollection Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSubSectionCollection Class

Glossary Item Box

Provides a collection of name keyed sections that contain more key/value settings

Object Model

UserSettingsSubSectionCollection ClassUserSettingsSubSection Class

Syntax

Visual Basic (Declaration)
Public NotInheritable Class UserSettingsSubSectionCollection
   Inherits System.Configuration.ConfigurationElementCollection
C#
public sealed class UserSettingsSubSectionCollection : System.Configuration.ConfigurationElementCollection

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection a;
UserSettingsSubSectionCollection coll1 = new UserSettingsSubSectionCollection();
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType);

Assert.IsNull(coll1["a"]);
a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

coll1.Remove("a");
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);
coll1.Clear();
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

UserSettingsSubSectionCollection other = new UserSettingsSubSectionCollection();
other.CopyFrom(coll1);

Assert.IsNotNull(other["a"]);
Assert.AreEqual("a", other["a"].Name);
VB.NET Copy Code
Dim a As UserSettingsSubSection
Dim coll1 As New UserSettingsSubSectionCollection()
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType)

Assert.IsNull(coll1("a"))
a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

coll1.Remove("a")
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))
coll1.Clear()
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

Dim other As New UserSettingsSubSectionCollection()
other.CopyFrom(coll1)

Assert.IsNotNull(other("a"))
Assert.AreEqual("a", other("a").Name)

Inheritance Hierarchy

System.Object
System.Configuration.ConfigurationElement
System.Configuration.ConfigurationElementCollection
CSharpTest.Net.AppConfig.UserSettingsSubSectionCollection

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Members
CSharpTest.Net.AppConfig Namespace
UserSettingsSubSectionCollection UserSettingsSection.Sections

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
UserSettingsSubSectionCollection Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSubSectionCollection Class

Glossary Item Box

The following tables list the members exposed by UserSettingsSubSectionCollection.

Public Constructors

 | Name | Description
Public Constructor | UserSettingsSubSectionCollection Constructor | Constructs a collection of named sections
Top

Public Properties

 | Name | Description
Public Property | CollectionType | Overridden. Gets the type of the System.Configuration.ConfigurationElementCollection.
Public Property | Count | Gets the number of elements in the collection. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Property | ElementInformation | Gets an System.Configuration.ElementInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Public Property | EmitClear | Gets or sets a value that specifies whether the collection has been cleared. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Property | IsSynchronized | Gets a value indicating whether access to the collection is synchronized. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Property | Item | Returns the specified collection by name if it exists, or null if not found
Public Property | LockAllAttributesExcept | Gets the collection of locked attributes. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllElementsExcept | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAttributes | Gets the collection of locked attributes (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockElements | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockItem | Gets or sets a value indicating whether the element is locked. (Inherited from System.Configuration.ConfigurationElement)
Public Property | SyncRoot | Gets an object used to synchronize access to the System.Configuration.ConfigurationElementCollection. (Inherited from System.Configuration.ConfigurationElementCollection)
Top

Protected Properties

 | Name | Description
Protected Property | ElementName | Gets the name used to identify this collection of elements in the configuration file when overridden in a derived class. (Inherited from System.Configuration.ConfigurationElementCollection)
Protected Property | EvaluationContext | Gets the System.Configuration.ContextInformation object for the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Protected Property | ThrowOnDuplicate | Gets a value indicating whether an attempt to add a duplicate System.Configuration.ConfigurationElement to the System.Configuration.ConfigurationElementCollection will cause an exception to be thrown. (Inherited from System.Configuration.ConfigurationElementCollection)
Top

Public Methods

 | Name | Description
Public Method | Add | Adds a new section with the specified name
Public Method | Clear | Clears all elements from the collection
Public Method | CopyFrom | Deep copy of all settings from one configuration to another.
Public Method | CopyTo | Copies the contents of the System.Configuration.ConfigurationElementCollection to an array. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Method | GetEnumerator | Gets an System.Collections.IEnumerator which is used to iterate through the System.Configuration.ConfigurationElementCollection. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Method | IsReadOnly | Gets a value indicating whether the System.Configuration.ConfigurationElement object is read-only. (Inherited from System.Configuration.ConfigurationElement)
Public Method | Remove | Removes the specified collection by name
Top

Protected Methods

 | Name | Description
Protected Method | BaseIndexOf | Indicates the index of the specified System.Configuration.ConfigurationElement. (Inherited from System.Configuration.ConfigurationElementCollection)
Protected Method | CreateNewElement | Overloaded. Overridden. creates a new UserSettingsSubSection
Protected Method | GetElementKey | Overridden. Returns the name of the UserSettingsSubSection
Protected Method | IsElementName | Indicates whether the specified System.Configuration.ConfigurationElement exists in the System.Configuration.ConfigurationElementCollection. (Inherited from System.Configuration.ConfigurationElementCollection)
Protected Method | IsElementRemovable | Indicates whether the specified System.Configuration.ConfigurationElement can be removed from the System.Configuration.ConfigurationElementCollection. (Inherited from System.Configuration.ConfigurationElementCollection)
Protected Method | ListErrors | Adds the invalid-property errors in this System.Configuration.ConfigurationElement object, and in all subelements, to the passed list. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedAttribute | Gets a value indicating whether an unknown attribute is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedElement | Gets a value indicating whether an unknown element is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnRequiredPropertyNotFound | Throws an exception when a required property is not found. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PostDeserialize | Called after deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PreSerialize | Called before serialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | SetPropertyValue | Sets a property to the specified value. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

UserSettingsSubSectionCollection Class
CSharpTest.Net.AppConfig Namespace
UserSettingsSubSectionCollection UserSettingsSection.Sections

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingsSubSectionCollection Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : UserSettingsSubSectionCollection Constructor

Glossary Item Box

Constructs a collection of named sections

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public UserSettingsSubSectionCollection()

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection a;
UserSettingsSubSectionCollection coll1 = new UserSettingsSubSectionCollection();
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType);

Assert.IsNull(coll1["a"]);
a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

coll1.Remove("a");
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);
coll1.Clear();
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

UserSettingsSubSectionCollection other = new UserSettingsSubSectionCollection();
other.CopyFrom(coll1);

Assert.IsNotNull(other["a"]);
Assert.AreEqual("a", other["a"].Name);
VB.NET Copy Code
Dim a As UserSettingsSubSection
Dim coll1 As New UserSettingsSubSectionCollection()
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType)

Assert.IsNull(coll1("a"))
a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

coll1.Remove("a")
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))
coll1.Clear()
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

Dim other As New UserSettingsSubSectionCollection()
other.CopyFrom(coll1)

Assert.IsNotNull(other("a"))
Assert.AreEqual("a", other("a").Name)

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
UserSettingsSubSectionCollection Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSubSectionCollection Class

Glossary Item Box

For a list of all members of this type, see UserSettingsSubSectionCollection members.

Public Methods

 | Name | Description
Public Method | Add | Adds a new section with the specified name
Public Method | Clear | Clears all elements from the collection
Public Method | CopyFrom | Deep copy of all settings from one configuration to another.
Public Method | CopyTo | Copies the contents of the System.Configuration.ConfigurationElementCollection to an array. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Method | GetEnumerator | Gets an System.Collections.IEnumerator which is used to iterate through the System.Configuration.ConfigurationElementCollection. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Method | IsReadOnly | Gets a value indicating whether the System.Configuration.ConfigurationElement object is read-only. (Inherited from System.Configuration.ConfigurationElement)
Public Method | Remove | Removes the specified collection by name
Top

Protected Methods

 | Name | Description
Protected Method | BaseIndexOf | Indicates the index of the specified System.Configuration.ConfigurationElement. (Inherited from System.Configuration.ConfigurationElementCollection)
Protected Method | CreateNewElement | Overloaded. Overridden. creates a new UserSettingsSubSection
Protected Method | GetElementKey | Overridden. Returns the name of the UserSettingsSubSection
Protected Method | IsElementName | Indicates whether the specified System.Configuration.ConfigurationElement exists in the System.Configuration.ConfigurationElementCollection. (Inherited from System.Configuration.ConfigurationElementCollection)
Protected Method | IsElementRemovable | Indicates whether the specified System.Configuration.ConfigurationElement can be removed from the System.Configuration.ConfigurationElementCollection. (Inherited from System.Configuration.ConfigurationElementCollection)
Protected Method | ListErrors | Adds the invalid-property errors in this System.Configuration.ConfigurationElement object, and in all subelements, to the passed list. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedAttribute | Gets a value indicating whether an unknown attribute is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedElement | Gets a value indicating whether an unknown element is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnRequiredPropertyNotFound | Throws an exception when a required property is not found. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PostDeserialize | Called after deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PreSerialize | Called before serialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | SetPropertyValue | Sets a property to the specified value. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

UserSettingsSubSectionCollection Class
CSharpTest.Net.AppConfig Namespace
UserSettingsSubSectionCollection UserSettingsSection.Sections

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : Add Method

name

Glossary Item Box

Adds a new section with the specified name

Syntax

Visual Basic (Declaration)
Public Function Add( _
   ByVal name As String _
) As UserSettingsSubSection
C#
public UserSettingsSubSection Add(
   string name
)

Parameters

name

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members
UserSettingsSubSection

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs

Used By

UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : Clear Method

Glossary Item Box

Clears all elements from the collection

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection a;
UserSettingsSubSectionCollection coll1 = new UserSettingsSubSectionCollection();
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType);

Assert.IsNull(coll1["a"]);
a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

coll1.Remove("a");
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);
coll1.Clear();
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

UserSettingsSubSectionCollection other = new UserSettingsSubSectionCollection();
other.CopyFrom(coll1);

Assert.IsNotNull(other["a"]);
Assert.AreEqual("a", other["a"].Name);
VB.NET Copy Code
Dim a As UserSettingsSubSection
Dim coll1 As New UserSettingsSubSectionCollection()
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType)

Assert.IsNull(coll1("a"))
a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

coll1.Remove("a")
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))
coll1.Clear()
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

Dim other As New UserSettingsSubSectionCollection()
other.CopyFrom(coll1)

Assert.IsNotNull(other("a"))
Assert.AreEqual("a", other("a").Name)

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyFrom Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : CopyFrom Method

other

Glossary Item Box

Deep copy of all settings from one configuration to another.

Syntax

Visual Basic (Declaration)
Public Sub CopyFrom( _
   ByVal other As UserSettingsSubSectionCollection _
)
C#
public void CopyFrom(
   UserSettingsSubSectionCollection other
)

Parameters

other

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection a;
UserSettingsSubSectionCollection coll1 = new UserSettingsSubSectionCollection();
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType);

Assert.IsNull(coll1["a"]);
a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

coll1.Remove("a");
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);
coll1.Clear();
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

UserSettingsSubSectionCollection other = new UserSettingsSubSectionCollection();
other.CopyFrom(coll1);

Assert.IsNotNull(other["a"]);
Assert.AreEqual("a", other["a"].Name);
VB.NET Copy Code
Dim a As UserSettingsSubSection
Dim coll1 As New UserSettingsSubSectionCollection()
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType)

Assert.IsNull(coll1("a"))
a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

coll1.Remove("a")
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))
coll1.Clear()
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

Dim other As New UserSettingsSubSectionCollection()
other.CopyFrom(coll1)

Assert.IsNotNull(other("a"))
Assert.AreEqual("a", other("a").Name)

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members

Used By

UserSettingsSection.CopyFrom(UserSettingsSection)

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNewElement Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : CreateNewElement Method

Glossary Item Box

creates a new UserSettingsSubSection

Overload List

Overload | Description
CreateNewElement() | creates a new UserSettingsSubSection
CreateNewElement(String) | creates a new UserSettingsSubSection

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members
Base Implementation in CreateNewElement


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNewElement() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class > CreateNewElement Method : CreateNewElement() Method

Glossary Item Box

creates a new UserSettingsSubSection

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides NotOverridable Function CreateNewElement() As ConfigurationElement
C#
protected override ConfigurationElement CreateNewElement()

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members
Overload List
Base Implementation in CreateNewElement()


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNewElement(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class > CreateNewElement Method : CreateNewElement(String) Method

elementName

Glossary Item Box

creates a new UserSettingsSubSection

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides NotOverridable Function CreateNewElement( _
   ByVal elementName As String _
) As ConfigurationElement
C#
protected override ConfigurationElement CreateNewElement(
   string elementName
)

Parameters

elementName

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members
Overload List
Base Implementation in CreateNewElement(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
GetElementKey Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : GetElementKey Method

element

Glossary Item Box

Returns the name of the UserSettingsSubSection

Syntax

Visual Basic (Declaration)
Protected Overrides NotOverridable Function GetElementKey( _
   ByVal element As ConfigurationElement _
) As Object
C#
protected override object GetElementKey(
   ConfigurationElement element
)

Parameters

element

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members
Base Implementation in GetElementKey


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : Remove Method

name

Glossary Item Box

Removes the specified collection by name

Syntax

Visual Basic (Declaration)
Public Sub Remove( _
   ByVal name As String _
)
C#
public void Remove(
   string name
)

Parameters

name

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
UserSettingsSubSection a;
UserSettingsSubSectionCollection coll1 = new UserSettingsSubSectionCollection();
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType);

Assert.IsNull(coll1["a"]);
a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

coll1.Remove("a");
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);
coll1.Clear();
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

UserSettingsSubSectionCollection other = new UserSettingsSubSectionCollection();
other.CopyFrom(coll1);

Assert.IsNotNull(other["a"]);
Assert.AreEqual("a", other["a"].Name);
VB.NET Copy Code
Dim a As UserSettingsSubSection
Dim coll1 As New UserSettingsSubSectionCollection()
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType)

Assert.IsNull(coll1("a"))
a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

coll1.Remove("a")
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))
coll1.Clear()
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

Dim other As New UserSettingsSubSectionCollection()
other.CopyFrom(coll1)

Assert.IsNotNull(other("a"))
Assert.AreEqual("a", other("a").Name)

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
UserSettingsSubSectionCollection Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace : UserSettingsSubSectionCollection Class

Glossary Item Box

For a list of all members of this type, see UserSettingsSubSectionCollection members.

Public Properties

 | Name | Description
Public Property | CollectionType | Overridden. Gets the type of the System.Configuration.ConfigurationElementCollection.
Public Property | Count | Gets the number of elements in the collection. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Property | ElementInformation | Gets an System.Configuration.ElementInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Public Property | EmitClear | Gets or sets a value that specifies whether the collection has been cleared. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Property | IsSynchronized | Gets a value indicating whether access to the collection is synchronized. (Inherited from System.Configuration.ConfigurationElementCollection)
Public Property | Item | Returns the specified collection by name if it exists, or null if not found
Public Property | LockAllAttributesExcept | Gets the collection of locked attributes. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllElementsExcept | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAttributes | Gets the collection of locked attributes (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockElements | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockItem | Gets or sets a value indicating whether the element is locked. (Inherited from System.Configuration.ConfigurationElement)
Public Property | SyncRoot | Gets an object used to synchronize access to the System.Configuration.ConfigurationElementCollection. (Inherited from System.Configuration.ConfigurationElementCollection)
Top

Protected Properties

 | Name | Description
Protected Property | ElementName | Gets the name used to identify this collection of elements in the configuration file when overridden in a derived class. (Inherited from System.Configuration.ConfigurationElementCollection)
Protected Property | EvaluationContext | Gets the System.Configuration.ContextInformation object for the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Protected Property | ThrowOnDuplicate | Gets a value indicating whether an attempt to add a duplicate System.Configuration.ConfigurationElement to the System.Configuration.ConfigurationElementCollection will cause an exception to be thrown. (Inherited from System.Configuration.ConfigurationElementCollection)
Top

See Also

Reference

UserSettingsSubSectionCollection Class
CSharpTest.Net.AppConfig Namespace
UserSettingsSubSectionCollection UserSettingsSection.Sections

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CollectionType Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : CollectionType Property

Glossary Item Box

Gets the type of the System.Configuration.ConfigurationElementCollection.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable ReadOnly Property CollectionType As ConfigurationElementCollectionType
C#
public override ConfigurationElementCollectionType CollectionType {get;}

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members
Base Implementation in CollectionType

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item(String) Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : Item(String) Property

name

Glossary Item Box

Returns the specified collection by name if it exists, or null if not found

Syntax

Visual Basic (Declaration)
Public Overloads Shadows ReadOnly Property Item( _
   ByVal name As String _
) As UserSettingsSubSection
C#
public new UserSettingsSubSection Item(
   string name
) {get;}

Parameters

name

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

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

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members
UserSettingsSubSection

Used By

UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%ItemTitle%%

CSharpTest.Net.Bases Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Bases Namespace

Glossary Item Box

Classes

 | Class | Description
Class | Comparable<T> | Provides a base-class for non-reference comparison of objects
Class | Comparable.EqualityComparer<T> | Implements the equality comparer
Class | Disposable | Wraps the IDisposable object interface for classes that desire to be sure of being called a single time for the dispose.
Class | Equatable<T> | Provides a base-class for non-reference equality objects
Class | Equatable.EqualityComparer<T> | Implements the equality comparer

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Comparable<T> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Comparable<T> Class

Glossary Item Box

Provides a base-class for non-reference comparison of objects

Syntax

Visual Basic (Declaration)
Public MustInherit Class Comparable(Of T As Comparable(Of T))
   Inherits Equatable(Of T)
C#
public abstract class Comparable<T> : Equatable<T>
where T: Comparable<T>

Type Parameters

T

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Equatable<T>
CSharpTest.Net.Bases.Comparable<T>
CSharpTest.Net.Crypto.Hash
CSharpTest.Net.Crypto.PasswordHash

Requirements

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

See Also

Reference

Comparable<T> Members
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Comparable<T> Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Comparable<T> Class

Glossary Item Box

The following tables list the members exposed by Comparable<T>.

Protected Constructors

 | Name | Description
Protected Constructor | Comparable<T> Constructor |
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | returns a non-reference comparer for this class
Top

Protected Properties

 | Name | Description
Protected Property | HashCode | Extracts the correct hash code (Inherited from CSharpTest.Net.Bases.Equatable<T>)
Top

Public Methods

 | Name | Description
Public Method | CompareTo | Compares with another object of T
Public Method | Equals | Overloaded. Overridden. Returns true if the object is equal
Top

Public Operators

public Operator Greater Than | Compares two objects
public Operator Greater Than or Equal | Compares two objects
public Operator Less Than | Compares two objects
public Operator Less Than or Equal | Compares two objects
Top

See Also

Reference

Comparable<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparable<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class : Comparable<T> Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected Comparable<T>()

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Comparable<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Comparable<T> Class

Glossary Item Box

For a list of all members of this type, see Comparable<T> members.

Public Methods

 | Name | Description
Public Method | CompareTo | Compares with another object of T
Public Method | Equals | Overloaded. Overridden. Returns true if the object is equal
Top

See Also

Reference

Comparable<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CompareTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class : CompareTo Method

other

Glossary Item Box

Compares with another object of T

Syntax

Visual Basic (Declaration)
Public MustOverride Function CompareTo( _
   ByVal other As T _
) As Integer
C#
public abstract int CompareTo(
   T other
)

Parameters

other

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
{
    Assert.AreEqual(pwd1, pwd2);
    Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray());
    Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray());

    Assert.IsTrue(pwd1 == pwd2);
    Assert.IsTrue(pwd1 == pwd2);
    Assert.IsFalse(pwd1 != pwd2);
    Assert.IsTrue(pwd1.Equals(pwd2));
    Assert.IsTrue(pwd1.Equals((object)pwd2));
    Assert.AreEqual(0, pwd1.CompareTo(pwd2));
    Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
    Assert.AreEqual(pwd1.ToString(), pwd2.ToString());

    PasswordHash nil = null;
    Assert.IsFalse(pwd1 < nil);
    Assert.IsTrue(pwd1 > nil);
    Assert.AreEqual(1, pwd1.CompareTo(null));
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
        Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray())
        Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray())

        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsFalse(pwd1 <> pwd2)
        Assert.IsTrue(pwd1.Equals(pwd2))
        Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
        Assert.AreEqual(0, pwd1.CompareTo(pwd2))
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
        Assert.AreEqual(pwd1.ToString(), pwd2.ToString())

        Dim nil As PasswordHash = Nothing
        Assert.IsFalse(pwd1 < nil)
        Assert.IsTrue(pwd1 > nil)
        Assert.AreEqual(1, pwd1.CompareTo(Nothing))
    End Using
End Using

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members

Used By

Boolean Comparable.Equals(T)
Boolean Comparable.EqualityComparer.Equals(T,T)
Int32 Comparable.EqualityComparer.Compare(T,T)

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class : Equals Method

Glossary Item Box

Returns true if the object is equal

Overload List

Overload | Description
Equals(T) | Returns true if the object is equal

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members
Base Implementation in Equals


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class > Equals Method : Equals(T) Method

other

Glossary Item Box

Returns true if the object is equal

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Equals( _
   ByVal other As T _
) As Boolean
C#
public override bool Equals(
   T other
)

Parameters

other

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members
Overload List
Base Implementation in Equals(T)

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
Comparable<T> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Comparable<T> Class

Glossary Item Box

For a list of all members of this type, see Comparable<T> members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | returns a non-reference comparer for this class
Top

See Also

Reference

Comparable<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class : Comparer Field

Glossary Item Box

returns a non-reference comparer for this class

Syntax

Visual Basic (Declaration)
Public Shadows Shared ReadOnly Comparer As Comparable(Of T)
C#
public new static readonly Comparable<T> Comparer

Example

Library/Library.Test/TestEquatable.cs

C# Copy Code
IComparer<Null<int>> cmp = Null<int>.Comparer;
Null<int> nil = null;
Null<int> a = 5;
Null<int> b1 = 6;
Null<int> b2 = 6;

Assert.IsTrue(cmp.Compare(null, nil) == 0);
Assert.IsTrue(cmp.Compare(nil, null) == 0);
Assert.IsTrue(cmp.Compare(b1, b2) == 0);
Assert.IsTrue(cmp.Compare(a, b1) < 0);
Assert.IsTrue(cmp.Compare(b1, a) > 0);
Assert.IsTrue(cmp.Compare(nil, a) < 0);
Assert.IsTrue(cmp.Compare(a, nil) > 0);
Assert.IsTrue(cmp.Compare(null, a) < 0);
Assert.IsTrue(cmp.Compare(a, null) > 0);
VB.NET Copy Code
Dim cmp As IComparer(Of Null(Of Integer)) = Null(Of Integer).Comparer
Dim nil As Null(Of Integer) = Nothing
Dim a As Null(Of Integer) = 5
Dim b1 As Null(Of Integer) = 6
Dim b2 As Null(Of Integer) = 6

Assert.IsTrue(cmp.Compare(Nothing, nil) = 0)
Assert.IsTrue(cmp.Compare(nil, Nothing) = 0)
Assert.IsTrue(cmp.Compare(b1, b2) = 0)
Assert.IsTrue(cmp.Compare(a, b1) < 0)
Assert.IsTrue(cmp.Compare(b1, a) > 0)
Assert.IsTrue(cmp.Compare(nil, a) < 0)
Assert.IsTrue(cmp.Compare(a, nil) > 0)
Assert.IsTrue(cmp.Compare(Nothing, a) < 0)
Assert.IsTrue(cmp.Compare(a, Nothing) > 0)

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Greater Than Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class : Greater Than Operator

a
b

Glossary Item Box

Compares two objects

Syntax

Visual Basic (Declaration)
Public Operator >( _
   ByVal a As Comparable(Of T), _
   ByVal b As Comparable(Of T) _
) As Boolean
C#
public bool operator >(
   Comparable<T> a,
   Comparable<T> b
)

Parameters

a
b

Example

Library/Library.Test/TestEquatable.cs

C# Copy Code
Null<int> nil = null;
Null<int> a = 5;
Null<int> b1 = 6;
Null<int> b2 = 6;

Assert.IsTrue(null >= nil);
Assert.IsTrue(nil >= null);
Assert.IsTrue(b1 >= b2);
Assert.IsFalse(a >= b1);
Assert.IsTrue(b1 >= a);
Assert.IsFalse(nil >= a);
Assert.IsTrue(a >= nil);
Assert.IsFalse(null >= a);
Assert.IsTrue(a >= null);

Assert.IsFalse(null > nil);
Assert.IsFalse(nil > null);
Assert.IsFalse(b1 > b2);
Assert.IsFalse(a > b1);
Assert.IsTrue(b1 > a);
Assert.IsFalse(nil > a);
Assert.IsTrue(a > nil);
Assert.IsFalse(null > a);
Assert.IsTrue(a > null);
VB.NET Copy Code
Dim nil As Null(Of Integer) = Nothing
Dim a As Null(Of Integer) = 5
Dim b1 As Null(Of Integer) = 6
Dim b2 As Null(Of Integer) = 6

Assert.IsTrue(Nothing >= nil)
Assert.IsTrue(nil >= Nothing)
Assert.IsTrue(b1 >= b2)
Assert.IsFalse(a >= b1)
Assert.IsTrue(b1 >= a)
Assert.IsFalse(nil >= a)
Assert.IsTrue(a >= nil)
Assert.IsFalse(Nothing >= a)
Assert.IsTrue(a >= Nothing)

Assert.IsFalse(Nothing > nil)
Assert.IsFalse(nil > Nothing)
Assert.IsFalse(b1 > b2)
Assert.IsFalse(a > b1)
Assert.IsTrue(b1 > a)
Assert.IsFalse(nil > a)
Assert.IsTrue(a > nil)
Assert.IsFalse(Nothing > a)
Assert.IsTrue(a > Nothing)

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Greater Than or Equal Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class : Greater Than or Equal Operator

a
b

Glossary Item Box

Compares two objects

Syntax

Visual Basic (Declaration)
Public Operator >=( _
   ByVal a As Comparable(Of T), _
   ByVal b As Comparable(Of T) _
) As Boolean
C#
public bool operator >=(
   Comparable<T> a,
   Comparable<T> b
)

Parameters

a
b

Example

Library/Library.Test/TestEquatable.cs

C# Copy Code
Null<int> nil = null;
Null<int> a = 5;
Null<int> b1 = 6;
Null<int> b2 = 6;

Assert.IsTrue(null >= nil);
Assert.IsTrue(nil >= null);
Assert.IsTrue(b1 >= b2);
Assert.IsFalse(a >= b1);
Assert.IsTrue(b1 >= a);
Assert.IsFalse(nil >= a);
Assert.IsTrue(a >= nil);
Assert.IsFalse(null >= a);
Assert.IsTrue(a >= null);

Assert.IsFalse(null > nil);
Assert.IsFalse(nil > null);
Assert.IsFalse(b1 > b2);
Assert.IsFalse(a > b1);
Assert.IsTrue(b1 > a);
Assert.IsFalse(nil > a);
Assert.IsTrue(a > nil);
Assert.IsFalse(null > a);
Assert.IsTrue(a > null);
VB.NET Copy Code
Dim nil As Null(Of Integer) = Nothing
Dim a As Null(Of Integer) = 5
Dim b1 As Null(Of Integer) = 6
Dim b2 As Null(Of Integer) = 6

Assert.IsTrue(Nothing >= nil)
Assert.IsTrue(nil >= Nothing)
Assert.IsTrue(b1 >= b2)
Assert.IsFalse(a >= b1)
Assert.IsTrue(b1 >= a)
Assert.IsFalse(nil >= a)
Assert.IsTrue(a >= nil)
Assert.IsFalse(Nothing >= a)
Assert.IsTrue(a >= Nothing)

Assert.IsFalse(Nothing > nil)
Assert.IsFalse(nil > Nothing)
Assert.IsFalse(b1 > b2)
Assert.IsFalse(a > b1)
Assert.IsTrue(b1 > a)
Assert.IsFalse(nil > a)
Assert.IsTrue(a > nil)
Assert.IsFalse(Nothing > a)
Assert.IsTrue(a > Nothing)

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Less Than Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class : Less Than Operator

a
b

Glossary Item Box

Compares two objects

Syntax

Visual Basic (Declaration)
Public Operator <( _
   ByVal a As Comparable(Of T), _
   ByVal b As Comparable(Of T) _
) As Boolean
C#
public bool operator <(
   Comparable<T> a,
   Comparable<T> b
)

Parameters

a
b

Example

Library/Library.Test/TestEquatable.cs

C# Copy Code
Null<int> nil = null;
Null<int> a = 5;
Null<int> b1 = 6;
Null<int> b2 = 6;

Assert.IsTrue(null <= nil);
Assert.IsTrue(nil <= null);
Assert.IsTrue(b1 <= b2);
Assert.IsTrue(a <= b1);
Assert.IsFalse(b1 <= a);
Assert.IsTrue(nil <= a);
Assert.IsFalse(a <= nil);
Assert.IsTrue(null <= a);
Assert.IsFalse(a <= null);

Assert.IsFalse(null < nil);
Assert.IsFalse(nil < null);
Assert.IsFalse(b1 < b2);
Assert.IsTrue(a < b1);
Assert.IsFalse(b1 < a);
Assert.IsTrue(nil < a);
Assert.IsFalse(a < nil);
Assert.IsTrue(null < a);
Assert.IsFalse(a < null);
VB.NET Copy Code
Dim nil As Null(Of Integer) = Nothing
Dim a As Null(Of Integer) = 5
Dim b1 As Null(Of Integer) = 6
Dim b2 As Null(Of Integer) = 6

Assert.IsTrue(Nothing <= nil)
Assert.IsTrue(nil <= Nothing)
Assert.IsTrue(b1 <= b2)
Assert.IsTrue(a <= b1)
Assert.IsFalse(b1 <= a)
Assert.IsTrue(nil <= a)
Assert.IsFalse(a <= nil)
Assert.IsTrue(Nothing <= a)
Assert.IsFalse(a <= Nothing)

Assert.IsFalse(Nothing < nil)
Assert.IsFalse(nil < Nothing)
Assert.IsFalse(b1 < b2)
Assert.IsTrue(a < b1)
Assert.IsFalse(b1 < a)
Assert.IsTrue(nil < a)
Assert.IsFalse(a < nil)
Assert.IsTrue(Nothing < a)
Assert.IsFalse(a < Nothing)

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Less Than or Equal Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable<T> Class : Less Than or Equal Operator

a
b

Glossary Item Box

Compares two objects

Syntax

Visual Basic (Declaration)
Public Operator <=( _
   ByVal a As Comparable(Of T), _
   ByVal b As Comparable(Of T) _
) As Boolean
C#
public bool operator <=(
   Comparable<T> a,
   Comparable<T> b
)

Parameters

a
b

Example

Library/Library.Test/TestEquatable.cs

C# Copy Code
Null<int> nil = null;
Null<int> a = 5;
Null<int> b1 = 6;
Null<int> b2 = 6;

Assert.IsTrue(null <= nil);
Assert.IsTrue(nil <= null);
Assert.IsTrue(b1 <= b2);
Assert.IsTrue(a <= b1);
Assert.IsFalse(b1 <= a);
Assert.IsTrue(nil <= a);
Assert.IsFalse(a <= nil);
Assert.IsTrue(null <= a);
Assert.IsFalse(a <= null);

Assert.IsFalse(null < nil);
Assert.IsFalse(nil < null);
Assert.IsFalse(b1 < b2);
Assert.IsTrue(a < b1);
Assert.IsFalse(b1 < a);
Assert.IsTrue(nil < a);
Assert.IsFalse(a < nil);
Assert.IsTrue(null < a);
Assert.IsFalse(a < null);
VB.NET Copy Code
Dim nil As Null(Of Integer) = Nothing
Dim a As Null(Of Integer) = 5
Dim b1 As Null(Of Integer) = 6
Dim b2 As Null(Of Integer) = 6

Assert.IsTrue(Nothing <= nil)
Assert.IsTrue(nil <= Nothing)
Assert.IsTrue(b1 <= b2)
Assert.IsTrue(a <= b1)
Assert.IsFalse(b1 <= a)
Assert.IsTrue(nil <= a)
Assert.IsFalse(a <= nil)
Assert.IsTrue(Nothing <= a)
Assert.IsFalse(a <= Nothing)

Assert.IsFalse(Nothing < nil)
Assert.IsFalse(nil < Nothing)
Assert.IsFalse(b1 < b2)
Assert.IsTrue(a < b1)
Assert.IsFalse(b1 < a)
Assert.IsTrue(nil < a)
Assert.IsFalse(a < nil)
Assert.IsTrue(Nothing < a)
Assert.IsFalse(a < Nothing)

Requirements

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

See Also

Reference

Comparable<T> Class
Comparable<T> Members

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Comparable.EqualityComparer<T> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Comparable.EqualityComparer<T> Class

Glossary Item Box

Implements the equality comparer

Syntax

Visual Basic (Declaration)
Public NotInheritable Class Comparable.EqualityComparer(Of T As Comparable(Of T))
   Inherits System.Collections.Generic.Comparer(Of T)
C#
public sealed class Comparable.EqualityComparer<T> : System.Collections.Generic.Comparer<T>
where T: Comparable<T>

Type Parameters

T

Inheritance Hierarchy

System.Object
System.Collections.Generic.Comparer<T>
CSharpTest.Net.Bases.Comparable`1.EqualityComparer<T>

Requirements

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

See Also

Reference

Comparable.EqualityComparer<T> Members
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Comparable.EqualityComparer<T> Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Comparable.EqualityComparer<T> Class

Glossary Item Box

The following tables list the members exposed by Comparable.EqualityComparer<T>.

Public Constructors

 | Name | Description
Public Constructor | Comparable.EqualityComparer<T> Constructor |
Top

Public Methods

 | Name | Description
Public Method | Compare | Overridden. Returns the comparison between the two objects
Public Method | Equals | Overloaded. Compares the two objects for non-reference equality
Public Method | GetHashCode | Overloaded. Extracts the correct hash code
Top

See Also

Reference

Comparable.EqualityComparer<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparable.EqualityComparer<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable.EqualityComparer<T> Class : Comparable.EqualityComparer<T> Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public Comparable.EqualityComparer<T>()

Requirements

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

See Also

Reference

Comparable.EqualityComparer<T> Class
Comparable.EqualityComparer<T> Members

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Comparable.EqualityComparer<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Comparable.EqualityComparer<T> Class

Glossary Item Box

For a list of all members of this type, see Comparable.EqualityComparer<T> members.

Public Methods

 | Name | Description
Public Method | Compare | Overridden. Returns the comparison between the two objects
Public Method | Equals | Overloaded. Compares the two objects for non-reference equality
Public Method | GetHashCode | Overloaded. Extracts the correct hash code
Top

See Also

Reference

Comparable.EqualityComparer<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Compare Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable.EqualityComparer<T> Class : Compare Method

x
y

Glossary Item Box

Returns the comparison between the two objects

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable Function Compare( _
   ByVal x As T, _
   ByVal y As T _
) As Integer
C#
public override int Compare(
   T x,
   T y
)

Parameters

x
y

Requirements

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

See Also

Reference

Comparable.EqualityComparer<T> Class
Comparable.EqualityComparer<T> Members
Base Implementation in Compare

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable.EqualityComparer<T> Class : Equals Method

Glossary Item Box

Compares the two objects for non-reference equality

Overload List

Overload | Description
Equals(T,T) | Compares the two objects for non-reference equality

Requirements

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

See Also

Reference

Comparable.EqualityComparer<T> Class
Comparable.EqualityComparer<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(T,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable.EqualityComparer<T> Class > Equals Method : Equals(T,T) Method

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Overloads Function Equals( _
   ByVal x As T, _
   ByVal y As T _
) As Boolean
C#
public bool Equals(
   T x,
   T y
)

Parameters

x
y

Requirements

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

See Also

Reference

Comparable.EqualityComparer<T> Class
Comparable.EqualityComparer<T> Members
Overload List

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable.EqualityComparer<T> Class : GetHashCode Method

Glossary Item Box

Extracts the correct hash code

Overload List

Overload | Description
GetHashCode(T) | Extracts the correct hash code

Requirements

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

See Also

Reference

Comparable.EqualityComparer<T> Class
Comparable.EqualityComparer<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode(T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Comparable.EqualityComparer<T> Class > GetHashCode Method : GetHashCode(T) Method

obj

Glossary Item Box

Extracts the correct hash code

Syntax

Visual Basic (Declaration)
Public Overloads Function GetHashCode( _
   ByVal obj As T _
) As Integer
C#
public int GetHashCode(
   T obj
)

Parameters

obj

Requirements

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

See Also

Reference

Comparable.EqualityComparer<T> Class
Comparable.EqualityComparer<T> Members
Overload List

Source Code

Library/Bases/Comparable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Disposable Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Disposable Class

Glossary Item Box

Wraps the IDisposable object interface for classes that desire to be sure of being called a single time for the dispose.

Syntax

Visual Basic (Declaration)
Public MustInherit Class Disposable
C#
public abstract class Disposable

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Disposable
CSharpTest.Net.IO.BackgroundWriter
CSharpTest.Net.IO.StreamCache

Requirements

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

See Also

Reference

Disposable Members
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Disposable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Disposable Class Members
See Also Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Disposable Class

Glossary Item Box

The following tables list the members exposed by Disposable.

Protected Constructors

 | Name | Description
Protected Constructor | Disposable Constructor |
Top

Public Methods

 | Name | Description
Public Method | Dispose | Overloaded. disposes of the object if it has not already been disposed
Top

Protected Methods

 | Name | Description
Protected Method | Assert | Raises the ObjectDisposedException if this object has already been disposed
Protected Method | Finalize | last-chance dispose
Top

Public Events

 | Name | Description
Public Event | Disposed | Raised when the object is disposed
Top

See Also

Reference

Disposable Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Disposable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Disposable Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Disposable Class : Disposable Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected Disposable()

Requirements

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

See Also

Reference

Disposable Class
Disposable Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Disposable Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Disposable Class

Glossary Item Box

For a list of all members of this type, see Disposable members.

Public Methods

 | Name | Description
Public Method | Dispose | Overloaded. disposes of the object if it has not already been disposed
Top

Protected Methods

 | Name | Description
Protected Method | Assert | Raises the ObjectDisposedException if this object has already been disposed
Protected Method | Finalize | last-chance dispose
Top

See Also

Reference

Disposable Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Disposable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Disposable Class : Assert Method

Glossary Item Box

Raises the ObjectDisposedException if this object has already been disposed

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Assert()
C#
protected virtual void Assert()

Requirements

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

See Also

Reference

Disposable Class
Disposable Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Disposable Class : Dispose Method

Glossary Item Box

disposes of the object if it has not already been disposed

Overload List

Overload | Description
Dispose() | disposes of the object if it has not already been disposed
Dispose(Boolean) | Your implementation of the dispose method

Requirements

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

See Also

Reference

Disposable Class
Disposable Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Disposable Class > Dispose Method : Dispose() Method

Glossary Item Box

disposes of the object if it has not already been disposed

Syntax

Visual Basic (Declaration)
Public Overloads Sub Dispose()
C#
public void Dispose()

Example

Library/Library.Test/TestDisposable.cs

C# Copy Code
MyDisposable o = new MyDisposable();
using (o)
{
    Assert.AreEqual(0, o._disposedCount);
    o.Dispose();
    Assert.AreEqual(1, o._disposedCount);
    o.Dispose();
    Assert.AreEqual(1, o._disposedCount);
}
Assert.AreEqual(1, o._disposedCount);
VB.NET Copy Code
Dim o As New MyDisposable()
Using o
    Assert.AreEqual(0, o._disposedCount)
    o.Dispose()
    Assert.AreEqual(1, o._disposedCount)
    o.Dispose()
    Assert.AreEqual(1, o._disposedCount)
End Using
Assert.AreEqual(1, o._disposedCount)

Requirements

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

See Also

Reference

Disposable Class
Disposable Members
Overload List

Source Code

Library/Bases/Disposable.cs

Used By

BackgroundWriter.Close()
FragmentedFile.Dispose()


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Disposable Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Your implementation of the dispose method

Syntax

Visual Basic (Declaration)
Protected Overloads MustOverride Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected abstract void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

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

See Also

Reference

Disposable Class
Disposable Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
Finalize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Disposable Class : Finalize Method

Glossary Item Box

last-chance dispose

Syntax

Visual Basic (Declaration)
Protected Overrides Sub Finalize()
C#
protected override void Finalize()

Requirements

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

See Also

Reference

Disposable Class
Disposable Members
Base Implementation in Finalize


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
Disposable Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Disposable Class

Glossary Item Box

For a list of all members of this type, see Disposable members.

Public Events

 | Name | Description
Public Event | Disposed | Raised when the object is disposed
Top

See Also

Reference

Disposable Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Disposable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Disposed Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Disposable Class : Disposed Event

Glossary Item Box

Raised when the object is disposed

Syntax

Visual Basic (Declaration)
Public Event Disposed As EventHandler
C#
public event EventHandler Disposed

Requirements

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

See Also

Reference

Disposable Class
Disposable Members

Source Code

Library/Bases/Disposable.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Equatable<T> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Equatable<T> Class

Glossary Item Box

Provides a base-class for non-reference equality objects

Syntax

Visual Basic (Declaration)
Public MustInherit Class Equatable(Of T As Equatable(Of T))
C#
public abstract class Equatable<T>
where T: Equatable<T>

Type Parameters

T

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Equatable<T>
CSharpTest.Net.Bases.Comparable<T>
CSharpTest.Net.Crypto.Salt

Requirements

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

See Also

Reference

Equatable<T> Members
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Equatable<T> Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Equatable<T> Class

Glossary Item Box

The following tables list the members exposed by Equatable<T>.

Protected Constructors

 | Name | Description
Protected Constructor | Equatable<T> Constructor |
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | return a non-reference equality comparer for this class
Top

Protected Properties

 | Name | Description
Protected Property | HashCode | Extracts the correct hash code
Top

Public Methods

 | Name | Description
Public Method | Equals | Overloaded. Returns true if the other object is equal to this one
Public Method | GetHashCode | Overloaded. Extracts the correct hash code
Top

Public Operators

public Operator Equality | Compares the two objects for non-reference equality
public Operator Inequality | Compares the two objects for non-reference equality
Top

See Also

Reference

Equatable<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equatable<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class : Equatable<T> Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected Equatable<T>()

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Equatable<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Equatable<T> Class

Glossary Item Box

For a list of all members of this type, see Equatable<T> members.

Public Methods

 | Name | Description
Public Method | Equals | Overloaded. Returns true if the other object is equal to this one
Public Method | GetHashCode | Overloaded. Extracts the correct hash code
Top

See Also

Reference

Equatable<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class : Equals Method

Glossary Item Box

Returns true if the other object is equal to this one

Overload List

Overload | Description
Equals(T) | Returns true if the other object is equal to this one
Equals(Object) | Returns true if the other object is equal to this one
Equals(T,T) | Compares the two objects for non-reference equality

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(T) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class > Equals Method : Equals(T) Method

other

Glossary Item Box

Returns true if the other object is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads MustOverride Function Equals( _
   ByVal other As T _
) As Boolean
C#
public abstract bool Equals(
   T other
)

Parameters

other

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
Salt scopy = Salt.FromBytes(s.ToArray());

Assert.AreEqual(s, scopy);
Assert.IsTrue(s.Equals(scopy));
Assert.IsTrue(s.Equals((object)scopy));
Assert.IsTrue(s == scopy);
Assert.IsFalse(s != scopy);
Assert.AreEqual(s.GetHashCode(), scopy.GetHashCode());

scopy = new Salt();
Assert.AreNotEqual(s, scopy);
Assert.IsFalse(s.Equals(scopy));
Assert.IsFalse(s.Equals((object)scopy));
Assert.IsFalse(s == scopy);
Assert.IsTrue(s != scopy);
Assert.AreNotEqual(s.GetHashCode(), scopy.GetHashCode());
VB.NET Copy Code
Dim s As New Salt()
Dim scopy As Salt = Salt.FromBytes(s.ToArray())

Assert.AreEqual(s, scopy)
Assert.IsTrue(s.Equals(scopy))
Assert.IsTrue(s.Equals(DirectCast(scopy, Object)))
Assert.IsTrue(s = scopy)
Assert.IsFalse(s <> scopy)
Assert.AreEqual(s.GetHashCode(), scopy.GetHashCode())

scopy = New Salt()
Assert.AreNotEqual(s, scopy)
Assert.IsFalse(s.Equals(scopy))
Assert.IsFalse(s.Equals(DirectCast(scopy, Object)))
Assert.IsFalse(s = scopy)
Assert.IsTrue(s <> scopy)
Assert.AreNotEqual(s.GetHashCode(), scopy.GetHashCode())

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members
Overload List

Source Code

Library/Bases/Equatable.cs

Used By

Boolean Equatable.EqualityComparer.Equals(T,T)
Boolean PasswordHash.VerifyPassword(Password)
Boolean PasswordHash.VerifyPassword(Stream)


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class > Equals Method : Equals(Object) Method

obj

Glossary Item Box

Returns true if the other object is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Equals( _
   ByVal obj As Object _
) As Boolean
C#
public override bool Equals(
   object obj
)

Parameters

obj

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members
Overload List
Base Implementation in Equals(Object)

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(T,T) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class > Equals Method : Equals(T,T) Method

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Equals( _
   ByVal x As T, _
   ByVal y As T _
) As Boolean
C#
public static bool Equals(
   T x,
   T y
)

Parameters

x
y

Example

Library/Library.Test/TestEquatable.cs

C# Copy Code
IEqualityComparer<Null<int>> cmp = Null<int>.Comparer;
Null<int> nil = null;
Null<int> a = 5;
Null<int> b1 = 6;
Null<int> b2 = 6;

Assert.IsTrue(cmp.Equals(null, nil));
Assert.IsTrue(cmp.Equals(nil, null));
Assert.IsTrue(cmp.Equals(b1, b2));
Assert.IsFalse(cmp.Equals(a, b1));
Assert.IsFalse(cmp.Equals(b1, a));
Assert.IsFalse(cmp.Equals(nil, a));
Assert.IsFalse(cmp.Equals(a, nil));
Assert.IsFalse(cmp.Equals(null, a));
Assert.IsFalse(cmp.Equals(a, null));

Assert.IsTrue(Null<int>.Equals(null, nil));
Assert.IsTrue(Null<int>.Equals(nil, null));
Assert.IsTrue(Null<int>.Equals(b1, b2));
Assert.IsFalse(Null<int>.Equals(a, b1));
Assert.IsFalse(Null<int>.Equals(b1, a));
Assert.IsFalse(Null<int>.Equals(nil, a));
Assert.IsFalse(Null<int>.Equals(a, nil));
Assert.IsFalse(Null<int>.Equals(null, a));
Assert.IsFalse(Null<int>.Equals(a, null));

Assert.AreNotEqual(a.GetHashCode(), b2.GetHashCode());
Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode());

Assert.AreEqual(cmp.GetHashCode(nil), 0);
Assert.AreEqual(cmp.GetHashCode(a), a.GetHashCode());
Assert.AreEqual(cmp.GetHashCode(b1), b2.GetHashCode());

Assert.AreEqual(Null<int>.GetHashCode(nil), 0);
Assert.AreEqual(Null<int>.GetHashCode(a), a.GetHashCode());
Assert.AreEqual(Null<int>.GetHashCode(b1), b2.GetHashCode());
VB.NET Copy Code
Dim cmp As IEqualityComparer(Of Null(Of Integer)) = Null(Of Integer).Comparer
Dim nil As Null(Of Integer) = Nothing
Dim a As Null(Of Integer) = 5
Dim b1 As Null(Of Integer) = 6
Dim b2 As Null(Of Integer) = 6

Assert.IsTrue(cmp.Equals(Nothing, nil))
Assert.IsTrue(cmp.Equals(nil, Nothing))
Assert.IsTrue(cmp.Equals(b1, b2))
Assert.IsFalse(cmp.Equals(a, b1))
Assert.IsFalse(cmp.Equals(b1, a))
Assert.IsFalse(cmp.Equals(nil, a))
Assert.IsFalse(cmp.Equals(a, nil))
Assert.IsFalse(cmp.Equals(Nothing, a))
Assert.IsFalse(cmp.Equals(a, Nothing))

Assert.IsTrue(Null(Of Integer).Equals(Nothing, nil))
Assert.IsTrue(Null(Of Integer).Equals(nil, Nothing))
Assert.IsTrue(Null(Of Integer).Equals(b1, b2))
Assert.IsFalse(Null(Of Integer).Equals(a, b1))
Assert.IsFalse(Null(Of Integer).Equals(b1, a))
Assert.IsFalse(Null(Of Integer).Equals(nil, a))
Assert.IsFalse(Null(Of Integer).Equals(a, nil))
Assert.IsFalse(Null(Of Integer).Equals(Nothing, a))
Assert.IsFalse(Null(Of Integer).Equals(a, Nothing))

Assert.AreNotEqual(a.GetHashCode(), b2.GetHashCode())
Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode())

Assert.AreEqual(cmp.GetHashCode(nil), 0)
Assert.AreEqual(cmp.GetHashCode(a), a.GetHashCode())
Assert.AreEqual(cmp.GetHashCode(b1), b2.GetHashCode())

Assert.AreEqual(Null(Of Integer).GetHashCode(nil), 0)
Assert.AreEqual(Null(Of Integer).GetHashCode(a), a.GetHashCode())
Assert.AreEqual(Null(Of Integer).GetHashCode(b1), b2.GetHashCode())

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members
Overload List

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class : GetHashCode Method

Glossary Item Box

Extracts the correct hash code

Overload List

Overload | Description
GetHashCode() | Extracts the correct hash code
GetHashCode(T) | Compares the two objects for non-reference equality

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members
Base Implementation in GetHashCode


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class > GetHashCode Method : GetHashCode() Method

Glossary Item Box

Extracts the correct hash code

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function GetHashCode() As Integer
C#
public override int GetHashCode()

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members
Overload List
Base Implementation in GetHashCode

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode(T) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class > GetHashCode Method : GetHashCode(T) Method

obj

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function GetHashCode( _
   ByVal obj As T _
) As Integer
C#
public static int GetHashCode(
   T obj
)

Parameters

obj

Example

Library/Library.Test/TestEquatable.cs

C# Copy Code
IEqualityComparer<Null<int>> cmp = Null<int>.Comparer;
Null<int> nil = null;
Null<int> a = 5;
Null<int> b1 = 6;
Null<int> b2 = 6;

Assert.IsTrue(cmp.Equals(null, nil));
Assert.IsTrue(cmp.Equals(nil, null));
Assert.IsTrue(cmp.Equals(b1, b2));
Assert.IsFalse(cmp.Equals(a, b1));
Assert.IsFalse(cmp.Equals(b1, a));
Assert.IsFalse(cmp.Equals(nil, a));
Assert.IsFalse(cmp.Equals(a, nil));
Assert.IsFalse(cmp.Equals(null, a));
Assert.IsFalse(cmp.Equals(a, null));

Assert.IsTrue(Null<int>.Equals(null, nil));
Assert.IsTrue(Null<int>.Equals(nil, null));
Assert.IsTrue(Null<int>.Equals(b1, b2));
Assert.IsFalse(Null<int>.Equals(a, b1));
Assert.IsFalse(Null<int>.Equals(b1, a));
Assert.IsFalse(Null<int>.Equals(nil, a));
Assert.IsFalse(Null<int>.Equals(a, nil));
Assert.IsFalse(Null<int>.Equals(null, a));
Assert.IsFalse(Null<int>.Equals(a, null));

Assert.AreNotEqual(a.GetHashCode(), b2.GetHashCode());
Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode());

Assert.AreEqual(cmp.GetHashCode(nil), 0);
Assert.AreEqual(cmp.GetHashCode(a), a.GetHashCode());
Assert.AreEqual(cmp.GetHashCode(b1), b2.GetHashCode());

Assert.AreEqual(Null<int>.GetHashCode(nil), 0);
Assert.AreEqual(Null<int>.GetHashCode(a), a.GetHashCode());
Assert.AreEqual(Null<int>.GetHashCode(b1), b2.GetHashCode());
VB.NET Copy Code
Dim cmp As IEqualityComparer(Of Null(Of Integer)) = Null(Of Integer).Comparer
Dim nil As Null(Of Integer) = Nothing
Dim a As Null(Of Integer) = 5
Dim b1 As Null(Of Integer) = 6
Dim b2 As Null(Of Integer) = 6

Assert.IsTrue(cmp.Equals(Nothing, nil))
Assert.IsTrue(cmp.Equals(nil, Nothing))
Assert.IsTrue(cmp.Equals(b1, b2))
Assert.IsFalse(cmp.Equals(a, b1))
Assert.IsFalse(cmp.Equals(b1, a))
Assert.IsFalse(cmp.Equals(nil, a))
Assert.IsFalse(cmp.Equals(a, nil))
Assert.IsFalse(cmp.Equals(Nothing, a))
Assert.IsFalse(cmp.Equals(a, Nothing))

Assert.IsTrue(Null(Of Integer).Equals(Nothing, nil))
Assert.IsTrue(Null(Of Integer).Equals(nil, Nothing))
Assert.IsTrue(Null(Of Integer).Equals(b1, b2))
Assert.IsFalse(Null(Of Integer).Equals(a, b1))
Assert.IsFalse(Null(Of Integer).Equals(b1, a))
Assert.IsFalse(Null(Of Integer).Equals(nil, a))
Assert.IsFalse(Null(Of Integer).Equals(a, nil))
Assert.IsFalse(Null(Of Integer).Equals(Nothing, a))
Assert.IsFalse(Null(Of Integer).Equals(a, Nothing))

Assert.AreNotEqual(a.GetHashCode(), b2.GetHashCode())
Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode())

Assert.AreEqual(cmp.GetHashCode(nil), 0)
Assert.AreEqual(cmp.GetHashCode(a), a.GetHashCode())
Assert.AreEqual(cmp.GetHashCode(b1), b2.GetHashCode())

Assert.AreEqual(Null(Of Integer).GetHashCode(nil), 0)
Assert.AreEqual(Null(Of Integer).GetHashCode(a), a.GetHashCode())
Assert.AreEqual(Null(Of Integer).GetHashCode(b1), b2.GetHashCode())

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members
Overload List

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Equatable<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Equatable<T> Class

Glossary Item Box

For a list of all members of this type, see Equatable<T> members.

Protected Properties

 | Name | Description
Protected Property | HashCode | Extracts the correct hash code
Top

See Also

Reference

Equatable<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashCode Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class : HashCode Property

Glossary Item Box

Extracts the correct hash code

Syntax

Visual Basic (Declaration)
Protected MustOverride ReadOnly Property HashCode As Integer
C#
protected abstract int HashCode {get;}

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
Equatable<T> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Equatable<T> Class

Glossary Item Box

For a list of all members of this type, see Equatable<T> members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | return a non-reference equality comparer for this class
Top

See Also

Reference

Equatable<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class : Comparer Field

Glossary Item Box

return a non-reference equality comparer for this class

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Comparer As Equatable(Of T)
C#
public static readonly Equatable<T> Comparer

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members

Used By

Boolean Equatable.Equals(Object)
Int32 Equatable.GetHashCode()
Boolean Equatable.Equals(T,T)
Int32 Equatable.GetHashCode(T)

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class : Equality Operator

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Operator =( _
   ByVal x As Equatable(Of T), _
   ByVal y As Equatable(Of T) _
) As Boolean
C#
public bool operator ==(
   Equatable<T> x,
   Equatable<T> y
)

Parameters

x
y

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
Salt scopy = Salt.FromBytes(s.ToArray());

Assert.AreEqual(s, scopy);
Assert.IsTrue(s.Equals(scopy));
Assert.IsTrue(s.Equals((object)scopy));
Assert.IsTrue(s == scopy);
Assert.IsFalse(s != scopy);
Assert.AreEqual(s.GetHashCode(), scopy.GetHashCode());

scopy = new Salt();
Assert.AreNotEqual(s, scopy);
Assert.IsFalse(s.Equals(scopy));
Assert.IsFalse(s.Equals((object)scopy));
Assert.IsFalse(s == scopy);
Assert.IsTrue(s != scopy);
Assert.AreNotEqual(s.GetHashCode(), scopy.GetHashCode());
VB.NET Copy Code
Dim s As New Salt()
Dim scopy As Salt = Salt.FromBytes(s.ToArray())

Assert.AreEqual(s, scopy)
Assert.IsTrue(s.Equals(scopy))
Assert.IsTrue(s.Equals(DirectCast(scopy, Object)))
Assert.IsTrue(s = scopy)
Assert.IsFalse(s <> scopy)
Assert.AreEqual(s.GetHashCode(), scopy.GetHashCode())

scopy = New Salt()
Assert.AreNotEqual(s, scopy)
Assert.IsFalse(s.Equals(scopy))
Assert.IsFalse(s.Equals(DirectCast(scopy, Object)))
Assert.IsFalse(s = scopy)
Assert.IsTrue(s <> scopy)
Assert.AreNotEqual(s.GetHashCode(), scopy.GetHashCode())

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members

Source Code

Library/Bases/Equatable.cs

Used By

Int32 Hash.CompareTo(Hash)


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable<T> Class : Inequality Operator

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Operator <>( _
   ByVal x As Equatable(Of T), _
   ByVal y As Equatable(Of T) _
) As Boolean
C#
public bool operator !=(
   Equatable<T> x,
   Equatable<T> y
)

Parameters

x
y

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
Salt scopy = Salt.FromBytes(s.ToArray());

Assert.AreEqual(s, scopy);
Assert.IsTrue(s.Equals(scopy));
Assert.IsTrue(s.Equals((object)scopy));
Assert.IsTrue(s == scopy);
Assert.IsFalse(s != scopy);
Assert.AreEqual(s.GetHashCode(), scopy.GetHashCode());

scopy = new Salt();
Assert.AreNotEqual(s, scopy);
Assert.IsFalse(s.Equals(scopy));
Assert.IsFalse(s.Equals((object)scopy));
Assert.IsFalse(s == scopy);
Assert.IsTrue(s != scopy);
Assert.AreNotEqual(s.GetHashCode(), scopy.GetHashCode());
VB.NET Copy Code
Dim s As New Salt()
Dim scopy As Salt = Salt.FromBytes(s.ToArray())

Assert.AreEqual(s, scopy)
Assert.IsTrue(s.Equals(scopy))
Assert.IsTrue(s.Equals(DirectCast(scopy, Object)))
Assert.IsTrue(s = scopy)
Assert.IsFalse(s <> scopy)
Assert.AreEqual(s.GetHashCode(), scopy.GetHashCode())

scopy = New Salt()
Assert.AreNotEqual(s, scopy)
Assert.IsFalse(s.Equals(scopy))
Assert.IsFalse(s.Equals(DirectCast(scopy, Object)))
Assert.IsFalse(s = scopy)
Assert.IsTrue(s <> scopy)
Assert.AreNotEqual(s.GetHashCode(), scopy.GetHashCode())

Requirements

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

See Also

Reference

Equatable<T> Class
Equatable<T> Members

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Equatable.EqualityComparer<T> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Equatable.EqualityComparer<T> Class

Glossary Item Box

Implements the equality comparer

Syntax

Visual Basic (Declaration)
Public NotInheritable Class Equatable.EqualityComparer(Of T As Equatable(Of T))
   Inherits System.Collections.Generic.EqualityComparer(Of T)
C#
public sealed class Equatable.EqualityComparer<T> : System.Collections.Generic.EqualityComparer<T>
where T: Equatable<T>

Type Parameters

T

Inheritance Hierarchy

System.Object
System.Collections.Generic.EqualityComparer<T>
CSharpTest.Net.Bases.Equatable`1.EqualityComparer<T>

Requirements

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

See Also

Reference

Equatable.EqualityComparer<T> Members
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Equatable.EqualityComparer<T> Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Equatable.EqualityComparer<T> Class

Glossary Item Box

The following tables list the members exposed by Equatable.EqualityComparer<T>.

Public Constructors

 | Name | Description
Public Constructor | Equatable.EqualityComparer<T> Constructor |
Top

Public Methods

 | Name | Description
Public Method | Equals | Overloaded. Overridden. Compares the two objects for non-reference equality
Public Method | GetHashCode | Overloaded. Overridden. Extracts the correct hash code
Top

See Also

Reference

Equatable.EqualityComparer<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equatable.EqualityComparer<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable.EqualityComparer<T> Class : Equatable.EqualityComparer<T> Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public Equatable.EqualityComparer<T>()

Requirements

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

See Also

Reference

Equatable.EqualityComparer<T> Class
Equatable.EqualityComparer<T> Members

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Equatable.EqualityComparer<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Equatable.EqualityComparer<T> Class

Glossary Item Box

For a list of all members of this type, see Equatable.EqualityComparer<T> members.

Public Methods

 | Name | Description
Public Method | Equals | Overloaded. Overridden. Compares the two objects for non-reference equality
Public Method | GetHashCode | Overloaded. Overridden. Extracts the correct hash code
Top

See Also

Reference

Equatable.EqualityComparer<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable.EqualityComparer<T> Class : Equals Method

Glossary Item Box

Compares the two objects for non-reference equality

Overload List

Overload | Description
Equals(T,T) | Compares the two objects for non-reference equality

Requirements

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

See Also

Reference

Equatable.EqualityComparer<T> Class
Equatable.EqualityComparer<T> Members
Base Implementation in Equals


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(T,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable.EqualityComparer<T> Class > Equals Method : Equals(T,T) Method

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Overloads Overrides NotOverridable Function Equals( _
   ByVal x As T, _
   ByVal y As T _
) As Boolean
C#
public override bool Equals(
   T x,
   T y
)

Parameters

x
y

Requirements

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

See Also

Reference

Equatable.EqualityComparer<T> Class
Equatable.EqualityComparer<T> Members
Overload List
Base Implementation in Equals(T,T)

Source Code

Library/Bases/Equatable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable.EqualityComparer<T> Class : GetHashCode Method

Glossary Item Box

Extracts the correct hash code

Overload List

Overload | Description
GetHashCode(T) | Extracts the correct hash code

Requirements

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

See Also

Reference

Equatable.EqualityComparer<T> Class
Equatable.EqualityComparer<T> Members
Base Implementation in GetHashCode


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode(T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Equatable.EqualityComparer<T> Class > GetHashCode Method : GetHashCode(T) Method

obj

Glossary Item Box

Extracts the correct hash code

Syntax

Visual Basic (Declaration)
Public Overloads Overrides NotOverridable Function GetHashCode( _
   ByVal obj As T _
) As Integer
C#
public override int GetHashCode(
   T obj
)

Parameters

obj

Requirements

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

See Also

Reference

Equatable.EqualityComparer<T> Class
Equatable.EqualityComparer<T> Members
Overload List
Base Implementation in GetHashCode(T)

Source Code

Library/Bases/Equatable.cs


%%ItemTitle%%

CSharpTest.Net.Cloning Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Cloning Namespace

Glossary Item Box

Classes

 | Class | Description
Class | ClonableExtensions | Extension method for DeepClone<T>() on every object.
Class | MemberwiseClone | Provides a deep-copy, field-level duplication of any object
Class | ObjectCloner | A class that performs duplication of an entire object graph
Class | ReferenceEqualityComparer | Dictionary comparer for comparing objects by reference reguardless of having the GetHashCode / Equals override implemented on an object.
Class | SerializerClone | Used to duplicate objects either by the ISerializable interface or by field-level duplication.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
ClonableExtensions Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ClonableExtensions Class

Glossary Item Box

Extension method for DeepClone<T>() on every object.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class ClonableExtensions
C#
public static class ClonableExtensions

Inheritance Hierarchy

System.Object
CSharpTest.Net.Cloning.ClonableExtensions

Requirements

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

See Also

Reference

ClonableExtensions Members
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/ClonableExtensions.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ClonableExtensions Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ClonableExtensions Class

Glossary Item Box

The following tables list the members exposed by ClonableExtensions.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DeepClone<T> | Provides a deep-clone of objects using either serialization routines if available or memberwize cloning when serialization is not supported. See also: new SerializerClone().Clone<T>(instance)
Top

See Also

Reference

ClonableExtensions Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/ClonableExtensions.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ClonableExtensions Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ClonableExtensions Class

Glossary Item Box

For a list of all members of this type, see ClonableExtensions members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DeepClone<T> | Provides a deep-clone of objects using either serialization routines if available or memberwize cloning when serialization is not supported. See also: new SerializerClone().Clone<T>(instance)
Top

See Also

Reference

ClonableExtensions Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/ClonableExtensions.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
DeepClone<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ClonableExtensions Class : DeepClone<T> Method

instance

Glossary Item Box

Provides a deep-clone of objects using either serialization routines if available or memberwize cloning when serialization is not supported. See also: new SerializerClone().Clone<T>(instance)

Syntax

Visual Basic (Declaration)
Public Shared Function DeepClone(Of T)( _
   ByVal instance As T _
) As T
C#
public static T DeepClone<T>(
   T instance
)

Parameters

instance

Type Parameters

T

Requirements

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

See Also

Reference

ClonableExtensions Class
ClonableExtensions Members

Source Code

Library/Cloning/ClonableExtensions.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MemberwiseClone Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : MemberwiseClone Class

Glossary Item Box

Provides a deep-copy, field-level duplication of any object

Syntax

Visual Basic (Declaration)
Public Class MemberwiseClone
   Inherits ObjectCloner
C#
public class MemberwiseClone : ObjectCloner

Example

Library/Library.Test/TestCloning.cs

C# Copy Code
const int Reps = 1000;
TestObject test = TestObject.Create();
object result;

Stopwatch timer = new Stopwatch();
timer.Start();

for (int i = 0; i < Reps; i++)
{
    BinaryFormatter bf = new BinaryFormatter();
    using (MemoryStream m = new MemoryStream())
    {
        bf.Serialize(m, test);
        m.Position = 0;
        result = bf.Deserialize(m);
    }
}

timer.Stop();
Console.WriteLine("Elapsed: {0,10} (100%)", timer.ElapsedTicks);
long percentof = timer.ElapsedTicks;

timer = new Stopwatch();
timer.Start();

for (int i = 0; i < Reps; i++)
{
    result = new SerializerClone().Clone(test);
}

timer.Stop();
Console.WriteLine("Elapsed: {0,10} ({1}%)", timer.ElapsedTicks, (timer.ElapsedTicks * 100) / percentof);

timer = new Stopwatch();
timer.Start();

for (int i = 0; i < Reps; i++)
{
    result = new MemberwiseClone().Clone(test);
}

timer.Stop();
Console.WriteLine("Elapsed: {0,10} ({1}%)", timer.ElapsedTicks, (timer.ElapsedTicks * 100) / percentof);
VB.NET Copy Code
Const  Reps As Integer = 1000
Dim test As TestObject = TestObject.Create()
Dim result As Object

Dim timer As New Stopwatch()
timer.Start()

Dim i As Integer = 0
While i < Reps
    Dim bf As New BinaryFormatter()
    Using m As New MemoryStream()
        bf.Serialize(m, test)
        m.Position = 0
        result = bf.Deserialize(m)
    End Using
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

timer.[Stop]()
Console.WriteLine("Elapsed: {0,10} (100%)", timer.ElapsedTicks)
Dim percentof As Long = timer.ElapsedTicks

timer = New Stopwatch()
timer.Start()

Dim i As Integer = 0
While i < Reps
    result = New SerializerClone().Clone(test)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

timer.[Stop]()
Console.WriteLine("Elapsed: {0,10} ({1}%)", timer.ElapsedTicks, (timer.ElapsedTicks * 100) / percentof)

timer = New Stopwatch()
timer.Start()

Dim i As Integer = 0
While i < Reps
    result = New MemberwiseClone().Clone(test)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

timer.[Stop]()
Console.WriteLine("Elapsed: {0,10} ({1}%)", timer.ElapsedTicks, (timer.ElapsedTicks * 100) / percentof)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Cloning.ObjectCloner
CSharpTest.Net.Cloning.MemberwiseClone
CSharpTest.Net.Cloning.SerializerClone

Requirements

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

See Also

Reference

MemberwiseClone Members
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/MemberwiseClone.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
MemberwiseClone Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : MemberwiseClone Class

Glossary Item Box

The following tables list the members exposed by MemberwiseClone.

Public Constructors

 | Name | Description
Public Constructor | MemberwiseClone Constructor | Provides a deep-copy, field-level duplication of any object
Top

Public Properties

 | Name | Description
Public Property | Graph | Add or Remove instances from the object graph, by adding this.Graph[o] = o; the instance 'o' will not be duplicated. (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

Public Methods

 | Name | Description
Public Method | Clear | Removes all instances from the object graph (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Public Method | Clone<T> | Public entry point to begin duplication of the object graph. (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Public Method | Dispose | Disposes of the instance and it's references to objects that have been duplicated (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

Protected Methods

 | Name | Description
Protected Method | CloneDefault | Overridden. Routine to clone an objects fields and their contents
Protected Method | CloneObject<T> | Internal duplicate an object graph (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

See Also

Reference

MemberwiseClone Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/MemberwiseClone.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MemberwiseClone Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > MemberwiseClone Class : MemberwiseClone Constructor

Glossary Item Box

Provides a deep-copy, field-level duplication of any object

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public MemberwiseClone()

Example

Library/Library.Test/TestCloning.cs

C# Copy Code
const int Reps = 1000;
TestObject test = TestObject.Create();
object result;

Stopwatch timer = new Stopwatch();
timer.Start();

for (int i = 0; i < Reps; i++)
{
    BinaryFormatter bf = new BinaryFormatter();
    using (MemoryStream m = new MemoryStream())
    {
        bf.Serialize(m, test);
        m.Position = 0;
        result = bf.Deserialize(m);
    }
}

timer.Stop();
Console.WriteLine("Elapsed: {0,10} (100%)", timer.ElapsedTicks);
long percentof = timer.ElapsedTicks;

timer = new Stopwatch();
timer.Start();

for (int i = 0; i < Reps; i++)
{
    result = new SerializerClone().Clone(test);
}

timer.Stop();
Console.WriteLine("Elapsed: {0,10} ({1}%)", timer.ElapsedTicks, (timer.ElapsedTicks * 100) / percentof);

timer = new Stopwatch();
timer.Start();

for (int i = 0; i < Reps; i++)
{
    result = new MemberwiseClone().Clone(test);
}

timer.Stop();
Console.WriteLine("Elapsed: {0,10} ({1}%)", timer.ElapsedTicks, (timer.ElapsedTicks * 100) / percentof);
VB.NET Copy Code
Const  Reps As Integer = 1000
Dim test As TestObject = TestObject.Create()
Dim result As Object

Dim timer As New Stopwatch()
timer.Start()

Dim i As Integer = 0
While i < Reps
    Dim bf As New BinaryFormatter()
    Using m As New MemoryStream()
        bf.Serialize(m, test)
        m.Position = 0
        result = bf.Deserialize(m)
    End Using
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

timer.[Stop]()
Console.WriteLine("Elapsed: {0,10} (100%)", timer.ElapsedTicks)
Dim percentof As Long = timer.ElapsedTicks

timer = New Stopwatch()
timer.Start()

Dim i As Integer = 0
While i < Reps
    result = New SerializerClone().Clone(test)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

timer.[Stop]()
Console.WriteLine("Elapsed: {0,10} ({1}%)", timer.ElapsedTicks, (timer.ElapsedTicks * 100) / percentof)

timer = New Stopwatch()
timer.Start()

Dim i As Integer = 0
While i < Reps
    result = New MemberwiseClone().Clone(test)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

timer.[Stop]()
Console.WriteLine("Elapsed: {0,10} ({1}%)", timer.ElapsedTicks, (timer.ElapsedTicks * 100) / percentof)

Requirements

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

See Also

Reference

MemberwiseClone Class
MemberwiseClone Members

Source Code

Library/Cloning/MemberwiseClone.cs

Used By

ScriptEngine ScriptEngine.GetDefaults(ScriptEngine.Language)


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
MemberwiseClone Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : MemberwiseClone Class

Glossary Item Box

For a list of all members of this type, see MemberwiseClone members.

Public Methods

 | Name | Description
Public Method | Clear | Removes all instances from the object graph (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Public Method | Clone<T> | Public entry point to begin duplication of the object graph. (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Public Method | Dispose | Disposes of the instance and it's references to objects that have been duplicated (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

Protected Methods

 | Name | Description
Protected Method | CloneDefault | Overridden. Routine to clone an objects fields and their contents
Protected Method | CloneObject<T> | Internal duplicate an object graph (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

See Also

Reference

MemberwiseClone Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/MemberwiseClone.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CloneDefault Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > MemberwiseClone Class : CloneDefault Method

instance

Glossary Item Box

Routine to clone an objects fields and their contents

Syntax

Visual Basic (Declaration)
Protected Overrides Function CloneDefault( _
   ByVal instance As Object _
) As Object
C#
protected override object CloneDefault(
   object instance
)

Parameters

instance

Requirements

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

See Also

Reference

MemberwiseClone Class
MemberwiseClone Members
Base Implementation in CloneDefault


%%PageItemTitle%%

[image]
CSharpTest.Net
ObjectCloner Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ObjectCloner Class

Glossary Item Box

A class that performs duplication of an entire object graph

Syntax

Visual Basic (Declaration)
Public MustInherit Class ObjectCloner
C#
public abstract class ObjectCloner

Inheritance Hierarchy

System.Object
CSharpTest.Net.Cloning.ObjectCloner
CSharpTest.Net.Cloning.MemberwiseClone

Requirements

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

See Also

Reference

ObjectCloner Members
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/ObjectCloner.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ObjectCloner Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ObjectCloner Class

Glossary Item Box

The following tables list the members exposed by ObjectCloner.

Protected Constructors

 | Name | Description
Protected Constructor | ObjectCloner Constructor | Creates the cloner
Top

Public Properties

 | Name | Description
Public Property | Graph | Add or Remove instances from the object graph, by adding this.Graph[o] = o; the instance 'o' will not be duplicated.
Top

Public Methods

 | Name | Description
Public Method | Clear | Removes all instances from the object graph
Public Method | Clone<T> | Public entry point to begin duplication of the object graph.
Public Method | Dispose | Disposes of the instance and it's references to objects that have been duplicated
Top

Protected Methods

 | Name | Description
Protected Method | CloneDefault | Provides the default behavior for duplicating an object and recording the duplication into the graph.
Protected Method | CloneObject<T> | Internal duplicate an object graph
Top

See Also

Reference

ObjectCloner Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/ObjectCloner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ObjectCloner Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ObjectCloner Class : ObjectCloner Constructor

Glossary Item Box

Creates the cloner

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected ObjectCloner()

Requirements

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

See Also

Reference

ObjectCloner Class
ObjectCloner Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ObjectCloner Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ObjectCloner Class

Glossary Item Box

For a list of all members of this type, see ObjectCloner members.

Public Methods

 | Name | Description
Public Method | Clear | Removes all instances from the object graph
Public Method | Clone<T> | Public entry point to begin duplication of the object graph.
Public Method | Dispose | Disposes of the instance and it's references to objects that have been duplicated
Top

Protected Methods

 | Name | Description
Protected Method | CloneDefault | Provides the default behavior for duplicating an object and recording the duplication into the graph.
Protected Method | CloneObject<T> | Internal duplicate an object graph
Top

See Also

Reference

ObjectCloner Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/ObjectCloner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ObjectCloner Class : Clear Method

Glossary Item Box

Removes all instances from the object graph

Syntax

Visual Basic (Declaration)
Public Overridable Sub Clear()
C#
public virtual void Clear()

Requirements

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

See Also

Reference

ObjectCloner Class
ObjectCloner Members

Used By

ObjectCloner.Dispose()
T ObjectCloner.Clone(T)

Source Code

Library/Cloning/ObjectCloner.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Clone<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ObjectCloner Class : Clone<T> Method

instance

Glossary Item Box

Public entry point to begin duplication of the object graph.

Syntax

Visual Basic (Declaration)
Public Overridable Function Clone(Of T)( _
   ByVal instance As T _
) As T
C#
public virtual T Clone<T>(
   T instance
)

Parameters

instance

Type Parameters

T

Requirements

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

See Also

Reference

ObjectCloner Class
ObjectCloner Members

Source Code

Library/Cloning/ObjectCloner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CloneDefault Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ObjectCloner Class : CloneDefault Method

inst

Glossary Item Box

Provides the default behavior for duplicating an object and recording the duplication into the graph.

Syntax

Visual Basic (Declaration)
Protected MustOverride Function CloneDefault( _
   ByVal inst As Object _
) As Object
C#
protected abstract object CloneDefault(
   object inst
)

Parameters

inst

Requirements

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

See Also

Reference

ObjectCloner Class
ObjectCloner Members


%%PageItemTitle%%

T
[image]
CSharpTest.Net
CloneObject<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ObjectCloner Class : CloneObject<T> Method

instance

Glossary Item Box

Internal duplicate an object graph

Syntax

Visual Basic (Declaration)
Protected Function CloneObject(Of T)( _
   ByVal instance As T _
) As T
C#
protected T CloneObject<T>(
   T instance
)

Parameters

instance

Type Parameters

T

Requirements

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

See Also

Reference

ObjectCloner Class
ObjectCloner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ObjectCloner Class : Dispose Method

Glossary Item Box

Disposes of the instance and it's references to objects that have been duplicated

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

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

See Also

Reference

ObjectCloner Class
ObjectCloner Members

Source Code

Library/Cloning/ObjectCloner.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ObjectCloner Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ObjectCloner Class

Glossary Item Box

For a list of all members of this type, see ObjectCloner members.

Public Properties

 | Name | Description
Public Property | Graph | Add or Remove instances from the object graph, by adding this.Graph[o] = o; the instance 'o' will not be duplicated.
Top

See Also

Reference

ObjectCloner Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/ObjectCloner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Graph Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ObjectCloner Class : Graph Property

Glossary Item Box

Add or Remove instances from the object graph, by adding this.Graph[o] = o; the instance 'o' will not be duplicated.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Graph As IDictionary(Of Object,Object)
C#
public IDictionary<object,object> Graph {get;}

Requirements

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

See Also

Reference

ObjectCloner Class
ObjectCloner Members

Source Code

Library/Cloning/ObjectCloner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReferenceEqualityComparer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ReferenceEqualityComparer Class

Glossary Item Box

Dictionary comparer for comparing objects by reference reguardless of having the GetHashCode / Equals override implemented on an object.

Syntax

Visual Basic (Declaration)
Public NotInheritable Class ReferenceEqualityComparer
C#
public sealed class ReferenceEqualityComparer

Inheritance Hierarchy

System.Object
CSharpTest.Net.Cloning.ReferenceEqualityComparer

Requirements

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

See Also

Reference

ReferenceEqualityComparer Members
CSharpTest.Net.Cloning Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ReferenceEqualityComparer Class Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : ReferenceEqualityComparer Class

Glossary Item Box

The following tables list the members exposed by ReferenceEqualityComparer.

Public Constructors

 | Name | Description
Public Constructor | ReferenceEqualityComparer Constructor |
Top

See Also

Reference

ReferenceEqualityComparer Class
CSharpTest.Net.Cloning Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
ReferenceEqualityComparer Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > ReferenceEqualityComparer Class : ReferenceEqualityComparer Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public ReferenceEqualityComparer()

Requirements

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

See Also

Reference

ReferenceEqualityComparer Class
ReferenceEqualityComparer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SerializerClone Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : SerializerClone Class

Glossary Item Box

Used to duplicate objects either by the ISerializable interface or by field-level duplication.

Syntax

Visual Basic (Declaration)
Public Class SerializerClone
   Inherits MemberwiseClone
C#
public class SerializerClone : MemberwiseClone

Example

Library/Library.Test/TestWeakReferenceT.cs

C# Copy Code
string value = "Testing Value";
Utils.WeakReference<string> r;
r = new Utils.WeakReference<string>(value);
Utils.WeakReference<string> r2 = new Cloning.SerializerClone().Clone(r);

Assert.AreEqual(r.Target, r2.Target);
Assert.AreEqual(value, r2.Target);
string tmp;
Assert.IsTrue(r2.TryGetTarget(out tmp) && tmp == value);
VB.NET Copy Code
Dim value As String = "Testing Value"
Dim r As Utils.WeakReference(Of String)
r = New Utils.WeakReference(Of String)(value)
Dim r2 As Utils.WeakReference(Of String) = New Cloning.SerializerClone().Clone(r)

Assert.AreEqual(r.Target, r2.Target)
Assert.AreEqual(value, r2.Target)
Dim tmp As String
Assert.IsTrue(r2.TryGetTarget(tmp) AndAlso tmp = value)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Cloning.ObjectCloner
CSharpTest.Net.Cloning.MemberwiseClone
CSharpTest.Net.Cloning.SerializerClone

Requirements

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

See Also

Reference

SerializerClone Members
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/SerializerClone.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SerializerClone Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : SerializerClone Class

Glossary Item Box

The following tables list the members exposed by SerializerClone.

Public Constructors

 | Name | Description
Public Constructor | SerializerClone Constructor | Used to duplicate objects either by the ISerializable interface or by field-level duplication.
Top

Public Properties

 | Name | Description
Public Property | Graph | Add or Remove instances from the object graph, by adding this.Graph[o] = o; the instance 'o' will not be duplicated. (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

Public Methods

 | Name | Description
Public Method | Clear | Removes all instances from the object graph (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Public Method | Clone<T> | Overridden. Public entry point to begin duplication of the object graph. If your using this instance multiple times you should call Clear() between the object graphs or the copies previously made will be used.
Public Method | Dispose | Disposes of the instance and it's references to objects that have been duplicated (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

Protected Methods

 | Name | Description
Protected Method | CloneDefault | Overridden. If the object provided is [Serializable] a simulated serialization routine is used to duplicate the object, if it's not serializable then the MemberwiseClone base class will perform the copy.
Protected Method | CloneObject<T> | Internal duplicate an object graph (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

See Also

Reference

SerializerClone Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/SerializerClone.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SerializerClone Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > SerializerClone Class : SerializerClone Constructor

Glossary Item Box

Used to duplicate objects either by the ISerializable interface or by field-level duplication.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public SerializerClone()

Example

Library/Library.Test/TestWeakReferenceT.cs

C# Copy Code
string value = "Testing Value";
Utils.WeakReference<string> r;
r = new Utils.WeakReference<string>(value);
Utils.WeakReference<string> r2 = new Cloning.SerializerClone().Clone(r);

Assert.AreEqual(r.Target, r2.Target);
Assert.AreEqual(value, r2.Target);
string tmp;
Assert.IsTrue(r2.TryGetTarget(out tmp) && tmp == value);
VB.NET Copy Code
Dim value As String = "Testing Value"
Dim r As Utils.WeakReference(Of String)
r = New Utils.WeakReference(Of String)(value)
Dim r2 As Utils.WeakReference(Of String) = New Cloning.SerializerClone().Clone(r)

Assert.AreEqual(r.Target, r2.Target)
Assert.AreEqual(value, r2.Target)
Dim tmp As String
Assert.IsTrue(r2.TryGetTarget(tmp) AndAlso tmp = value)

Requirements

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

See Also

Reference

SerializerClone Class
SerializerClone Members

Used By

T ClonableExtensions.DeepClone(T)

Source Code

Library/Cloning/SerializerClone.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SerializerClone Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : SerializerClone Class

Glossary Item Box

For a list of all members of this type, see SerializerClone members.

Public Methods

 | Name | Description
Public Method | Clear | Removes all instances from the object graph (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Public Method | Clone<T> | Overridden. Public entry point to begin duplication of the object graph. If your using this instance multiple times you should call Clear() between the object graphs or the copies previously made will be used.
Public Method | Dispose | Disposes of the instance and it's references to objects that have been duplicated (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

Protected Methods

 | Name | Description
Protected Method | CloneDefault | Overridden. If the object provided is [Serializable] a simulated serialization routine is used to duplicate the object, if it's not serializable then the MemberwiseClone base class will perform the copy.
Protected Method | CloneObject<T> | Internal duplicate an object graph (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

See Also

Reference

SerializerClone Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/SerializerClone.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Clone<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > SerializerClone Class : Clone<T> Method

instance

Glossary Item Box

Public entry point to begin duplication of the object graph. If your using this instance multiple times you should call Clear() between the object graphs or the copies previously made will be used.

Syntax

Visual Basic (Declaration)
Public Overrides Function Clone(Of T)( _
   ByVal instance As T _
) As T
C#
public override T Clone<T>(
   T instance
)

Parameters

instance

Type Parameters

T

Requirements

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

See Also

Reference

SerializerClone Class
SerializerClone Members
Base Implementation in Clone<T>

Source Code

Library/Cloning/SerializerClone.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CloneDefault Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace > SerializerClone Class : CloneDefault Method

instance

Glossary Item Box

If the object provided is [Serializable] a simulated serialization routine is used to duplicate the object, if it's not serializable then the MemberwiseClone base class will perform the copy.

Syntax

Visual Basic (Declaration)
Protected Overrides Function CloneDefault( _
   ByVal instance As Object _
) As Object
C#
protected override object CloneDefault(
   object instance
)

Parameters

instance

Requirements

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

See Also

Reference

SerializerClone Class
SerializerClone Members
Base Implementation in CloneDefault


%%ItemTitle%%

CSharpTest.Net.Collections Namespace (CSharpTest.Net.Library)
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Collections Namespace

Glossary Item Box

Classes

 | Class | Description
Class | BTreeDictionary<TKey,TValue> | Implements an IDictionary interface for an in-memory B+Tree
Class | BTreeList<T> | Implements an IList interface for an in-memory B+Tree of unique values
Class | DisposingList | Disposes of each element in the collection when the collection is disposed.
Class | DisposingList<T> | Disposes of each element in the collection when the collection is disposed.
Class | HashUtilities |
Class | KeyValueComparer<TKey,TValue> | Represents a key-value comparison
Class | LListNode | The basic Linked-list node, untyped, use LListNode<T> for strong typed nodes and lists.
Class | LListNode<T> | A typed node, used similiarly to LinkedListNode<T>. Can belong to single list at a time, the type of list is usually LListNode<T>.LList
Class | LListNode.LList<T> | Provides a linked list of nodes of type T
Class | LListNode.LList | Provides a linked list of nodes of type T
Class | LListNode.LList<TNode> | Provides a linked list of nodes of type T
Class | LurchTable<TKey,TValue> | LurchTable stands for "Least Used Recently Concurrent Hash Table" and has definate similarities to both the .NET 4 ConcurrentDictionary as well as Java's LinkedHashMap. This gives you a thread-safe dictionary/hashtable that stores element ordering by insertion, updates, or access. In addition it can be configured to use a 'hard-limit' count of items that will automatically 'pop' the oldest item in the collection.
Class | LurchTable.KeyCollection<TKey,TValue> | Provides the collection of Keys for the LurchTable
Class | LurchTable.ValueCollection<TKey,TValue> | Provides the collection of Values for the LurchTable
Class | MergeSort | Provides a stable array sort based on merge-sort using O(n) additional memory. As a release build, this routine will operate faster than Array.Sort when using a custom (non-default) comparison. It also has the advantange of being stable, that is it preserves the order of elements that compare as being of equal value.
Class | OrderedEnumeration<T> | Creates an ordered enumeration from an unordered enumeration by paginating the data, sorting the page, and then performing a binary-tree grouped mergesort on the resulting pages. When the page size (memoryLimit) is hit, the page will be unloaded to disk and restored on demand if a serializer is provided.
Class | OrderedKeyValuePairs<TKey,TValue> | Speicalizes the OrderedEnumeration of T to use key/value pairs with a key comparer.
Class | OrdinalList | An ordinal list is a list optimized to store lists of integer data that can then be manipulated as a set with intersect/union etc. Each integer stored is translated to a bit offset and thus cann't be stored more than once or in any particular order. Note: adding the value int.Max will allocate int.Max/8 bytes of memory, so this is best used with ordinal indexes into a list that is smaller than 8,388,608 (one megabyte of bits). Pre-allocate with Ceiling = max for better performance, or add the integers in reverse order (highest to lowest).
Class | ReadOnlyList<T> | A readonly list of T
Class | SetList<T> | Represents an immutable collection of unique items that can be manipulated as a set, intersect/union/etc.
Class | SynchronizedDictionary<TKey,TValue> | Represents a thread-safe generic collection of key/value pairs.
Class | SynchronizedList<T> | Represents a collection of objects that can be individually accessed by index.

Interfaces

 | Interface | Description
Interface | IConcurrentDictionary<TKey,TValue> | Extends the IDictionaryEx interface to encompass concurrent/atomic operations
Interface | ICreateOrUpdateValue<TKey,TValue> | An interface to provide conditional or custom creation or update logic to a concurrent dictionary.
Interface | ICreateValue<TKey,TValue> | An interface to provide conditional or custom creation logic to a concurrent dictionary.
Interface | IDictionaryEx<TKey,TValue> | Extends the IDictionary interface to encompass the TryXxxx operations
Interface | IReadOnlyCollection<T> | Provides common interface members for the implementation of a Set
Interface | IRemoveValue<TKey,TValue> | An interface to provide conditional removal of an item from a concurrent dictionary.
Interface | IUpdateValue<TKey,TValue> | An interface to provide conditional or custom update logic to a concurrent dictionary.

Structures

 | Structure | Description
Structure | LurchTable.Enumerator<TKey,TValue> | Provides an enumerator that iterates through the collection.
Structure | LurchTable.KeyCollection.Enumerator<TKey,TValue> | Provides an enumerator that iterates through the collection.
Structure | LurchTable.ValueCollection.Enumerator<TKey,TValue> | Provides an enumerator that iterates through the collection.

Delegates

 | Delegate | Description
Delegate | KeyValuePredicate<TKey,TValue> | Provides a delegate that performs a test on key/value pair
Delegate | KeyValueUpdate<TKey,TValue> | Provides a delegate that performs an atomic update of a key/value pair
Delegate | LurchTable.ItemUpdatedMethod<TKey,TValue> | Method signature for the ItemUpdated event

Enumerations

 | Enumeration | Description
Enumeration | DuplicateHandling | Defines how duplicate keys are handled
Enumeration | LurchTableOrder | Defines if and how items added to a LurchTable are linked together, this defines the value returned from Peek/Dequeue as the oldest entry of the specified operation.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeDictionary<TKey,TValue> Class

Glossary Item Box

Implements an IDictionary interface for an in-memory B+Tree

Object Model

BTreeDictionary<TKey,TValue> ClassTValue Class

Syntax

Visual Basic (Declaration)
Public Class BTreeDictionary
    (Of TKey,TValue)
   Implements IDictionaryEx(Of TKey,TValue)
C#
public class BTreeDictionary<TKey,TValue> : IDictionaryEx<TKey,TValue>

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>();
data.Add(1, "a");
data.Add(2, "b");
data.Add(3, "c");
data.Add(4, "d");
data.Add(5, "e");

Assert.AreEqual(1, data.First().Key);
Assert.AreEqual("a", data.First().Value);
data.Remove(1);
Assert.AreEqual(2, data.First().Key);
Assert.AreEqual("b", data.First().Value);

Assert.AreEqual(5, data.Last().Key);
Assert.AreEqual("e", data.Last().Value);
data.Remove(5);
Assert.AreEqual(4, data.Last().Key);
Assert.AreEqual("d", data.Last().Value);

data.Remove(4);
data.Remove(3);

KeyValuePair<int, string> kv;
Assert.IsTrue(data.TryGetLast(out kv));
Assert.IsTrue(data.TryGetFirst(out kv));
data.Remove(2);
Assert.IsFalse(data.TryGetLast(out kv));
Assert.IsFalse(data.TryGetFirst(out kv));

try
{
    data.First();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
try
{
    data.Last();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)()
data.Add(1, "a")
data.Add(2, "b")
data.Add(3, "c")
data.Add(4, "d")
data.Add(5, "e")

Assert.AreEqual(1, data.First().Key)
Assert.AreEqual("a", data.First().Value)
data.Remove(1)
Assert.AreEqual(2, data.First().Key)
Assert.AreEqual("b", data.First().Value)

Assert.AreEqual(5, data.Last().Key)
Assert.AreEqual("e", data.Last().Value)
data.Remove(5)
Assert.AreEqual(4, data.Last().Key)
Assert.AreEqual("d", data.Last().Value)

data.Remove(4)
data.Remove(3)

Dim kv As KeyValuePair(Of Integer, String)
Assert.IsTrue(data.TryGetLast(kv))
Assert.IsTrue(data.TryGetFirst(kv))
data.Remove(2)
Assert.IsFalse(data.TryGetLast(kv))
Assert.IsFalse(data.TryGetFirst(kv))

Try
    data.First()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try
Try
    data.Last()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BTreeDictionary<TKey,TValue>

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeDictionary<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by BTreeDictionary<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | BTreeDictionary<TKey,TValue> Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | DefaultOrder | The default `order` of the B+Tree structure.
Top

Public Properties

 | Name | Description
Public Property | Comparer | Gets the Comparer provided to the constructor or Comparer<TKey>.Default if it was not provided.
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | IsReadOnly | Gets a value indicating whether the ICollection is read-only.
Public Property | Item | Gets or sets the element with the specified key.
Public Property | Keys | Gets an ICollection containing the keys of the IDictionary.
Public Property | Values | Gets an ICollection containing the values in the IDictionary.
Top

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds an element with the provided key and value to the IDictionary.
Public Method | AddRange | Adds a set of items to the ICollection.
Public Method | Clear | Removes all items from the ICollection.
Public Method | Clone | Returns a writable clone of this collection.
Public Method | Contains | Determines whether the ICollection contains a specific key and value pair.
Public Method | ContainsKey | Determines whether the IDictionary contains an element with the specified key.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | DebugAssert | Ensures data integrity or raises exception
Public Method | EnumerateFrom | Inclusivly enumerates from start key to the end of the collection
Public Method | EnumerateRange | Inclusivly enumerates from start key to stop key
Public Method | First | Returns the first key and it's associated value.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | GetOrAdd | Adds a key/value pair to the IDictionary if the key does not already exist.
Public Method | Last | Returns the last key and it's associated value.
Public Method | MakeReadOnly | Returns a read-only clone of this collection. If this instance is already read-only the method will return this.
Public Method | Remove | Overloaded. Removes the element with the specified key from the IDictionary.
Public Method | ToArray | Returns all the items of this collection as an array of KeyValuePair.
Public Method | TryAdd | Adds an element with the provided key and value to the IDictionary.
Public Method | TryGetFirst | Returns the first key and it's associated value.
Public Method | TryGetLast | Returns the last key and it's associated value.
Public Method | TryGetValue | Gets the value associated with the specified key.
Public Method | TryRemove | Removes the element with the specified key from the IDictionary.
Public Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Top

See Also

Reference

BTreeDictionary<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : BTreeDictionary<TKey,TValue> Constructor

Glossary Item Box

Overload List

Overload | Description
BTreeDictionary<TKey,TValue> Constructor() | Constructs a BTreeList instance.
BTreeDictionary<TKey,TValue> Constructor(IComparer<TKey>) | Constructs a BTreeList instance.
BTreeDictionary<TKey,TValue> Constructor(Int32,IComparer<TKey>) | Constructs a BTreeList instance.
BTreeDictionary<TKey,TValue> Constructor(IEnumerable<KeyValuePair<TKey,TValue>>) | Constructs a BTreeList instance.
BTreeDictionary<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>) | Constructs a BTreeList instance.
BTreeDictionary<TKey,TValue> Constructor(Int32,IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>) | Constructs a BTreeList instance.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > BTreeDictionary<TKey,TValue> Constructor : BTreeDictionary<TKey,TValue> Constructor()

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public BTreeDictionary<TKey,TValue>()

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>();
data.Add(1, "a");
data.Add(2, "b");
data.Add(3, "c");
data.Add(4, "d");
data.Add(5, "e");

Assert.AreEqual(1, data.First().Key);
Assert.AreEqual("a", data.First().Value);
data.Remove(1);
Assert.AreEqual(2, data.First().Key);
Assert.AreEqual("b", data.First().Value);

Assert.AreEqual(5, data.Last().Key);
Assert.AreEqual("e", data.Last().Value);
data.Remove(5);
Assert.AreEqual(4, data.Last().Key);
Assert.AreEqual("d", data.Last().Value);

data.Remove(4);
data.Remove(3);

KeyValuePair<int, string> kv;
Assert.IsTrue(data.TryGetLast(out kv));
Assert.IsTrue(data.TryGetFirst(out kv));
data.Remove(2);
Assert.IsFalse(data.TryGetLast(out kv));
Assert.IsFalse(data.TryGetFirst(out kv));

try
{
    data.First();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
try
{
    data.Last();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)()
data.Add(1, "a")
data.Add(2, "b")
data.Add(3, "c")
data.Add(4, "d")
data.Add(5, "e")

Assert.AreEqual(1, data.First().Key)
Assert.AreEqual("a", data.First().Value)
data.Remove(1)
Assert.AreEqual(2, data.First().Key)
Assert.AreEqual("b", data.First().Value)

Assert.AreEqual(5, data.Last().Key)
Assert.AreEqual("e", data.Last().Value)
data.Remove(5)
Assert.AreEqual(4, data.Last().Key)
Assert.AreEqual("d", data.Last().Value)

data.Remove(4)
data.Remove(3)

Dim kv As KeyValuePair(Of Integer, String)
Assert.IsTrue(data.TryGetLast(kv))
Assert.IsTrue(data.TryGetFirst(kv))
data.Remove(2)
Assert.IsFalse(data.TryGetLast(kv))
Assert.IsFalse(data.TryGetFirst(kv))

Try
    data.First()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try
Try
    data.Last()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Constructor(IComparer<TKey>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > BTreeDictionary<TKey,TValue> Constructor : BTreeDictionary<TKey,TValue> Constructor(IComparer<TKey>)

comparer

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of TKey) _
)
C#
public BTreeDictionary<TKey,TValue>(
   IComparer<TKey> comparer
)

Parameters

comparer

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAdd(i, i.ToString()));

Assert.AreEqual(50, new List<KeyValuePair<int, string>>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<KeyValuePair<int, string>>(data.EnumerateFrom(75)).Count);

for (int i = 0; i < 100; i++)
{
    int first = -1;
    foreach (KeyValuePair<int, string> kv in data.EnumerateFrom(i))
    {
        first = kv.Key;
        break;
    }
    Assert.AreEqual(i, first);
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAdd(i, i.ToString()))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(50, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(75)).Count)

Dim i As Integer = 0
While i < 100
    Dim first As Integer = -1
    For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateFrom(i)
        first = kv.Key
        Exit For
    Next
    Assert.AreEqual(i, first)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Constructor(Int32,IComparer<TKey>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > BTreeDictionary<TKey,TValue> Constructor : BTreeDictionary<TKey,TValue> Constructor(Int32,IComparer<TKey>)

order
comparer

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal order As Integer, _
   ByVal comparer As IComparer(Of TKey) _
)
C#
public BTreeDictionary<TKey,TValue>(
   int order,
   IComparer<TKey> comparer
)

Parameters

order
comparer

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Constructor(IEnumerable<KeyValuePair<TKey,TValue>>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > BTreeDictionary<TKey,TValue> Constructor : BTreeDictionary<TKey,TValue> Constructor(IEnumerable<KeyValuePair<TKey,TValue>>)

copyFrom

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal copyFrom As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
)
C#
public BTreeDictionary<TKey,TValue>(
   IEnumerable<KeyValuePair<TKey,TValue>> copyFrom
)

Parameters

copyFrom

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
List<KeyValuePair<int, string>> sample = new List<KeyValuePair<int,string>>(GetSample());
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(sample);
//Key collection
Assert.AreEqual(data.Count, data.Keys.Count);
Assert.IsTrue(data.Keys.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
    Assert.IsTrue(data.Keys.Contains(sample[i].Key));

IEnumerator<int> ek = data.Keys.GetEnumerator();
Assert.IsTrue(ek.MoveNext());
int firstkey = ek.Current;
Assert.IsTrue(ek.MoveNext());
Assert.AreNotEqual(firstkey, ek.Current);
ek.Reset();
Assert.IsTrue(ek.MoveNext());
Assert.AreEqual(firstkey, ek.Current);
Assert.AreEqual(firstkey, ((System.Collections.IEnumerator)ek).Current);

//Value collection
Assert.AreEqual(data.Count, data.Values.Count);
Assert.IsTrue(data.Values.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
    Assert.IsTrue(data.Values.Contains(sample[i].Value));

IEnumerator<string> ev = data.Values.GetEnumerator();
Assert.IsTrue(ev.MoveNext());
string firstvalue = ev.Current;
Assert.IsTrue(ev.MoveNext());
Assert.AreNotEqual(firstvalue, ev.Current);
ev.Reset();
Assert.IsTrue(ev.MoveNext());
Assert.AreEqual(firstvalue, ((System.Collections.IEnumerator)ev).Current);
VB.NET Copy Code
Dim sample As New List(Of KeyValuePair(Of Integer, String))(GetSample())
Dim data As New BTreeDictionary(Of Integer, String)(sample)
'Key collection
Assert.AreEqual(data.Count, data.Keys.Count)
Assert.IsTrue(data.Keys.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
    Assert.IsTrue(data.Keys.Contains(sample(i).Key))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ek As IEnumerator(Of Integer) = data.Keys.GetEnumerator()
Assert.IsTrue(ek.MoveNext())
Dim firstkey As Integer = ek.Current
Assert.IsTrue(ek.MoveNext())
Assert.AreNotEqual(firstkey, ek.Current)
ek.Reset()
Assert.IsTrue(ek.MoveNext())
Assert.AreEqual(firstkey, ek.Current)
Assert.AreEqual(firstkey, (DirectCast(ek, System.Collections.IEnumerator)).Current)

'Value collection
Assert.AreEqual(data.Count, data.Values.Count)
Assert.IsTrue(data.Values.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
    Assert.IsTrue(data.Values.Contains(sample(i).Value))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ev As IEnumerator(Of String) = data.Values.GetEnumerator()
Assert.IsTrue(ev.MoveNext())
Dim firstvalue As String = ev.Current
Assert.IsTrue(ev.MoveNext())
Assert.AreNotEqual(firstvalue, ev.Current)
ev.Reset()
Assert.IsTrue(ev.MoveNext())
Assert.AreEqual(firstvalue, (DirectCast(ev, System.Collections.IEnumerator)).Current)

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > BTreeDictionary<TKey,TValue> Constructor : BTreeDictionary<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>)

comparer
copyFrom

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal copyFrom As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
)
C#
public BTreeDictionary<TKey,TValue>(
   IComparer<TKey> comparer,
   IEnumerable<KeyValuePair<TKey,TValue>> copyFrom
)

Parameters

comparer
copyFrom

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeDictionary<int, string> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeDictionary(Of Integer, String) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Constructor(Int32,IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > BTreeDictionary<TKey,TValue> Constructor : BTreeDictionary<TKey,TValue> Constructor(Int32,IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>)

order
comparer
copyFrom

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal order As Integer, _
   ByVal comparer As IComparer(Of TKey), _
   ByVal copyFrom As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
)
C#
public BTreeDictionary<TKey,TValue>(
   int order,
   IComparer<TKey> comparer,
   IEnumerable<KeyValuePair<TKey,TValue>> copyFrom
)

Parameters

order
comparer
copyFrom

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeDictionary<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BTreeDictionary<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds an element with the provided key and value to the IDictionary.
Public Method | AddRange | Adds a set of items to the ICollection.
Public Method | Clear | Removes all items from the ICollection.
Public Method | Clone | Returns a writable clone of this collection.
Public Method | Contains | Determines whether the ICollection contains a specific key and value pair.
Public Method | ContainsKey | Determines whether the IDictionary contains an element with the specified key.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | DebugAssert | Ensures data integrity or raises exception
Public Method | EnumerateFrom | Inclusivly enumerates from start key to the end of the collection
Public Method | EnumerateRange | Inclusivly enumerates from start key to stop key
Public Method | First | Returns the first key and it's associated value.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | GetOrAdd | Adds a key/value pair to the IDictionary if the key does not already exist.
Public Method | Last | Returns the last key and it's associated value.
Public Method | MakeReadOnly | Returns a read-only clone of this collection. If this instance is already read-only the method will return this.
Public Method | Remove | Overloaded. Removes the element with the specified key from the IDictionary.
Public Method | ToArray | Returns all the items of this collection as an array of KeyValuePair.
Public Method | TryAdd | Adds an element with the provided key and value to the IDictionary.
Public Method | TryGetFirst | Returns the first key and it's associated value.
Public Method | TryGetLast | Returns the last key and it's associated value.
Public Method | TryGetValue | Gets the value associated with the specified key.
Public Method | TryRemove | Removes the element with the specified key from the IDictionary.
Public Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Top

See Also

Reference

BTreeDictionary<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Add Method

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Overload List

Overload | Description
Add(TKey,TValue) | Adds an element with the provided key and value to the IDictionary.
Add(KeyValuePair<TKey,TValue>) | Adds an item to the ICollection.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > Add Method : Add(TKey,TValue) Method

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal key As TKey, _
   ByVal value As TValue _
)
C#
public void Add(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Exceptions

Exception | Description
System.ArgumentException | An element with the same key already exists in the IDictionary.
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>();
data.Add(1, "a");
data.Add(2, "b");
data.Add(3, "c");
data.Add(4, "d");
data.Add(5, "e");

Assert.AreEqual(1, data.First().Key);
Assert.AreEqual("a", data.First().Value);
data.Remove(1);
Assert.AreEqual(2, data.First().Key);
Assert.AreEqual("b", data.First().Value);

Assert.AreEqual(5, data.Last().Key);
Assert.AreEqual("e", data.Last().Value);
data.Remove(5);
Assert.AreEqual(4, data.Last().Key);
Assert.AreEqual("d", data.Last().Value);

data.Remove(4);
data.Remove(3);

KeyValuePair<int, string> kv;
Assert.IsTrue(data.TryGetLast(out kv));
Assert.IsTrue(data.TryGetFirst(out kv));
data.Remove(2);
Assert.IsFalse(data.TryGetLast(out kv));
Assert.IsFalse(data.TryGetFirst(out kv));

try
{
    data.First();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
try
{
    data.Last();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)()
data.Add(1, "a")
data.Add(2, "b")
data.Add(3, "c")
data.Add(4, "d")
data.Add(5, "e")

Assert.AreEqual(1, data.First().Key)
Assert.AreEqual("a", data.First().Value)
data.Remove(1)
Assert.AreEqual(2, data.First().Key)
Assert.AreEqual("b", data.First().Value)

Assert.AreEqual(5, data.Last().Key)
Assert.AreEqual("e", data.Last().Value)
data.Remove(5)
Assert.AreEqual(4, data.Last().Key)
Assert.AreEqual("d", data.Last().Value)

data.Remove(4)
data.Remove(3)

Dim kv As KeyValuePair(Of Integer, String)
Assert.IsTrue(data.TryGetLast(kv))
Assert.IsTrue(data.TryGetFirst(kv))
data.Remove(2)
Assert.IsFalse(data.TryGetLast(kv))
Assert.IsFalse(data.TryGetFirst(kv))

Try
    data.First()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try
Try
    data.Last()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs

Used By

TValue BTreeDictionary.GetOrAdd(TKey,TValue)


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(KeyValuePair<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > Add Method : Add(KeyValuePair<TKey,TValue>) Method

item
The object to add to the ICollection.

Glossary Item Box

Adds an item to the ICollection.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal item As KeyValuePair(Of TKey,TValue) _
)
C#
public void Add(
   KeyValuePair<TKey,TValue> item
)

Parameters

item
The object to add to the ICollection.

Exceptions

Exception | Description
System.ArgumentException | An element with the same key already exists in the IDictionary.
System.NotSupportedException | The IDictionary is read-only.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Used By

BTreeDictionary.Add(TKey,TValue)
BTreeDictionary.AddRange(IEnumerable>)

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : AddRange Method

items
The items to add to the ICollection.

Glossary Item Box

Adds a set of items to the ICollection.

Syntax

Visual Basic (Declaration)
Public Sub AddRange( _
   ByVal items As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
)
C#
public void AddRange(
   IEnumerable<KeyValuePair<TKey,TValue>> items
)

Parameters

items
The items to add to the ICollection.

Exceptions

Exception | Description
System.ArgumentException | An element with the same key already exists in the IDictionary.
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer, GetSample());
BTreeDictionary<int, string> copy = new BTreeDictionary<int, string>();
copy.AddRange(data);
Assert.AreEqual(copy.Count, data.Count);
foreach (int key in data.Keys)
    Assert.AreEqual(data[key], copy[key]);
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer, GetSample())
Dim copy As New BTreeDictionary(Of Integer, String)()
copy.AddRange(data)
Assert.AreEqual(copy.Count, data.Count)
For Each key As Integer In data.Keys
    Assert.AreEqual(data(key), copy(key))
Next

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Clear Method

Glossary Item Box

Removes all items from the ICollection.

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Exceptions

Exception | Description
System.NotSupportedException | The Collection is read-only.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Clone Method

Glossary Item Box

Returns a writable clone of this collection.

Syntax

Visual Basic (Declaration)
Public Function Clone() As BTreeDictionary(Of TKey,TValue)
C#
public BTreeDictionary<TKey,TValue> Clone()

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeDictionary<int, string> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeDictionary(Of Integer, String) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs

Used By

BTreeDictionary BTreeDictionary.MakeReadOnly()


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Contains Method

item
The object to locate in the ICollection.

Glossary Item Box

Determines whether the ICollection contains a specific key and value pair.

Syntax

Visual Basic (Declaration)
Public Function Contains( _
   ByVal item As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool Contains(
   KeyValuePair<TKey,TValue> item
)

Parameters

item
The object to locate in the ICollection.

Return Value

true if item is found in the ICollection; otherwise, false.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContainsKey Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : ContainsKey Method

key

Glossary Item Box

Determines whether the IDictionary contains an element with the specified key.

Syntax

Visual Basic (Declaration)
Public Function ContainsKey( _
   ByVal key As TKey _
) As Boolean
C#
public bool ContainsKey(
   TKey key
)

Parameters

key

Return Value

true if the IDictionary contains an element with the key; otherwise, false.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As KeyValuePair(Of TKey,TValue), _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   KeyValuePair<TKey,TValue>[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs

Used By

KeyValuePair[] BTreeDictionary.ToArray()


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugAssert Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : DebugAssert Method

Glossary Item Box

Ensures data integrity or raises exception

Syntax

Visual Basic (Declaration)
Public Sub DebugAssert()
C#
public void DebugAssert()

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateFrom Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : EnumerateFrom Method

start

Glossary Item Box

Inclusivly enumerates from start key to the end of the collection

Syntax

Visual Basic (Declaration)
Public Function EnumerateFrom( _
   ByVal start As TKey _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public IEnumerable<KeyValuePair<TKey,TValue>> EnumerateFrom(
   TKey start
)

Parameters

start

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAdd(i, i.ToString()));

Assert.AreEqual(50, new List<KeyValuePair<int, string>>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<KeyValuePair<int, string>>(data.EnumerateFrom(75)).Count);

for (int i = 0; i < 100; i++)
{
    int first = -1;
    foreach (KeyValuePair<int, string> kv in data.EnumerateFrom(i))
    {
        first = kv.Key;
        break;
    }
    Assert.AreEqual(i, first);
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAdd(i, i.ToString()))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(50, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(75)).Count)

Dim i As Integer = 0
While i < 100
    Dim first As Integer = -1
    For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateFrom(i)
        first = kv.Key
        Exit For
    Next
    Assert.AreEqual(i, first)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateRange Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : EnumerateRange Method

start
end

Glossary Item Box

Inclusivly enumerates from start key to stop key

Syntax

Visual Basic (Declaration)
Public Function EnumerateRange( _
   ByVal start As TKey, _
   ByVal end As TKey _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public IEnumerable<KeyValuePair<TKey,TValue>> EnumerateRange(
   TKey start,
   TKey end
)

Parameters

start
end

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAdd(i, i.ToString()));

int ix = 0;
foreach (KeyValuePair<int, string> kv in data.EnumerateRange(-500, 5000))
    Assert.AreEqual(ix++, kv.Key);
Assert.AreEqual(100, ix);

foreach (
    KeyValuePair<int, int> range in
        new Dictionary<int, int> {{6, 25}, {7, 25}, {8, 25}, {9, 25}, {22, 25}, {28, 28}})
{
    ix = range.Key;
    foreach (KeyValuePair<int, string> kv in data.EnumerateRange(ix, range.Value))
        Assert.AreEqual(ix++, kv.Key);
    Assert.AreEqual(range.Value, ix - 1);
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAdd(i, i.ToString()))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ix As Integer = 0
For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateRange(-500, 5000)
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1), kv.Key)
Next
Assert.AreEqual(100, ix)

For Each range As KeyValuePair(Of Integer, Integer) In New Dictionary(Of Integer, Integer)() From { _
    {6, 25}, _
    {7, 25}, _
    {8, 25}, _
    {9, 25}, _
    {22, 25}, _
    {28, 28} _
}
    ix = range.Key
    For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateRange(ix, range.Value)
        Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1), kv.Key)
    Next
    Assert.AreEqual(range.Value, ix - 1)
Next

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
First Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : First Method

Glossary Item Box

Returns the first key and it's associated value.

Syntax

Visual Basic (Declaration)
Public Function First() As KeyValuePair(Of TKey,TValue)
C#
public KeyValuePair<TKey,TValue> First()

Exceptions

Exception | Description
System.InvalidOperationException | The exception that is thrown when a method call is invalid for the object's current state.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>();
data.Add(1, "a");
data.Add(2, "b");
data.Add(3, "c");
data.Add(4, "d");
data.Add(5, "e");

Assert.AreEqual(1, data.First().Key);
Assert.AreEqual("a", data.First().Value);
data.Remove(1);
Assert.AreEqual(2, data.First().Key);
Assert.AreEqual("b", data.First().Value);

Assert.AreEqual(5, data.Last().Key);
Assert.AreEqual("e", data.Last().Value);
data.Remove(5);
Assert.AreEqual(4, data.Last().Key);
Assert.AreEqual("d", data.Last().Value);

data.Remove(4);
data.Remove(3);

KeyValuePair<int, string> kv;
Assert.IsTrue(data.TryGetLast(out kv));
Assert.IsTrue(data.TryGetFirst(out kv));
data.Remove(2);
Assert.IsFalse(data.TryGetLast(out kv));
Assert.IsFalse(data.TryGetFirst(out kv));

try
{
    data.First();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
try
{
    data.Last();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)()
data.Add(1, "a")
data.Add(2, "b")
data.Add(3, "c")
data.Add(4, "d")
data.Add(5, "e")

Assert.AreEqual(1, data.First().Key)
Assert.AreEqual("a", data.First().Value)
data.Remove(1)
Assert.AreEqual(2, data.First().Key)
Assert.AreEqual("b", data.First().Value)

Assert.AreEqual(5, data.Last().Key)
Assert.AreEqual("e", data.Last().Value)
data.Remove(5)
Assert.AreEqual(4, data.Last().Key)
Assert.AreEqual("d", data.Last().Value)

data.Remove(4)
data.Remove(3)

Dim kv As KeyValuePair(Of Integer, String)
Assert.IsTrue(data.TryGetLast(kv))
Assert.IsTrue(data.TryGetFirst(kv))
data.Remove(2)
Assert.IsFalse(data.TryGetLast(kv))
Assert.IsFalse(data.TryGetFirst(kv))

Try
    data.First()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try
Try
    data.Last()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of KeyValuePair(Of TKey,TValue))
C#
public IEnumerator<KeyValuePair<TKey,TValue>> GetEnumerator()

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer, GetSample());
BTreeDictionary<int, string> copy = (BTreeDictionary<int, string>) ((ICloneable) data).Clone();
using(IEnumerator<KeyValuePair<int, string>> e1 = data.GetEnumerator())
using(IEnumerator<KeyValuePair<int, string>> e2 = copy.GetEnumerator())
{
    while(e1.MoveNext() && e2.MoveNext())
    {
        Assert.AreEqual(e1.Current.Key, e2.Current.Key);
        Assert.AreEqual(e1.Current.Value, e2.Current.Value);
    }
    Assert.IsFalse(e1.MoveNext() || e2.MoveNext());
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer, GetSample())
Dim copy As BTreeDictionary(Of Integer, String) = DirectCast((DirectCast(data, ICloneable)).Clone(), BTreeDictionary(Of Integer, String))
Using e1 As IEnumerator(Of KeyValuePair(Of Integer, String)) = data.GetEnumerator()
    Using e2 As IEnumerator(Of KeyValuePair(Of Integer, String)) = copy.GetEnumerator()
        While e1.MoveNext() AndAlso e2.MoveNext()
            Assert.AreEqual(e1.Current.Key, e2.Current.Key)
            Assert.AreEqual(e1.Current.Value, e2.Current.Value)
        End While
        Assert.IsFalse(e1.MoveNext() OrElse e2.MoveNext())
    End Using
End Using

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : GetOrAdd Method

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Public Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As TValue
C#
public TValue GetOrAdd(
   TKey key,
   TValue value
)

Parameters

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
Assert.AreEqual("a", data.GetOrAdd(1, "a"));
Assert.AreEqual("a", data.GetOrAdd(1, "b"));
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Assert.AreEqual("a", data.GetOrAdd(1, "a"))
Assert.AreEqual("a", data.GetOrAdd(1, "b"))

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Last Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Last Method

Glossary Item Box

Returns the last key and it's associated value.

Syntax

Visual Basic (Declaration)
Public Function Last() As KeyValuePair(Of TKey,TValue)
C#
public KeyValuePair<TKey,TValue> Last()

Exceptions

Exception | Description
System.InvalidOperationException | The exception that is thrown when a method call is invalid for the object's current state.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>();
data.Add(1, "a");
data.Add(2, "b");
data.Add(3, "c");
data.Add(4, "d");
data.Add(5, "e");

Assert.AreEqual(1, data.First().Key);
Assert.AreEqual("a", data.First().Value);
data.Remove(1);
Assert.AreEqual(2, data.First().Key);
Assert.AreEqual("b", data.First().Value);

Assert.AreEqual(5, data.Last().Key);
Assert.AreEqual("e", data.Last().Value);
data.Remove(5);
Assert.AreEqual(4, data.Last().Key);
Assert.AreEqual("d", data.Last().Value);

data.Remove(4);
data.Remove(3);

KeyValuePair<int, string> kv;
Assert.IsTrue(data.TryGetLast(out kv));
Assert.IsTrue(data.TryGetFirst(out kv));
data.Remove(2);
Assert.IsFalse(data.TryGetLast(out kv));
Assert.IsFalse(data.TryGetFirst(out kv));

try
{
    data.First();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
try
{
    data.Last();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)()
data.Add(1, "a")
data.Add(2, "b")
data.Add(3, "c")
data.Add(4, "d")
data.Add(5, "e")

Assert.AreEqual(1, data.First().Key)
Assert.AreEqual("a", data.First().Value)
data.Remove(1)
Assert.AreEqual(2, data.First().Key)
Assert.AreEqual("b", data.First().Value)

Assert.AreEqual(5, data.Last().Key)
Assert.AreEqual("e", data.Last().Value)
data.Remove(5)
Assert.AreEqual(4, data.Last().Key)
Assert.AreEqual("d", data.Last().Value)

data.Remove(4)
data.Remove(3)

Dim kv As KeyValuePair(Of Integer, String)
Assert.IsTrue(data.TryGetLast(kv))
Assert.IsTrue(data.TryGetFirst(kv))
data.Remove(2)
Assert.IsFalse(data.TryGetLast(kv))
Assert.IsFalse(data.TryGetFirst(kv))

Try
    data.First()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try
Try
    data.Last()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MakeReadOnly Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : MakeReadOnly Method

Glossary Item Box

Returns a read-only clone of this collection. If this instance is already read-only the method will return this.

Syntax

Visual Basic (Declaration)
Public Function MakeReadOnly() As BTreeDictionary(Of TKey,TValue)
C#
public BTreeDictionary<TKey,TValue> MakeReadOnly()

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeDictionary<int, string> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeDictionary(Of Integer, String) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Remove Method

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Overload List

Overload | Description
Remove(TKey) | Removes the element with the specified key from the IDictionary.
Remove(KeyValuePair<TKey,TValue>) | Removes the first occurrence of a specific object from the ICollection.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove(TKey) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > Remove Method : Remove(TKey) Method

key
The key of the element to remove.

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Public Overloads Function Remove( _
   ByVal key As TKey _
) As Boolean
C#
public bool Remove(
   TKey key
)

Parameters

key
The key of the element to remove.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>();
data.Add(1, "a");
data.Add(2, "b");
data.Add(3, "c");
data.Add(4, "d");
data.Add(5, "e");

Assert.AreEqual(1, data.First().Key);
Assert.AreEqual("a", data.First().Value);
data.Remove(1);
Assert.AreEqual(2, data.First().Key);
Assert.AreEqual("b", data.First().Value);

Assert.AreEqual(5, data.Last().Key);
Assert.AreEqual("e", data.Last().Value);
data.Remove(5);
Assert.AreEqual(4, data.Last().Key);
Assert.AreEqual("d", data.Last().Value);

data.Remove(4);
data.Remove(3);

KeyValuePair<int, string> kv;
Assert.IsTrue(data.TryGetLast(out kv));
Assert.IsTrue(data.TryGetFirst(out kv));
data.Remove(2);
Assert.IsFalse(data.TryGetLast(out kv));
Assert.IsFalse(data.TryGetFirst(out kv));

try
{
    data.First();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
try
{
    data.Last();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)()
data.Add(1, "a")
data.Add(2, "b")
data.Add(3, "c")
data.Add(4, "d")
data.Add(5, "e")

Assert.AreEqual(1, data.First().Key)
Assert.AreEqual("a", data.First().Value)
data.Remove(1)
Assert.AreEqual(2, data.First().Key)
Assert.AreEqual("b", data.First().Value)

Assert.AreEqual(5, data.Last().Key)
Assert.AreEqual("e", data.Last().Value)
data.Remove(5)
Assert.AreEqual(4, data.Last().Key)
Assert.AreEqual("d", data.Last().Value)

data.Remove(4)
data.Remove(3)

Dim kv As KeyValuePair(Of Integer, String)
Assert.IsTrue(data.TryGetLast(kv))
Assert.IsTrue(data.TryGetFirst(kv))
data.Remove(2)
Assert.IsFalse(data.TryGetLast(kv))
Assert.IsFalse(data.TryGetFirst(kv))

Try
    data.First()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try
Try
    data.Last()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove(KeyValuePair<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > Remove Method : Remove(KeyValuePair<TKey,TValue>) Method

item
The object to remove from the ICollection.

Glossary Item Box

Removes the first occurrence of a specific object from the ICollection.

Syntax

Visual Basic (Declaration)
Public Overloads Function Remove( _
   ByVal item As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool Remove(
   KeyValuePair<TKey,TValue> item
)

Parameters

item
The object to remove from the ICollection.

Return Value

true if item was successfully removed from the ICollection; otherwise, false. This method also returns false if item is not found in the original ICollection.

Exceptions

Exception | Description
System.NotSupportedException | The ICollection is read-only.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : ToArray Method

Glossary Item Box

Returns all the items of this collection as an array of KeyValuePair.

Syntax

Visual Basic (Declaration)
Public Function ToArray() As KeyValuePair(Of TKey,TValue)()
C#
public KeyValuePair<TKey,TValue>[] ToArray()

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : TryAdd Method

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Public Function TryAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
public bool TryAdd(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAdd(i, i.ToString()));

Assert.AreEqual(50, new List<KeyValuePair<int, string>>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<KeyValuePair<int, string>>(data.EnumerateFrom(75)).Count);

for (int i = 0; i < 100; i++)
{
    int first = -1;
    foreach (KeyValuePair<int, string> kv in data.EnumerateFrom(i))
    {
        first = kv.Key;
        break;
    }
    Assert.AreEqual(i, first);
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAdd(i, i.ToString()))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(50, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(75)).Count)

Dim i As Integer = 0
While i < 100
    Dim first As Integer = -1
    For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateFrom(i)
        first = kv.Key
        Exit For
    Next
    Assert.AreEqual(i, first)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetFirst Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : TryGetFirst Method

item

Glossary Item Box

Returns the first key and it's associated value.

Syntax

Visual Basic (Declaration)
Public Function TryGetFirst( _
   ByRef item As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool TryGetFirst(
   out KeyValuePair<TKey,TValue> item
)

Parameters

item

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>();
data.Add(1, "a");
data.Add(2, "b");
data.Add(3, "c");
data.Add(4, "d");
data.Add(5, "e");

Assert.AreEqual(1, data.First().Key);
Assert.AreEqual("a", data.First().Value);
data.Remove(1);
Assert.AreEqual(2, data.First().Key);
Assert.AreEqual("b", data.First().Value);

Assert.AreEqual(5, data.Last().Key);
Assert.AreEqual("e", data.Last().Value);
data.Remove(5);
Assert.AreEqual(4, data.Last().Key);
Assert.AreEqual("d", data.Last().Value);

data.Remove(4);
data.Remove(3);

KeyValuePair<int, string> kv;
Assert.IsTrue(data.TryGetLast(out kv));
Assert.IsTrue(data.TryGetFirst(out kv));
data.Remove(2);
Assert.IsFalse(data.TryGetLast(out kv));
Assert.IsFalse(data.TryGetFirst(out kv));

try
{
    data.First();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
try
{
    data.Last();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)()
data.Add(1, "a")
data.Add(2, "b")
data.Add(3, "c")
data.Add(4, "d")
data.Add(5, "e")

Assert.AreEqual(1, data.First().Key)
Assert.AreEqual("a", data.First().Value)
data.Remove(1)
Assert.AreEqual(2, data.First().Key)
Assert.AreEqual("b", data.First().Value)

Assert.AreEqual(5, data.Last().Key)
Assert.AreEqual("e", data.Last().Value)
data.Remove(5)
Assert.AreEqual(4, data.Last().Key)
Assert.AreEqual("d", data.Last().Value)

data.Remove(4)
data.Remove(3)

Dim kv As KeyValuePair(Of Integer, String)
Assert.IsTrue(data.TryGetLast(kv))
Assert.IsTrue(data.TryGetFirst(kv))
data.Remove(2)
Assert.IsFalse(data.TryGetLast(kv))
Assert.IsFalse(data.TryGetFirst(kv))

Try
    data.First()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try
Try
    data.Last()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Used By

KeyValuePair BTreeDictionary.First()

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetLast Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : TryGetLast Method

item

Glossary Item Box

Returns the last key and it's associated value.

Syntax

Visual Basic (Declaration)
Public Function TryGetLast( _
   ByRef item As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool TryGetLast(
   out KeyValuePair<TKey,TValue> item
)

Parameters

item

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>();
data.Add(1, "a");
data.Add(2, "b");
data.Add(3, "c");
data.Add(4, "d");
data.Add(5, "e");

Assert.AreEqual(1, data.First().Key);
Assert.AreEqual("a", data.First().Value);
data.Remove(1);
Assert.AreEqual(2, data.First().Key);
Assert.AreEqual("b", data.First().Value);

Assert.AreEqual(5, data.Last().Key);
Assert.AreEqual("e", data.Last().Value);
data.Remove(5);
Assert.AreEqual(4, data.Last().Key);
Assert.AreEqual("d", data.Last().Value);

data.Remove(4);
data.Remove(3);

KeyValuePair<int, string> kv;
Assert.IsTrue(data.TryGetLast(out kv));
Assert.IsTrue(data.TryGetFirst(out kv));
data.Remove(2);
Assert.IsFalse(data.TryGetLast(out kv));
Assert.IsFalse(data.TryGetFirst(out kv));

try
{
    data.First();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
try
{
    data.Last();
    Assert.Fail("Should raise InvalidOperationException");
}
catch (InvalidOperationException)
{
}
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)()
data.Add(1, "a")
data.Add(2, "b")
data.Add(3, "c")
data.Add(4, "d")
data.Add(5, "e")

Assert.AreEqual(1, data.First().Key)
Assert.AreEqual("a", data.First().Value)
data.Remove(1)
Assert.AreEqual(2, data.First().Key)
Assert.AreEqual("b", data.First().Value)

Assert.AreEqual(5, data.Last().Key)
Assert.AreEqual("e", data.Last().Value)
data.Remove(5)
Assert.AreEqual(4, data.Last().Key)
Assert.AreEqual("d", data.Last().Value)

data.Remove(4)
data.Remove(3)

Dim kv As KeyValuePair(Of Integer, String)
Assert.IsTrue(data.TryGetLast(kv))
Assert.IsTrue(data.TryGetFirst(kv))
data.Remove(2)
Assert.IsFalse(data.TryGetLast(kv))
Assert.IsFalse(data.TryGetFirst(kv))

Try
    data.First()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try
Try
    data.Last()
    Assert.Fail("Should raise InvalidOperationException")
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Used By

KeyValuePair BTreeDictionary.Last()

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : TryGetValue Method

key
value

Glossary Item Box

Gets the value associated with the specified key.

Syntax

Visual Basic (Declaration)
Public Function TryGetValue( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
public bool TryGetValue(
   TKey key,
   out TValue value
)

Parameters

key
value

Return Value

true if the object that implements IDictionary contains an element with the specified key; otherwise, false.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : TryRemove Method

key
The key of the element to remove.
value
The value that was removed.

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Public Function TryRemove( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
public bool TryRemove(
   TKey key,
   out TValue value
)

Parameters

key
The key of the element to remove.
value
The value that was removed.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : TryUpdate Method

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Overload List

Overload | Description
TryUpdate(TKey,TValue) | Updates an element with the provided key to the value if it exists.
TryUpdate(TKey,TValue,TValue) | Updates an element with the provided key to the value if it exists.

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Return Value

Returns true if the key provided was found and updated to the value.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,TValue,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue, _
   ByVal comparisonValue As TValue _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   TValue value,
   TValue comparisonValue
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Return Value

Returns true if the key provided was found and updated to the value.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeDictionary<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BTreeDictionary<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Comparer | Gets the Comparer provided to the constructor or Comparer<TKey>.Default if it was not provided.
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | IsReadOnly | Gets a value indicating whether the ICollection is read-only.
Public Property | Item | Gets or sets the element with the specified key.
Public Property | Keys | Gets an ICollection containing the keys of the IDictionary.
Public Property | Values | Gets an ICollection containing the values in the IDictionary.
Top

See Also

Reference

BTreeDictionary<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Comparer Property

Glossary Item Box

Gets the Comparer provided to the constructor or Comparer<TKey>.Default if it was not provided.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Comparer As IComparer(Of TKey)
C#
public IComparer<TKey> Comparer {get;}

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Count Property

Glossary Item Box

Gets the number of elements contained in the ICollection.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
List<KeyValuePair<int, string>> sample = new List<KeyValuePair<int,string>>(GetSample());
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(sample);
//Key collection
Assert.AreEqual(data.Count, data.Keys.Count);
Assert.IsTrue(data.Keys.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
    Assert.IsTrue(data.Keys.Contains(sample[i].Key));

IEnumerator<int> ek = data.Keys.GetEnumerator();
Assert.IsTrue(ek.MoveNext());
int firstkey = ek.Current;
Assert.IsTrue(ek.MoveNext());
Assert.AreNotEqual(firstkey, ek.Current);
ek.Reset();
Assert.IsTrue(ek.MoveNext());
Assert.AreEqual(firstkey, ek.Current);
Assert.AreEqual(firstkey, ((System.Collections.IEnumerator)ek).Current);

//Value collection
Assert.AreEqual(data.Count, data.Values.Count);
Assert.IsTrue(data.Values.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
    Assert.IsTrue(data.Values.Contains(sample[i].Value));

IEnumerator<string> ev = data.Values.GetEnumerator();
Assert.IsTrue(ev.MoveNext());
string firstvalue = ev.Current;
Assert.IsTrue(ev.MoveNext());
Assert.AreNotEqual(firstvalue, ev.Current);
ev.Reset();
Assert.IsTrue(ev.MoveNext());
Assert.AreEqual(firstvalue, ((System.Collections.IEnumerator)ev).Current);
VB.NET Copy Code
Dim sample As New List(Of KeyValuePair(Of Integer, String))(GetSample())
Dim data As New BTreeDictionary(Of Integer, String)(sample)
'Key collection
Assert.AreEqual(data.Count, data.Keys.Count)
Assert.IsTrue(data.Keys.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
    Assert.IsTrue(data.Keys.Contains(sample(i).Key))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ek As IEnumerator(Of Integer) = data.Keys.GetEnumerator()
Assert.IsTrue(ek.MoveNext())
Dim firstkey As Integer = ek.Current
Assert.IsTrue(ek.MoveNext())
Assert.AreNotEqual(firstkey, ek.Current)
ek.Reset()
Assert.IsTrue(ek.MoveNext())
Assert.AreEqual(firstkey, ek.Current)
Assert.AreEqual(firstkey, (DirectCast(ek, System.Collections.IEnumerator)).Current)

'Value collection
Assert.AreEqual(data.Count, data.Values.Count)
Assert.IsTrue(data.Values.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
    Assert.IsTrue(data.Values.Contains(sample(i).Value))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ev As IEnumerator(Of String) = data.Values.GetEnumerator()
Assert.IsTrue(ev.MoveNext())
Dim firstvalue As String = ev.Current
Assert.IsTrue(ev.MoveNext())
Assert.AreNotEqual(firstvalue, ev.Current)
ev.Reset()
Assert.IsTrue(ev.MoveNext())
Assert.AreEqual(firstvalue, (DirectCast(ev, System.Collections.IEnumerator)).Current)

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReadOnly Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : IsReadOnly Property

Glossary Item Box

Gets a value indicating whether the ICollection is read-only.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReadOnly As Boolean
C#
public bool IsReadOnly {get;}

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeDictionary<int, string> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeDictionary(Of Integer, String) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Item Property

key
The key of the element to get or set.

Glossary Item Box

Gets or sets the element with the specified key.

Syntax

Visual Basic (Declaration)
Public Default Property Item( _
   ByVal key As TKey _
) As TValue
C#
public TValue this[
   TKey key
]; {get; set;}

Parameters

key
The key of the element to get or set.

Property Value

The element with the specified key.

Exceptions

Exception | Description
System.Collections.Generic.KeyNotFoundException | The property is retrieved and key is not found.
System.NotSupportedException | The property is set and the IDictionary is read-only.

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer, GetSample());
BTreeDictionary<int, string> copy = new BTreeDictionary<int, string>();
copy.AddRange(data);
Assert.AreEqual(copy.Count, data.Count);
foreach (int key in data.Keys)
    Assert.AreEqual(data[key], copy[key]);
VB.NET Copy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer, GetSample())
Dim copy As New BTreeDictionary(Of Integer, String)()
copy.AddRange(data)
Assert.AreEqual(copy.Count, data.Count)
For Each key As Integer In data.Keys
    Assert.AreEqual(data(key), copy(key))
Next

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Keys Property

Glossary Item Box

Gets an ICollection containing the keys of the IDictionary.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As ICollection(Of TKey)
C#
public ICollection<TKey> Keys {get;}

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
List<KeyValuePair<int, string>> sample = new List<KeyValuePair<int,string>>(GetSample());
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(sample);
//Key collection
Assert.AreEqual(data.Count, data.Keys.Count);
Assert.IsTrue(data.Keys.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
    Assert.IsTrue(data.Keys.Contains(sample[i].Key));

IEnumerator<int> ek = data.Keys.GetEnumerator();
Assert.IsTrue(ek.MoveNext());
int firstkey = ek.Current;
Assert.IsTrue(ek.MoveNext());
Assert.AreNotEqual(firstkey, ek.Current);
ek.Reset();
Assert.IsTrue(ek.MoveNext());
Assert.AreEqual(firstkey, ek.Current);
Assert.AreEqual(firstkey, ((System.Collections.IEnumerator)ek).Current);

//Value collection
Assert.AreEqual(data.Count, data.Values.Count);
Assert.IsTrue(data.Values.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
    Assert.IsTrue(data.Values.Contains(sample[i].Value));

IEnumerator<string> ev = data.Values.GetEnumerator();
Assert.IsTrue(ev.MoveNext());
string firstvalue = ev.Current;
Assert.IsTrue(ev.MoveNext());
Assert.AreNotEqual(firstvalue, ev.Current);
ev.Reset();
Assert.IsTrue(ev.MoveNext());
Assert.AreEqual(firstvalue, ((System.Collections.IEnumerator)ev).Current);
VB.NET Copy Code
Dim sample As New List(Of KeyValuePair(Of Integer, String))(GetSample())
Dim data As New BTreeDictionary(Of Integer, String)(sample)
'Key collection
Assert.AreEqual(data.Count, data.Keys.Count)
Assert.IsTrue(data.Keys.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
    Assert.IsTrue(data.Keys.Contains(sample(i).Key))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ek As IEnumerator(Of Integer) = data.Keys.GetEnumerator()
Assert.IsTrue(ek.MoveNext())
Dim firstkey As Integer = ek.Current
Assert.IsTrue(ek.MoveNext())
Assert.AreNotEqual(firstkey, ek.Current)
ek.Reset()
Assert.IsTrue(ek.MoveNext())
Assert.AreEqual(firstkey, ek.Current)
Assert.AreEqual(firstkey, (DirectCast(ek, System.Collections.IEnumerator)).Current)

'Value collection
Assert.AreEqual(data.Count, data.Values.Count)
Assert.IsTrue(data.Values.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
    Assert.IsTrue(data.Values.Contains(sample(i).Value))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ev As IEnumerator(Of String) = data.Values.GetEnumerator()
Assert.IsTrue(ev.MoveNext())
Dim firstvalue As String = ev.Current
Assert.IsTrue(ev.MoveNext())
Assert.AreNotEqual(firstvalue, ev.Current)
ev.Reset()
Assert.IsTrue(ev.MoveNext())
Assert.AreEqual(firstvalue, (DirectCast(ev, System.Collections.IEnumerator)).Current)

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Values Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : Values Property

Glossary Item Box

Gets an ICollection containing the values in the IDictionary.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Values As ICollection(Of TValue)
C#
public ICollection<TValue> Values {get;}

Example

Library/Library.Test/TestBTreeDictionary.cs

C# Copy Code
List<KeyValuePair<int, string>> sample = new List<KeyValuePair<int,string>>(GetSample());
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(sample);
//Key collection
Assert.AreEqual(data.Count, data.Keys.Count);
Assert.IsTrue(data.Keys.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
    Assert.IsTrue(data.Keys.Contains(sample[i].Key));

IEnumerator<int> ek = data.Keys.GetEnumerator();
Assert.IsTrue(ek.MoveNext());
int firstkey = ek.Current;
Assert.IsTrue(ek.MoveNext());
Assert.AreNotEqual(firstkey, ek.Current);
ek.Reset();
Assert.IsTrue(ek.MoveNext());
Assert.AreEqual(firstkey, ek.Current);
Assert.AreEqual(firstkey, ((System.Collections.IEnumerator)ek).Current);

//Value collection
Assert.AreEqual(data.Count, data.Values.Count);
Assert.IsTrue(data.Values.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
    Assert.IsTrue(data.Values.Contains(sample[i].Value));

IEnumerator<string> ev = data.Values.GetEnumerator();
Assert.IsTrue(ev.MoveNext());
string firstvalue = ev.Current;
Assert.IsTrue(ev.MoveNext());
Assert.AreNotEqual(firstvalue, ev.Current);
ev.Reset();
Assert.IsTrue(ev.MoveNext());
Assert.AreEqual(firstvalue, ((System.Collections.IEnumerator)ev).Current);
VB.NET Copy Code
Dim sample As New List(Of KeyValuePair(Of Integer, String))(GetSample())
Dim data As New BTreeDictionary(Of Integer, String)(sample)
'Key collection
Assert.AreEqual(data.Count, data.Keys.Count)
Assert.IsTrue(data.Keys.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
    Assert.IsTrue(data.Keys.Contains(sample(i).Key))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ek As IEnumerator(Of Integer) = data.Keys.GetEnumerator()
Assert.IsTrue(ek.MoveNext())
Dim firstkey As Integer = ek.Current
Assert.IsTrue(ek.MoveNext())
Assert.AreNotEqual(firstkey, ek.Current)
ek.Reset()
Assert.IsTrue(ek.MoveNext())
Assert.AreEqual(firstkey, ek.Current)
Assert.AreEqual(firstkey, (DirectCast(ek, System.Collections.IEnumerator)).Current)

'Value collection
Assert.AreEqual(data.Count, data.Values.Count)
Assert.IsTrue(data.Values.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
    Assert.IsTrue(data.Values.Contains(sample(i).Value))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ev As IEnumerator(Of String) = data.Values.GetEnumerator()
Assert.IsTrue(ev.MoveNext())
Dim firstvalue As String = ev.Current
Assert.IsTrue(ev.MoveNext())
Assert.AreNotEqual(firstvalue, ev.Current)
ev.Reset()
Assert.IsTrue(ev.MoveNext())
Assert.AreEqual(firstvalue, (DirectCast(ev, System.Collections.IEnumerator)).Current)

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
BTreeDictionary<TKey,TValue> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeDictionary<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see BTreeDictionary<TKey,TValue> members.

Public Fields

 | Name | Description
Public Field | DefaultOrder | The default `order` of the B+Tree structure.
Top

See Also

Reference

BTreeDictionary<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultOrder Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : DefaultOrder Field

Glossary Item Box

The default `order` of the B+Tree structure.

Syntax

Visual Basic (Declaration)
Public Const DefaultOrder As Integer
C#
public const int DefaultOrder

Requirements

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

See Also

Reference

BTreeDictionary<TKey,TValue> Class
BTreeDictionary<TKey,TValue> Members

Source Code

Library/Collections/BTreeDictionary.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
BTreeList<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeList<T> Class

Glossary Item Box

Implements an IList interface for an in-memory B+Tree of unique values

Syntax

Visual Basic (Declaration)
Public Class BTreeList(Of T)
C#
public class BTreeList<T>

Type Parameters

T

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAddItem(i));

Assert.AreEqual(50, new List<int>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<int>(data.EnumerateFrom(75)).Count);

for (int i = 0; i < 100; i++)
{
    int first = -1;
    foreach (int kv in data.EnumerateFrom(i))
    {
        first = kv;
        break;
    }
    Assert.AreEqual(i, first);
}
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAddItem(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(50, New List(Of Integer)(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of Integer)(data.EnumerateFrom(75)).Count)

Dim i As Integer = 0
While i < 100
    Dim first As Integer = -1
    For Each kv As Integer In data.EnumerateFrom(i)
        first = kv
        Exit For
    Next
    Assert.AreEqual(i, first)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BTreeList<T>

Requirements

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

See Also

Reference

BTreeList<T> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BTreeList<T> Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeList<T> Class

Glossary Item Box

The following tables list the members exposed by BTreeList<T>.

Public Constructors

 | Name | Description
Public Constructor | BTreeList<T> Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | DefaultOrder | The default `order` of the B+Tree structure.
Top

Public Properties

 | Name | Description
Public Property | Comparer | Gets the Comparer provided to the constructor or Comparer<TKey>.Default if it was not provided.
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | IsReadOnly | Gets a value indicating whether the ICollection is read-only.
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an element with the provided value to the IList.
Public Method | AddRange | Adds a set of items to the ICollection.
Public Method | Clear | Removes all items from the ICollection.
Public Method | Clone | Returns a writable clone of this collection.
Public Method | Contains | Determines whether the ICollection contains a specific value pair.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | EnumerateFrom | Inclusivly enumerates from start value to the end of the collection
Public Method | EnumerateRange | Inclusivly enumerates from start value to stop value
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | MakeReadOnly | Returns a read-only clone of this collection. If this instance is already read-only the method will return this.
Public Method | Remove | Removes the element with the specified value from the IList.
Public Method | ToArray | Returns all the items of this collection as an array of KeyValuePair.
Public Method | TryAddItem | Adds an element with the provided value to the IList.
Top

See Also

Reference

BTreeList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeList<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : BTreeList<T> Constructor

Glossary Item Box

Overload List

Overload | Description
BTreeList<T> Constructor() | Constructs a BTreeList instance.
BTreeList<T> Constructor(IComparer<T>) | Constructs a BTreeList instance.
BTreeList<T> Constructor(Int32,IComparer<T>) | Constructs a BTreeList instance.
BTreeList<T> Constructor(IEnumerable<T>) | Constructs a BTreeList instance.
BTreeList<T> Constructor(IComparer<T>,IEnumerable<T>) | Constructs a BTreeList instance.
BTreeList<T> Constructor(Int32,IComparer<T>,IEnumerable<T>) | Constructs a BTreeList instance.

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeList<T> Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class > BTreeList<T> Constructor : BTreeList<T> Constructor()

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public BTreeList<T>()

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
BTreeList<int> copy = new BTreeList<int>();
copy.AddRange(data);
Assert.AreEqual(copy.Count, data.Count);
IList<int> lista = data, listb = copy;
for (int ix = 0; ix < data.Count; ix++)
    Assert.AreEqual(lista[ix], listb[ix]);
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Dim copy As New BTreeList(Of Integer)()
copy.AddRange(data)
Assert.AreEqual(copy.Count, data.Count)
Dim lista As IList(Of Integer) = data, listb As IList(Of Integer) = copy
Dim ix As Integer = 0
While ix < data.Count
    Assert.AreEqual(lista(ix), listb(ix))
    System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)
End While

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members
Overload List

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeList<T> Constructor(IComparer<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class > BTreeList<T> Constructor : BTreeList<T> Constructor(IComparer<T>)

comparer

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of T) _
)
C#
public BTreeList<T>(
   IComparer<T> comparer
)

Parameters

comparer

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAddItem(i));

Assert.AreEqual(50, new List<int>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<int>(data.EnumerateFrom(75)).Count);

for (int i = 0; i < 100; i++)
{
    int first = -1;
    foreach (int kv in data.EnumerateFrom(i))
    {
        first = kv;
        break;
    }
    Assert.AreEqual(i, first);
}
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAddItem(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(50, New List(Of Integer)(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of Integer)(data.EnumerateFrom(75)).Count)

Dim i As Integer = 0
While i < 100
    Dim first As Integer = -1
    For Each kv As Integer In data.EnumerateFrom(i)
        first = kv
        Exit For
    Next
    Assert.AreEqual(i, first)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members
Overload List

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeList<T> Constructor(Int32,IComparer<T>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class > BTreeList<T> Constructor : BTreeList<T> Constructor(Int32,IComparer<T>)

order
comparer

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal order As Integer, _
   ByVal comparer As IComparer(Of T) _
)
C#
public BTreeList<T>(
   int order,
   IComparer<T> comparer
)

Parameters

order
comparer

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members
Overload List

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeList<T> Constructor(IEnumerable<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class > BTreeList<T> Constructor : BTreeList<T> Constructor(IEnumerable<T>)

copyFrom

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal copyFrom As IEnumerable(Of T) _
)
C#
public BTreeList<T>(
   IEnumerable<T> copyFrom
)

Parameters

copyFrom

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> test = new BTreeList<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
IList<int> list = test;
for (int i = 10; i < 1000; i++)
    test.Add(i);

for(int i=900; i >0; i-=100)
{
    Assert.IsTrue(test.Contains(i));
    Assert.AreEqual(i, list.IndexOf(i));
    list.RemoveAt(i);
    Assert.IsFalse(test.Contains(i));
    Assert.AreEqual(-1, list.IndexOf(i));
    Assert.AreEqual(i + 1, list[i]);
}

list.RemoveAt(0);
list.RemoveAt(1);
list.RemoveAt(2);
Assert.AreEqual(1, list[0]);
Assert.AreEqual(3, list[1]);
Assert.AreEqual(5, list[2]);

Assert.AreEqual(1000 - 12, list.Count);
VB.NET Copy Code
Dim test As New BTreeList(Of Integer)(New Integer() {0, 1, 2, 3, 4, 5, _
    6, 7, 8, 9})
Dim list As IList(Of Integer) = test
Dim i As Integer = 10
While i < 1000
    test.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 900
While i > 0
    Assert.IsTrue(test.Contains(i))
    Assert.AreEqual(i, list.IndexOf(i))
    list.RemoveAt(i)
    Assert.IsFalse(test.Contains(i))
    Assert.AreEqual(-1, list.IndexOf(i))
    Assert.AreEqual(i + 1, list(i))
    i -= 100
End While

list.RemoveAt(0)
list.RemoveAt(1)
list.RemoveAt(2)
Assert.AreEqual(1, list(0))
Assert.AreEqual(3, list(1))
Assert.AreEqual(5, list(2))

Assert.AreEqual(1000 - 12, list.Count)

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members
Overload List

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeList<T> Constructor(IComparer<T>,IEnumerable<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class > BTreeList<T> Constructor : BTreeList<T> Constructor(IComparer<T>,IEnumerable<T>)

comparer
copyFrom

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of T), _
   ByVal copyFrom As IEnumerable(Of T) _
)
C#
public BTreeList<T>(
   IComparer<T> comparer,
   IEnumerable<T> copyFrom
)

Parameters

comparer
copyFrom

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeList<int> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeList(Of Integer) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members
Overload List

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BTreeList<T> Constructor(Int32,IComparer<T>,IEnumerable<T>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class > BTreeList<T> Constructor : BTreeList<T> Constructor(Int32,IComparer<T>,IEnumerable<T>)

order
comparer
copyFrom

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal order As Integer, _
   ByVal comparer As IComparer(Of T), _
   ByVal copyFrom As IEnumerable(Of T) _
)
C#
public BTreeList<T>(
   int order,
   IComparer<T> comparer,
   IEnumerable<T> copyFrom
)

Parameters

order
comparer
copyFrom

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members
Overload List

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BTreeList<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeList<T> Class

Glossary Item Box

For a list of all members of this type, see BTreeList<T> members.

Public Methods

 | Name | Description
Public Method | Add | Adds an element with the provided value to the IList.
Public Method | AddRange | Adds a set of items to the ICollection.
Public Method | Clear | Removes all items from the ICollection.
Public Method | Clone | Returns a writable clone of this collection.
Public Method | Contains | Determines whether the ICollection contains a specific value pair.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | EnumerateFrom | Inclusivly enumerates from start value to the end of the collection
Public Method | EnumerateRange | Inclusivly enumerates from start value to stop value
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | MakeReadOnly | Returns a read-only clone of this collection. If this instance is already read-only the method will return this.
Public Method | Remove | Removes the element with the specified value from the IList.
Public Method | ToArray | Returns all the items of this collection as an array of KeyValuePair.
Public Method | TryAddItem | Adds an element with the provided value to the IList.
Top

See Also

Reference

BTreeList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(T) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Add(T) Method

value
The object to use as the value of the element to add.

Glossary Item Box

Adds an element with the provided value to the IList.

Syntax

Visual Basic (Declaration)
Public Sub Add( _
   ByVal value As T _
)
C#
public void Add(
   T value
)

Parameters

value
The object to use as the value of the element to add.

Exceptions

Exception | Description
System.ArgumentException | An element with the same value already exists in the IList.
System.NotSupportedException | The IList is read-only.

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> test = new BTreeList<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
IList<int> list = test;
for (int i = 10; i < 1000; i++)
    test.Add(i);

for(int i=900; i >0; i-=100)
{
    Assert.IsTrue(test.Contains(i));
    Assert.AreEqual(i, list.IndexOf(i));
    list.RemoveAt(i);
    Assert.IsFalse(test.Contains(i));
    Assert.AreEqual(-1, list.IndexOf(i));
    Assert.AreEqual(i + 1, list[i]);
}

list.RemoveAt(0);
list.RemoveAt(1);
list.RemoveAt(2);
Assert.AreEqual(1, list[0]);
Assert.AreEqual(3, list[1]);
Assert.AreEqual(5, list[2]);

Assert.AreEqual(1000 - 12, list.Count);
VB.NET Copy Code
Dim test As New BTreeList(Of Integer)(New Integer() {0, 1, 2, 3, 4, 5, _
    6, 7, 8, 9})
Dim list As IList(Of Integer) = test
Dim i As Integer = 10
While i < 1000
    test.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 900
While i > 0
    Assert.IsTrue(test.Contains(i))
    Assert.AreEqual(i, list.IndexOf(i))
    list.RemoveAt(i)
    Assert.IsFalse(test.Contains(i))
    Assert.AreEqual(-1, list.IndexOf(i))
    Assert.AreEqual(i + 1, list(i))
    i -= 100
End While

list.RemoveAt(0)
list.RemoveAt(1)
list.RemoveAt(2)
Assert.AreEqual(1, list(0))
Assert.AreEqual(3, list(1))
Assert.AreEqual(5, list(2))

Assert.AreEqual(1000 - 12, list.Count)

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs

Used By

BTreeList.AddRange(IEnumerable)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : AddRange Method

items
The items to add to the ICollection.

Glossary Item Box

Adds a set of items to the ICollection.

Syntax

Visual Basic (Declaration)
Public Sub AddRange( _
   ByVal items As IEnumerable(Of T) _
)
C#
public void AddRange(
   IEnumerable<T> items
)

Parameters

items
The items to add to the ICollection.

Exceptions

Exception | Description
System.ArgumentException | An element with the same value already exists in the IList.
System.NotSupportedException | The IList is read-only.

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
BTreeList<int> copy = new BTreeList<int>();
copy.AddRange(data);
Assert.AreEqual(copy.Count, data.Count);
IList<int> lista = data, listb = copy;
for (int ix = 0; ix < data.Count; ix++)
    Assert.AreEqual(lista[ix], listb[ix]);
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Dim copy As New BTreeList(Of Integer)()
copy.AddRange(data)
Assert.AreEqual(copy.Count, data.Count)
Dim lista As IList(Of Integer) = data, listb As IList(Of Integer) = copy
Dim ix As Integer = 0
While ix < data.Count
    Assert.AreEqual(lista(ix), listb(ix))
    System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)
End While

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Clear Method

Glossary Item Box

Removes all items from the ICollection.

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Exceptions

Exception | Description
System.NotSupportedException | The Collection is read-only.

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Clone Method

Glossary Item Box

Returns a writable clone of this collection.

Syntax

Visual Basic (Declaration)
Public Function Clone() As BTreeList(Of T)
C#
public BTreeList<T> Clone()

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeList<int> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeList(Of Integer) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs

Used By

BTreeList BTreeList.MakeReadOnly()


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Contains Method

item
The object to locate in the ICollection.

Glossary Item Box

Determines whether the ICollection contains a specific value pair.

Syntax

Visual Basic (Declaration)
Public Function Contains( _
   ByVal item As T _
) As Boolean
C#
public bool Contains(
   T item
)

Parameters

item
The object to locate in the ICollection.

Return Value

true if item is found in the ICollection; otherwise, false.

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> test = new BTreeList<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
IList<int> list = test;
for (int i = 10; i < 1000; i++)
    test.Add(i);

for(int i=900; i >0; i-=100)
{
    Assert.IsTrue(test.Contains(i));
    Assert.AreEqual(i, list.IndexOf(i));
    list.RemoveAt(i);
    Assert.IsFalse(test.Contains(i));
    Assert.AreEqual(-1, list.IndexOf(i));
    Assert.AreEqual(i + 1, list[i]);
}

list.RemoveAt(0);
list.RemoveAt(1);
list.RemoveAt(2);
Assert.AreEqual(1, list[0]);
Assert.AreEqual(3, list[1]);
Assert.AreEqual(5, list[2]);

Assert.AreEqual(1000 - 12, list.Count);
VB.NET Copy Code
Dim test As New BTreeList(Of Integer)(New Integer() {0, 1, 2, 3, 4, 5, _
    6, 7, 8, 9})
Dim list As IList(Of Integer) = test
Dim i As Integer = 10
While i < 1000
    test.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 900
While i > 0
    Assert.IsTrue(test.Contains(i))
    Assert.AreEqual(i, list.IndexOf(i))
    list.RemoveAt(i)
    Assert.IsFalse(test.Contains(i))
    Assert.AreEqual(-1, list.IndexOf(i))
    Assert.AreEqual(i + 1, list(i))
    i -= 100
End While

list.RemoveAt(0)
list.RemoveAt(1)
list.RemoveAt(2)
Assert.AreEqual(1, list(0))
Assert.AreEqual(3, list(1))
Assert.AreEqual(5, list(2))

Assert.AreEqual(1000 - 12, list.Count)

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As T, _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   T[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs

Used By

T[] BTreeList.ToArray()


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateFrom Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : EnumerateFrom Method

start

Glossary Item Box

Inclusivly enumerates from start value to the end of the collection

Syntax

Visual Basic (Declaration)
Public Function EnumerateFrom( _
   ByVal start As T _
) As IEnumerable(Of T)
C#
public IEnumerable<T> EnumerateFrom(
   T start
)

Parameters

start

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAddItem(i));

Assert.AreEqual(50, new List<int>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<int>(data.EnumerateFrom(75)).Count);

for (int i = 0; i < 100; i++)
{
    int first = -1;
    foreach (int kv in data.EnumerateFrom(i))
    {
        first = kv;
        break;
    }
    Assert.AreEqual(i, first);
}
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAddItem(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(50, New List(Of Integer)(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of Integer)(data.EnumerateFrom(75)).Count)

Dim i As Integer = 0
While i < 100
    Dim first As Integer = -1
    For Each kv As Integer In data.EnumerateFrom(i)
        first = kv
        Exit For
    Next
    Assert.AreEqual(i, first)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateRange Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : EnumerateRange Method

start
end

Glossary Item Box

Inclusivly enumerates from start value to stop value

Syntax

Visual Basic (Declaration)
Public Function EnumerateRange( _
   ByVal start As T, _
   ByVal end As T _
) As IEnumerable(Of T)
C#
public IEnumerable<T> EnumerateRange(
   T start,
   T end
)

Parameters

start
end

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAddItem(i));

int ix = 0;
foreach (int kv in data.EnumerateRange(-500, 5000))
    Assert.AreEqual(ix++, kv);
Assert.AreEqual(100, ix);

foreach (
    KeyValuePair<int, int> range in
        new Dictionary<int, int> {{6, 25}, {7, 25}, {8, 25}, {9, 25}, {22, 25}, {28, 28}})
{
    ix = range.Key;
    foreach (int kv in data.EnumerateRange(ix, range.Value))
        Assert.AreEqual(ix++, kv);
    Assert.AreEqual(range.Value, ix - 1);
}
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAddItem(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim ix As Integer = 0
For Each kv As Integer In data.EnumerateRange(-500, 5000)
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1), kv)
Next
Assert.AreEqual(100, ix)

For Each range As KeyValuePair(Of Integer, Integer) In New Dictionary(Of Integer, Integer)() From { _
    {6, 25}, _
    {7, 25}, _
    {8, 25}, _
    {9, 25}, _
    {22, 25}, _
    {28, 28} _
}
    ix = range.Key
    For Each kv As Integer In data.EnumerateRange(ix, range.Value)
        Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1), kv)
    Next
    Assert.AreEqual(range.Value, ix - 1)
Next

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of T)
C#
public IEnumerator<T> GetEnumerator()

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
BTreeList<int> copy = (BTreeList<int>) ((ICloneable) data).Clone();
using(IEnumerator<int> e1 = data.GetEnumerator())
using(IEnumerator<int> e2 = copy.GetEnumerator())
{
    while(e1.MoveNext() && e2.MoveNext())
    {
        Assert.AreEqual(e1.Current, e2.Current);
    }
    Assert.IsFalse(e1.MoveNext() || e2.MoveNext());
}
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Dim copy As BTreeList(Of Integer) = DirectCast((DirectCast(data, ICloneable)).Clone(), BTreeList(Of Integer))
Using e1 As IEnumerator(Of Integer) = data.GetEnumerator()
    Using e2 As IEnumerator(Of Integer) = copy.GetEnumerator()
        While e1.MoveNext() AndAlso e2.MoveNext()
            Assert.AreEqual(e1.Current, e2.Current)
        End While
        Assert.IsFalse(e1.MoveNext() OrElse e2.MoveNext())
    End Using
End Using

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MakeReadOnly Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : MakeReadOnly Method

Glossary Item Box

Returns a read-only clone of this collection. If this instance is already read-only the method will return this.

Syntax

Visual Basic (Declaration)
Public Function MakeReadOnly() As BTreeList(Of T)
C#
public BTreeList<T> MakeReadOnly()

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeList<int> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeList(Of Integer) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove(T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Remove(T) Method

value
The value of the element to remove.

Glossary Item Box

Removes the element with the specified value from the IList.

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal value As T _
) As Boolean
C#
public bool Remove(
   T value
)

Parameters

value
The value of the element to remove.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if value was not found in the original IList.

Exceptions

Exception | Description
System.NotSupportedException | The IList is read-only.

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : ToArray Method

Glossary Item Box

Returns all the items of this collection as an array of KeyValuePair.

Syntax

Visual Basic (Declaration)
Public Function ToArray() As T()
C#
public T[] ToArray()

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAddItem Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : TryAddItem Method

value
The object to use as the value of the element to add.

Glossary Item Box

Adds an element with the provided value to the IList.

Syntax

Visual Basic (Declaration)
Public Function TryAddItem( _
   ByVal value As T _
) As Boolean
C#
public bool TryAddItem(
   T value
)

Parameters

value
The object to use as the value of the element to add.

Exceptions

Exception | Description
System.NotSupportedException | The IList is read-only.

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAddItem(i));

Assert.AreEqual(50, new List<int>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<int>(data.EnumerateFrom(75)).Count);

for (int i = 0; i < 100; i++)
{
    int first = -1;
    foreach (int kv in data.EnumerateFrom(i))
    {
        first = kv;
        break;
    }
    Assert.AreEqual(i, first);
}
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAddItem(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(50, New List(Of Integer)(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of Integer)(data.EnumerateFrom(75)).Count)

Dim i As Integer = 0
While i < 100
    Dim first As Integer = -1
    For Each kv As Integer In data.EnumerateFrom(i)
        first = kv
        Exit For
    Next
    Assert.AreEqual(i, first)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BTreeList<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeList<T> Class

Glossary Item Box

For a list of all members of this type, see BTreeList<T> members.

Public Properties

 | Name | Description
Public Property | Comparer | Gets the Comparer provided to the constructor or Comparer<TKey>.Default if it was not provided.
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | IsReadOnly | Gets a value indicating whether the ICollection is read-only.
Top

See Also

Reference

BTreeList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Comparer Property

Glossary Item Box

Gets the Comparer provided to the constructor or Comparer<TKey>.Default if it was not provided.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Comparer As IComparer(Of T)
C#
public IComparer<T> Comparer {get;}

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Count Property

Glossary Item Box

Gets the number of elements contained in the ICollection.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeList<int> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeList(Of Integer) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReadOnly Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : IsReadOnly Property

Glossary Item Box

Gets a value indicating whether the ICollection is read-only.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReadOnly As Boolean
C#
public bool IsReadOnly {get;}

Example

Library/Library.Test/TestBTreeList.cs

C# Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
Assert.IsFalse(data.IsReadOnly);

BTreeList<int> copy = data.MakeReadOnly();
Assert.IsFalse(ReferenceEquals(data, copy));
Assert.AreEqual(data.Count, copy.Count);
Assert.IsTrue(copy.IsReadOnly);

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()));
data = copy.Clone();
Assert.IsFalse(data.IsReadOnly);
Assert.IsFalse(ReferenceEquals(copy, data));
Assert.AreEqual(data.Count, copy.Count);
VB.NET Copy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Assert.IsFalse(data.IsReadOnly)

Dim copy As BTreeList(Of Integer) = data.MakeReadOnly()
Assert.IsFalse(ReferenceEquals(data, copy))
Assert.AreEqual(data.Count, copy.Count)
Assert.IsTrue(copy.IsReadOnly)

Assert.IsTrue(ReferenceEquals(copy, copy.MakeReadOnly()))
data = copy.Clone()
Assert.IsFalse(data.IsReadOnly)
Assert.IsFalse(ReferenceEquals(copy, data))
Assert.AreEqual(data.Count, copy.Count)

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
BTreeList<T> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : BTreeList<T> Class

Glossary Item Box

For a list of all members of this type, see BTreeList<T> members.

Public Fields

 | Name | Description
Public Field | DefaultOrder | The default `order` of the B+Tree structure.
Top

See Also

Reference

BTreeList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultOrder Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : DefaultOrder Field

Glossary Item Box

The default `order` of the B+Tree structure.

Syntax

Visual Basic (Declaration)
Public Const DefaultOrder As Integer
C#
public const int DefaultOrder

Requirements

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

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members

Source Code

Library/Collections/BTreeList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DisposingList Class

Glossary Item Box

Disposes of each element in the collection when the collection is disposed.

Object Model

DisposingList ClassIDisposable Interface

Syntax

Visual Basic (Declaration)
Public Class DisposingList
   Inherits CSharpTest.Net.Collections.DisposingList(Of IDisposable)
C#
public class DisposingList : CSharpTest.Net.Collections.DisposingList<IDisposable>

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string path;
using(DisposingList l = new DisposingList())
{
    TempFile ftarget = new TempFile();
    ftarget.Delete();

    l.Add(ftarget);
    TempFile fbigone = TempFile.Attach(String.Format("{0}.~{1:x4}", ftarget.TempPath, 0x10008 - 25));
    fbigone.Create().Dispose();
    Assert.IsTrue(fbigone.Exists);
    l.Add(fbigone);
    path = ftarget.TempPath;

    string tmpName;
    Dictionary<string, object> names = new Dictionary<string,object>(StringComparer.OrdinalIgnoreCase);

    for( int i=0; i < 25; i++ )
    {
        Stream s = ReplaceFile.CreateDerivedFile(ftarget.TempPath, out tmpName);
        l.Add(TempFile.Attach(tmpName));
        l.Add(s);
        names.Add(tmpName, null);
    }

    fbigone.Delete();
    Assert.AreEqual(25, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length);
}
Assert.AreEqual(0, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length);
VB.NET Copy Code
Dim path As String
Using l As New DisposingList()
    Dim ftarget As New TempFile()
    ftarget.Delete()

    l.Add(ftarget)
    Dim fbigone As TempFile = TempFile.Attach([String].Format("{0}.~{1:x4}", ftarget.TempPath, &H10008 - 25))
    fbigone.Create().Dispose()
    Assert.IsTrue(fbigone.Exists)
    l.Add(fbigone)
    path = ftarget.TempPath

    Dim tmpName As String
    Dim names As New Dictionary(Of String, Object)(StringComparer.OrdinalIgnoreCase)

    Dim i As Integer = 0
    While i < 25
        Dim s As Stream = ReplaceFile.CreateDerivedFile(ftarget.TempPath, tmpName)
        l.Add(TempFile.Attach(tmpName))
        l.Add(s)
        names.Add(tmpName, Nothing)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    fbigone.Delete()
    Assert.AreEqual(25, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length)
End Using
Assert.AreEqual(0, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length)

Inheritance Hierarchy

System.Object
System.Collections.Generic.List<T>
CSharpTest.Net.Collections.DisposingList<T>
CSharpTest.Net.Collections.DisposingList

Requirements

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

See Also

Reference

DisposingList Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DisposingList Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DisposingList Class

Glossary Item Box

The following tables list the members exposed by DisposingList.

Public Constructors

 | Name | Description
Public Constructor | DisposingList Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Capacity | Gets or sets the total number of elements the internal data structure can hold without resizing. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Property | Count | Gets the number of elements actually contained in the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Property | Item | Gets or sets the element at the specified index. (Inherited from System.Collections.Generic.List<IDisposable>)
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an object to the end of the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | AddRange | Adds the elements of the specified collection to the end of the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | AsReadOnly | Returns a read-only IList wrapper for the current collection. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | BinarySearch | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Clear | Removes all elements from the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Contains | Determines whether an element is in the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | ConvertAll | Converts the elements in the current List to another type, and returns a list containing the converted elements. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | CopyTo | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Dispose | Disposes of each element in the collection when the collection is disposed. (Inherited from CSharpTest.Net.Collections.DisposingList<IDisposable>)
Public Method | Exists | Determines whether the List contains elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Find | Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | FindAll | Retrieves all the elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | FindIndex | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | FindLast | Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | FindLastIndex | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | ForEach | Performs the specified action on each element of the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | GetRange | Creates a shallow copy of a range of elements in the source List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | IndexOf | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Insert | Inserts an element into the List at the specified index. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | InsertRange | Inserts the elements of a collection into the List at the specified index. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | LastIndexOf | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Remove | Removes the first occurrence of a specific object from the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | RemoveAll | Removes all the elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | RemoveAt | Removes the element at the specified index of the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | RemoveRange | Removes a range of elements from the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Reverse | Overloaded. Reverses the order of the elements in the entire List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Sort | Overloaded. Sorts the elements in the entire List using the default comparer. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | ToArray | Copies the elements of the List to a new array. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | TrimExcess | Sets the capacity to the actual number of elements in the List, if that number is less than a threshold value. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | TrueForAll | Determines whether every element in the List matches the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<IDisposable>)
Top

See Also

Reference

DisposingList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList Class : DisposingList Constructor

Glossary Item Box

Overload List

Overload | Description
DisposingList Constructor() | Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the default initial capacity.
DisposingList Constructor(IEnumerable<IDisposable>) | Initializes a new instance of the System.Collections.Generic.List>T> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.
DisposingList Constructor(Int32) | Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the specified initial capacity.

Requirements

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

See Also

Reference

DisposingList Class
DisposingList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList Class > DisposingList Constructor : DisposingList Constructor()

Glossary Item Box

Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the default initial capacity.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public DisposingList()

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string path;
using(DisposingList l = new DisposingList())
{
    TempFile ftarget = new TempFile();
    ftarget.Delete();

    l.Add(ftarget);
    TempFile fbigone = TempFile.Attach(String.Format("{0}.~{1:x4}", ftarget.TempPath, 0x10008 - 25));
    fbigone.Create().Dispose();
    Assert.IsTrue(fbigone.Exists);
    l.Add(fbigone);
    path = ftarget.TempPath;

    string tmpName;
    Dictionary<string, object> names = new Dictionary<string,object>(StringComparer.OrdinalIgnoreCase);

    for( int i=0; i < 25; i++ )
    {
        Stream s = ReplaceFile.CreateDerivedFile(ftarget.TempPath, out tmpName);
        l.Add(TempFile.Attach(tmpName));
        l.Add(s);
        names.Add(tmpName, null);
    }

    fbigone.Delete();
    Assert.AreEqual(25, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length);
}
Assert.AreEqual(0, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length);
VB.NET Copy Code
Dim path As String
Using l As New DisposingList()
    Dim ftarget As New TempFile()
    ftarget.Delete()

    l.Add(ftarget)
    Dim fbigone As TempFile = TempFile.Attach([String].Format("{0}.~{1:x4}", ftarget.TempPath, &H10008 - 25))
    fbigone.Create().Dispose()
    Assert.IsTrue(fbigone.Exists)
    l.Add(fbigone)
    path = ftarget.TempPath

    Dim tmpName As String
    Dim names As New Dictionary(Of String, Object)(StringComparer.OrdinalIgnoreCase)

    Dim i As Integer = 0
    While i < 25
        Dim s As Stream = ReplaceFile.CreateDerivedFile(ftarget.TempPath, tmpName)
        l.Add(TempFile.Attach(tmpName))
        l.Add(s)
        names.Add(tmpName, Nothing)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    fbigone.Delete()
    Assert.AreEqual(25, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length)
End Using
Assert.AreEqual(0, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length)

Requirements

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

See Also

Reference

DisposingList Class
DisposingList Members
Overload List

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList Constructor(IEnumerable<IDisposable>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList Class > DisposingList Constructor : DisposingList Constructor(IEnumerable<IDisposable>)

collection

Glossary Item Box

Initializes a new instance of the System.Collections.Generic.List>T> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal collection As IEnumerable(Of IDisposable) _
)
C#
public DisposingList(
   IEnumerable<IDisposable> collection
)

Parameters

collection

Example

Library/Library.Test/TestDisposingList.cs

C# Copy Code
disposeOrder.Clear();
DisposingList list = new DisposingList();

DisposeInOrder a = new DisposeInOrder();
DisposeInOrder b = new DisposeInOrder();

list.Add(a);
list.Add(b);
list.Add(null);
list.Dispose();

//Removed from list?
Assert.AreEqual(0, list.Count);
//All were disposed?
Assert.AreEqual(2, disposeOrder.Count);
//Disposed in reverse order of creation?
Assert.IsTrue(object.ReferenceEquals(b, disposeOrder[0]));
Assert.IsTrue(object.ReferenceEquals(a, disposeOrder[1]));

Assert.AreEqual(2, new DisposingList(new IDisposable[] { a, b }).Count);
Assert.AreEqual(0, new DisposingList(5).Count);
VB.NET Copy Code
disposeOrder.Clear()
Dim list As New DisposingList()

Dim a As New DisposeInOrder()
Dim b As New DisposeInOrder()

list.Add(a)
list.Add(b)
list.Add(Nothing)
list.Dispose()

'Removed from list?
Assert.AreEqual(0, list.Count)
'All were disposed?
Assert.AreEqual(2, disposeOrder.Count)
'Disposed in reverse order of creation?
Assert.IsTrue(Object.ReferenceEquals(b, disposeOrder(0)))
Assert.IsTrue(Object.ReferenceEquals(a, disposeOrder(1)))

Assert.AreEqual(2, New DisposingList(New IDisposable() {a, b}).Count)
Assert.AreEqual(0, New DisposingList(5).Count)

Requirements

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

See Also

Reference

DisposingList Class
DisposingList Members
Overload List

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList Constructor(Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList Class > DisposingList Constructor : DisposingList Constructor(Int32)

capacity

Glossary Item Box

Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the specified initial capacity.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal capacity As Integer _
)
C#
public DisposingList(
   int capacity
)

Parameters

capacity

Example

Library/Library.Test/TestDisposingList.cs

C# Copy Code
disposeOrder.Clear();
DisposingList list = new DisposingList();

DisposeInOrder a = new DisposeInOrder();
DisposeInOrder b = new DisposeInOrder();

list.Add(a);
list.Add(b);
list.Add(null);
list.Dispose();

//Removed from list?
Assert.AreEqual(0, list.Count);
//All were disposed?
Assert.AreEqual(2, disposeOrder.Count);
//Disposed in reverse order of creation?
Assert.IsTrue(object.ReferenceEquals(b, disposeOrder[0]));
Assert.IsTrue(object.ReferenceEquals(a, disposeOrder[1]));

Assert.AreEqual(2, new DisposingList(new IDisposable[] { a, b }).Count);
Assert.AreEqual(0, new DisposingList(5).Count);
VB.NET Copy Code
disposeOrder.Clear()
Dim list As New DisposingList()

Dim a As New DisposeInOrder()
Dim b As New DisposeInOrder()

list.Add(a)
list.Add(b)
list.Add(Nothing)
list.Dispose()

'Removed from list?
Assert.AreEqual(0, list.Count)
'All were disposed?
Assert.AreEqual(2, disposeOrder.Count)
'Disposed in reverse order of creation?
Assert.IsTrue(Object.ReferenceEquals(b, disposeOrder(0)))
Assert.IsTrue(Object.ReferenceEquals(a, disposeOrder(1)))

Assert.AreEqual(2, New DisposingList(New IDisposable() {a, b}).Count)
Assert.AreEqual(0, New DisposingList(5).Count)

Requirements

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

See Also

Reference

DisposingList Class
DisposingList Members
Overload List

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
DisposingList<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DisposingList<T> Class

Glossary Item Box

Disposes of each element in the collection when the collection is disposed.

Object Model

DisposingList<T> ClassT Class

Syntax

Visual Basic (Declaration)
Public Class DisposingList(Of T As IDisposable)
   Inherits System.Collections.Generic.List(Of T)
C#
public class DisposingList<T> : System.Collections.Generic.List<T>
where T: IDisposable

Type Parameters

T

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
using (TempFile tempFile = new TempFile())
{
    FileStreamFactory factory = new FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
    using (DisposingList<Stream> open = new DisposingList<Stream>())
    {
        for( int i = 0; i < 50; i++ )
            open.Add(factory.Create());
    }
}
VB.NET Copy Code
Using tempFile As New TempFile()
    Dim factory As New FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
    Using open As New DisposingList(Of Stream)()
        Dim i As Integer = 0
        While i < 50
            open.Add(factory.Create())
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Inheritance Hierarchy

System.Object
System.Collections.Generic.List<T>
CSharpTest.Net.Collections.DisposingList<T>
CSharpTest.Net.Collections.DisposingList

Requirements

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

See Also

Reference

DisposingList<T> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DisposingList<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DisposingList<T> Class

Glossary Item Box

The following tables list the members exposed by DisposingList<T>.

Public Constructors

 | Name | Description
Public Constructor | DisposingList<T> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Capacity | Gets or sets the total number of elements the internal data structure can hold without resizing. (Inherited from System.Collections.Generic.List<T>)
Public Property | Count | Gets the number of elements actually contained in the List. (Inherited from System.Collections.Generic.List<T>)
Public Property | Item | Gets or sets the element at the specified index. (Inherited from System.Collections.Generic.List<T>)
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an object to the end of the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | AddRange | Adds the elements of the specified collection to the end of the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | AsReadOnly | Returns a read-only IList wrapper for the current collection. (Inherited from System.Collections.Generic.List<T>)
Public Method | BinarySearch | Overloaded. Searches a range of elements in the sorted List for an element using the specified comparer and returns the zero-based index of the element. (Inherited from System.Collections.Generic.List<T>)
Public Method | Clear | Removes all elements from the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Contains | Determines whether an element is in the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | ConvertAll | Converts the elements in the current List to another type, and returns a list containing the converted elements. (Inherited from System.Collections.Generic.List<T>)
Public Method | CopyTo | Overloaded. Copies the entire List to a compatible one-dimensional array, starting at the beginning of the target array. (Inherited from System.Collections.Generic.List<T>)
Public Method | Dispose | Disposes of each element in the collection when the collection is disposed.
Public Method | Exists | Determines whether the List contains elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<T>)
Public Method | Find | Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | FindAll | Retrieves all the elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<T>)
Public Method | FindIndex | Overloaded. Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | FindLast | Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | FindLastIndex | Overloaded. Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | ForEach | Performs the specified action on each element of the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | GetRange | Creates a shallow copy of a range of elements in the source List. (Inherited from System.Collections.Generic.List<T>)
Public Method | IndexOf | Overloaded. Searches for the specified object and returns the zero-based index of the first occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Insert | Inserts an element into the List at the specified index. (Inherited from System.Collections.Generic.List<T>)
Public Method | InsertRange | Inserts the elements of a collection into the List at the specified index. (Inherited from System.Collections.Generic.List<T>)
Public Method | LastIndexOf | Overloaded. Searches for the specified object and returns the zero-based index of the last occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Remove | Removes the first occurrence of a specific object from the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | RemoveAll | Removes all the elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<T>)
Public Method | RemoveAt | Removes the element at the specified index of the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | RemoveRange | Removes a range of elements from the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Reverse | Overloaded. Reverses the order of the elements in the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Sort | Overloaded. Sorts the elements in the entire List using the default comparer. (Inherited from System.Collections.Generic.List<T>)
Public Method | ToArray | Copies the elements of the List to a new array. (Inherited from System.Collections.Generic.List<T>)
Public Method | TrimExcess | Sets the capacity to the actual number of elements in the List, if that number is less than a threshold value. (Inherited from System.Collections.Generic.List<T>)
Public Method | TrueForAll | Determines whether every element in the List matches the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<T>)
Top

See Also

Reference

DisposingList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList<T> Class : DisposingList<T> Constructor

Glossary Item Box

Overload List

Overload | Description
DisposingList<T> Constructor() | Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the default initial capacity.
DisposingList<T> Constructor(IEnumerable<T>) | Initializes a new instance of the System.Collections.Generic.List>T> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.
DisposingList<T> Constructor(Int32) | Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the specified initial capacity.

Requirements

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

See Also

Reference

DisposingList<T> Class
DisposingList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList<T> Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList<T> Class > DisposingList<T> Constructor : DisposingList<T> Constructor()

Glossary Item Box

Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the default initial capacity.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public DisposingList<T>()

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
using (TempFile tempFile = new TempFile())
{
    FileStreamFactory factory = new FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
    using (DisposingList<Stream> open = new DisposingList<Stream>())
    {
        for( int i = 0; i < 50; i++ )
            open.Add(factory.Create());
    }
}
VB.NET Copy Code
Using tempFile As New TempFile()
    Dim factory As New FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
    Using open As New DisposingList(Of Stream)()
        Dim i As Integer = 0
        While i < 50
            open.Add(factory.Create())
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

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

See Also

Reference

DisposingList<T> Class
DisposingList<T> Members
Overload List

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList<T> Constructor(IEnumerable<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList<T> Class > DisposingList<T> Constructor : DisposingList<T> Constructor(IEnumerable<T>)

collection

Glossary Item Box

Initializes a new instance of the System.Collections.Generic.List>T> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal collection As IEnumerable(Of T) _
)
C#
public DisposingList<T>(
   IEnumerable<T> collection
)

Parameters

collection

Example

Library/Library.Test/TestDisposingList.cs

C# Copy Code
disposeOrder.Clear();
DisposingList<DisposeInOrder> list = new DisposingList<DisposeInOrder>();

DisposeInOrder a = new DisposeInOrder();
DisposeInOrder b = new DisposeInOrder();

list.Add(a);
list.Add(b);
list.Add(null);
list.Dispose();

//Removed from list?
Assert.AreEqual(0, list.Count);
//All were disposed?
Assert.AreEqual(2, disposeOrder.Count);
//Disposed in reverse order of creation?
Assert.IsTrue(object.ReferenceEquals(b, disposeOrder[0]));
Assert.IsTrue(object.ReferenceEquals(a, disposeOrder[1]));

Assert.AreEqual(2, new DisposingList<DisposeInOrder>(new DisposeInOrder[] { a, b }).Count);
Assert.AreEqual(0, new DisposingList<DisposeInOrder>(5).Count);
VB.NET Copy Code
disposeOrder.Clear()
Dim list As New DisposingList(Of DisposeInOrder)()

Dim a As New DisposeInOrder()
Dim b As New DisposeInOrder()

list.Add(a)
list.Add(b)
list.Add(Nothing)
list.Dispose()

'Removed from list?
Assert.AreEqual(0, list.Count)
'All were disposed?
Assert.AreEqual(2, disposeOrder.Count)
'Disposed in reverse order of creation?
Assert.IsTrue(Object.ReferenceEquals(b, disposeOrder(0)))
Assert.IsTrue(Object.ReferenceEquals(a, disposeOrder(1)))

Assert.AreEqual(2, New DisposingList(Of DisposeInOrder)(New DisposeInOrder() {a, b}).Count)
Assert.AreEqual(0, New DisposingList(Of DisposeInOrder)(5).Count)

Requirements

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

See Also

Reference

DisposingList<T> Class
DisposingList<T> Members
Overload List

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingList<T> Constructor(Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList<T> Class > DisposingList<T> Constructor : DisposingList<T> Constructor(Int32)

capacity

Glossary Item Box

Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the specified initial capacity.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal capacity As Integer _
)
C#
public DisposingList<T>(
   int capacity
)

Parameters

capacity

Example

Library/Library.Test/TestDisposingList.cs

C# Copy Code
disposeOrder.Clear();
DisposingList<DisposeInOrder> list = new DisposingList<DisposeInOrder>();

DisposeInOrder a = new DisposeInOrder();
DisposeInOrder b = new DisposeInOrder();

list.Add(a);
list.Add(b);
list.Add(null);
list.Dispose();

//Removed from list?
Assert.AreEqual(0, list.Count);
//All were disposed?
Assert.AreEqual(2, disposeOrder.Count);
//Disposed in reverse order of creation?
Assert.IsTrue(object.ReferenceEquals(b, disposeOrder[0]));
Assert.IsTrue(object.ReferenceEquals(a, disposeOrder[1]));

Assert.AreEqual(2, new DisposingList<DisposeInOrder>(new DisposeInOrder[] { a, b }).Count);
Assert.AreEqual(0, new DisposingList<DisposeInOrder>(5).Count);
VB.NET Copy Code
disposeOrder.Clear()
Dim list As New DisposingList(Of DisposeInOrder)()

Dim a As New DisposeInOrder()
Dim b As New DisposeInOrder()

list.Add(a)
list.Add(b)
list.Add(Nothing)
list.Dispose()

'Removed from list?
Assert.AreEqual(0, list.Count)
'All were disposed?
Assert.AreEqual(2, disposeOrder.Count)
'Disposed in reverse order of creation?
Assert.IsTrue(Object.ReferenceEquals(b, disposeOrder(0)))
Assert.IsTrue(Object.ReferenceEquals(a, disposeOrder(1)))

Assert.AreEqual(2, New DisposingList(Of DisposeInOrder)(New DisposeInOrder() {a, b}).Count)
Assert.AreEqual(0, New DisposingList(Of DisposeInOrder)(5).Count)

Requirements

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

See Also

Reference

DisposingList<T> Class
DisposingList<T> Members
Overload List

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DisposingList<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DisposingList<T> Class

Glossary Item Box

For a list of all members of this type, see DisposingList<T> members.

Public Methods

 | Name | Description
Public Method | Add | Adds an object to the end of the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | AddRange | Adds the elements of the specified collection to the end of the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | AsReadOnly | Returns a read-only IList wrapper for the current collection. (Inherited from System.Collections.Generic.List<T>)
Public Method | BinarySearch | Overloaded. Searches a range of elements in the sorted List for an element using the specified comparer and returns the zero-based index of the element. (Inherited from System.Collections.Generic.List<T>)
Public Method | Clear | Removes all elements from the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Contains | Determines whether an element is in the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | ConvertAll | Converts the elements in the current List to another type, and returns a list containing the converted elements. (Inherited from System.Collections.Generic.List<T>)
Public Method | CopyTo | Overloaded. Copies the entire List to a compatible one-dimensional array, starting at the beginning of the target array. (Inherited from System.Collections.Generic.List<T>)
Public Method | Dispose | Disposes of each element in the collection when the collection is disposed.
Public Method | Exists | Determines whether the List contains elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<T>)
Public Method | Find | Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | FindAll | Retrieves all the elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<T>)
Public Method | FindIndex | Overloaded. Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | FindLast | Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | FindLastIndex | Overloaded. Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | ForEach | Performs the specified action on each element of the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | GetRange | Creates a shallow copy of a range of elements in the source List. (Inherited from System.Collections.Generic.List<T>)
Public Method | IndexOf | Overloaded. Searches for the specified object and returns the zero-based index of the first occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Insert | Inserts an element into the List at the specified index. (Inherited from System.Collections.Generic.List<T>)
Public Method | InsertRange | Inserts the elements of a collection into the List at the specified index. (Inherited from System.Collections.Generic.List<T>)
Public Method | LastIndexOf | Overloaded. Searches for the specified object and returns the zero-based index of the last occurrence within the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Remove | Removes the first occurrence of a specific object from the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | RemoveAll | Removes all the elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<T>)
Public Method | RemoveAt | Removes the element at the specified index of the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | RemoveRange | Removes a range of elements from the List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Reverse | Overloaded. Reverses the order of the elements in the entire List. (Inherited from System.Collections.Generic.List<T>)
Public Method | Sort | Overloaded. Sorts the elements in the entire List using the default comparer. (Inherited from System.Collections.Generic.List<T>)
Public Method | ToArray | Copies the elements of the List to a new array. (Inherited from System.Collections.Generic.List<T>)
Public Method | TrimExcess | Sets the capacity to the actual number of elements in the List, if that number is less than a threshold value. (Inherited from System.Collections.Generic.List<T>)
Public Method | TrueForAll | Determines whether every element in the List matches the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<T>)
Top

See Also

Reference

DisposingList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList<T> Class : Dispose Method

Glossary Item Box

Disposes of each element in the collection when the collection is disposed.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Example

Library/Library.Test/TestDisposingList.cs

C# Copy Code
disposeOrder.Clear();
DisposingList<DisposeInOrder> list = new DisposingList<DisposeInOrder>();

DisposeInOrder a = new DisposeInOrder();
DisposeInOrder b = new DisposeInOrder();

list.Add(a);
list.Add(b);
list.Add(null);
list.Dispose();

//Removed from list?
Assert.AreEqual(0, list.Count);
//All were disposed?
Assert.AreEqual(2, disposeOrder.Count);
//Disposed in reverse order of creation?
Assert.IsTrue(object.ReferenceEquals(b, disposeOrder[0]));
Assert.IsTrue(object.ReferenceEquals(a, disposeOrder[1]));

Assert.AreEqual(2, new DisposingList<DisposeInOrder>(new DisposeInOrder[] { a, b }).Count);
Assert.AreEqual(0, new DisposingList<DisposeInOrder>(5).Count);
VB.NET Copy Code
disposeOrder.Clear()
Dim list As New DisposingList(Of DisposeInOrder)()

Dim a As New DisposeInOrder()
Dim b As New DisposeInOrder()

list.Add(a)
list.Add(b)
list.Add(Nothing)
list.Dispose()

'Removed from list?
Assert.AreEqual(0, list.Count)
'All were disposed?
Assert.AreEqual(2, disposeOrder.Count)
'Disposed in reverse order of creation?
Assert.IsTrue(Object.ReferenceEquals(b, disposeOrder(0)))
Assert.IsTrue(Object.ReferenceEquals(a, disposeOrder(1)))

Assert.AreEqual(2, New DisposingList(Of DisposeInOrder)(New DisposeInOrder() {a, b}).Count)
Assert.AreEqual(0, New DisposingList(Of DisposeInOrder)(5).Count)

Requirements

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

See Also

Reference

DisposingList<T> Class
DisposingList<T> Members

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashUtilities Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : HashUtilities Class

Glossary Item Box

Syntax

Visual Basic (Declaration)
Friend Class HashUtilities
C#
internal class HashUtilities

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.HashUtilities

Requirements

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

See Also

Reference

HashUtilities Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HashUtilities Class Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : HashUtilities Class

Glossary Item Box

The following tables list the members exposed by HashUtilities.

Public Constructors

 | Name | Description
Public Constructor | HashUtilities Constructor |
Top

See Also

Reference

HashUtilities Class
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
HashUtilities Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > HashUtilities Class : HashUtilities Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public HashUtilities()

Requirements

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

See Also

Reference

HashUtilities Class
HashUtilities Members


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
KeyValueComparer<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : KeyValueComparer<TKey,TValue> Class

Glossary Item Box

Represents a key-value comparison

Syntax

Visual Basic (Declaration)
Public Class KeyValueComparer
    (Of TKey,TValue)
C#
public class KeyValueComparer<TKey,TValue>

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
KeyValueComparer<int, int> cmp = new KeyValueComparer<int, int>();
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, cmp.Comparer));
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, KeyValueComparer<int, int>.Default.Comparer));

Assert.AreEqual(-1, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(2, 1)));
Assert.AreEqual(0, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(1, 2)));
Assert.AreEqual(1, cmp.Compare(new KeyValuePair<int, int>(2, 1), new KeyValuePair<int, int>(1, 1)));
VB.NET Copy Code
Dim cmp As New KeyValueComparer(Of Integer, Integer)()
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], cmp.Comparer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], KeyValueComparer(Of Integer, Integer).[Default].Comparer))

Assert.AreEqual(-1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(2, 1)))
Assert.AreEqual(0, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(1, 2)))
Assert.AreEqual(1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(2, 1), New KeyValuePair(Of Integer, Integer)(1, 1)))

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.KeyValueComparer<TKey,TValue>

Requirements

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

See Also

Reference

KeyValueComparer<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
KeyValueComparer<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : KeyValueComparer<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by KeyValueComparer<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | KeyValueComparer<TKey,TValue> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Comparer | Returns the comparer being used by this instance
static (Shared in Visual Basic) | Default | Represents a key-value comparison using the default comparer for type TKey
Top

Public Methods

 | Name | Description
Public Method | Compare | Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
Top

See Also

Reference

KeyValueComparer<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
KeyValueComparer<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > KeyValueComparer<TKey,TValue> Class : KeyValueComparer<TKey,TValue> Constructor

Glossary Item Box

Overload List

Overload | Description
KeyValueComparer<TKey,TValue> Constructor() | Creates a key-value comparison using the default comparer for type TKey
KeyValueComparer<TKey,TValue> Constructor(IComparer<TKey>) | Creates a key-value comparison with the specified comparer

Requirements

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

See Also

Reference

KeyValueComparer<TKey,TValue> Class
KeyValueComparer<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
KeyValueComparer<TKey,TValue> Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > KeyValueComparer<TKey,TValue> Class > KeyValueComparer<TKey,TValue> Constructor : KeyValueComparer<TKey,TValue> Constructor()

Glossary Item Box

Creates a key-value comparison using the default comparer for type TKey

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public KeyValueComparer<TKey,TValue>()

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
KeyValueComparer<int, int> cmp = new KeyValueComparer<int, int>();
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, cmp.Comparer));
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, KeyValueComparer<int, int>.Default.Comparer));

Assert.AreEqual(-1, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(2, 1)));
Assert.AreEqual(0, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(1, 2)));
Assert.AreEqual(1, cmp.Compare(new KeyValuePair<int, int>(2, 1), new KeyValuePair<int, int>(1, 1)));
VB.NET Copy Code
Dim cmp As New KeyValueComparer(Of Integer, Integer)()
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], cmp.Comparer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], KeyValueComparer(Of Integer, Integer).[Default].Comparer))

Assert.AreEqual(-1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(2, 1)))
Assert.AreEqual(0, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(1, 2)))
Assert.AreEqual(1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(2, 1), New KeyValuePair(Of Integer, Integer)(1, 1)))

Requirements

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

See Also

Reference

KeyValueComparer<TKey,TValue> Class
KeyValueComparer<TKey,TValue> Members
Overload List

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
KeyValueComparer<TKey,TValue> Constructor(IComparer<TKey>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > KeyValueComparer<TKey,TValue> Class > KeyValueComparer<TKey,TValue> Constructor : KeyValueComparer<TKey,TValue> Constructor(IComparer<TKey>)

keyComparer

Glossary Item Box

Creates a key-value comparison with the specified comparer

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keyComparer As IComparer(Of TKey) _
)
C#
public KeyValueComparer<TKey,TValue>(
   IComparer<TKey> keyComparer
)

Parameters

keyComparer

Requirements

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

See Also

Reference

KeyValueComparer<TKey,TValue> Class
KeyValueComparer<TKey,TValue> Members
Overload List

Used By

Int32 BPlusTree.AddRange(IEnumerable>,Boolean)
Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)
IEnumerable> OrderedKeyValuePairs.Merge(IComparer,IEnumerable>[])
IEnumerable> OrderedKeyValuePairs.Merge(IComparer,DuplicateHandling,IEnumerable>[])

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
KeyValueComparer<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : KeyValueComparer<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see KeyValueComparer<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Compare | Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
Top

See Also

Reference

KeyValueComparer<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Compare Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > KeyValueComparer<TKey,TValue> Class : Compare Method

x
y

Glossary Item Box

Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

Syntax

Visual Basic (Declaration)
Public Function Compare( _
   ByVal x As KeyValuePair(Of TKey,TValue), _
   ByVal y As KeyValuePair(Of TKey,TValue) _
) As Integer
C#
public int Compare(
   KeyValuePair<TKey,TValue> x,
   KeyValuePair<TKey,TValue> y
)

Parameters

x
y

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
KeyValueComparer<int, int> cmp = new KeyValueComparer<int, int>();
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, cmp.Comparer));
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, KeyValueComparer<int, int>.Default.Comparer));

Assert.AreEqual(-1, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(2, 1)));
Assert.AreEqual(0, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(1, 2)));
Assert.AreEqual(1, cmp.Compare(new KeyValuePair<int, int>(2, 1), new KeyValuePair<int, int>(1, 1)));
VB.NET Copy Code
Dim cmp As New KeyValueComparer(Of Integer, Integer)()
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], cmp.Comparer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], KeyValueComparer(Of Integer, Integer).[Default].Comparer))

Assert.AreEqual(-1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(2, 1)))
Assert.AreEqual(0, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(1, 2)))
Assert.AreEqual(1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(2, 1), New KeyValuePair(Of Integer, Integer)(1, 1)))

Requirements

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

See Also

Reference

KeyValueComparer<TKey,TValue> Class
KeyValueComparer<TKey,TValue> Members

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
KeyValueComparer<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : KeyValueComparer<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see KeyValueComparer<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Comparer | Returns the comparer being used by this instance
static (Shared in Visual Basic) | Default | Represents a key-value comparison using the default comparer for type TKey
Top

See Also

Reference

KeyValueComparer<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > KeyValueComparer<TKey,TValue> Class : Comparer Property

Glossary Item Box

Returns the comparer being used by this instance

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Comparer As IComparer(Of TKey)
C#
public IComparer<TKey> Comparer {get;}

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

KeyValueComparer<TKey,TValue> Class
KeyValueComparer<TKey,TValue> Members

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Default Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > KeyValueComparer<TKey,TValue> Class : Default Property

Glossary Item Box

Represents a key-value comparison using the default comparer for type TKey

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Default As KeyValueComparer(Of TKey,TValue)
C#
public static KeyValueComparer<TKey,TValue> Default {get;}

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
KeyValueComparer<int, int> cmp = new KeyValueComparer<int, int>();
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, cmp.Comparer));
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, KeyValueComparer<int, int>.Default.Comparer));

Assert.AreEqual(-1, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(2, 1)));
Assert.AreEqual(0, cmp.Compare(new KeyValuePair<int, int>(1, 1), new KeyValuePair<int, int>(1, 2)));
Assert.AreEqual(1, cmp.Compare(new KeyValuePair<int, int>(2, 1), new KeyValuePair<int, int>(1, 1)));
VB.NET Copy Code
Dim cmp As New KeyValueComparer(Of Integer, Integer)()
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], cmp.Comparer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], KeyValueComparer(Of Integer, Integer).[Default].Comparer))

Assert.AreEqual(-1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(2, 1)))
Assert.AreEqual(0, cmp.Compare(New KeyValuePair(Of Integer, Integer)(1, 1), New KeyValuePair(Of Integer, Integer)(1, 2)))
Assert.AreEqual(1, cmp.Compare(New KeyValuePair(Of Integer, Integer)(2, 1), New KeyValuePair(Of Integer, Integer)(1, 1)))

Requirements

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

See Also

Reference

KeyValueComparer<TKey,TValue> Class
KeyValueComparer<TKey,TValue> Members

Source Code

Library/Collections/KeyValueComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode Class

Glossary Item Box

The basic Linked-list node, untyped, use LListNode<T> for strong typed nodes and lists.

Object Model

LListNode ClassLListNode ClassLListNode Class

Syntax

Visual Basic (Declaration)
Public Class LListNode
C#
public class LListNode

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.LListNode
CSharpTest.Net.Collections.LListNode<T>

Requirements

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

See Also

Reference

LListNode Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LListNode Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode Class

Glossary Item Box

The following tables list the members exposed by LListNode.

Protected Constructors

 | Name | Description
Protected Constructor | LListNode Constructor | You may derive an instance class from LListNode and use it in a single list, or you may construct a node<T> with the value that the node should contain.
Top

Public Properties

 | Name | Description
Public Property | Next | Returns the next item in the list or null
Public Property | Previous | Returns the previous item in the list or null
Top

See Also

Reference

LListNode Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode Class : LListNode Constructor

Glossary Item Box

You may derive an instance class from LListNode and use it in a single list, or you may construct a node<T> with the value that the node should contain.

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected LListNode()

Requirements

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

See Also

Reference

LListNode Class
LListNode Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LListNode Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode Class

Glossary Item Box

For a list of all members of this type, see LListNode members.

Public Properties

 | Name | Description
Public Property | Next | Returns the next item in the list or null
Public Property | Previous | Returns the previous item in the list or null
Top

See Also

Reference

LListNode Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Next Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode Class : Next Property

Glossary Item Box

Returns the next item in the list or null

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Next As LListNode
C#
public LListNode Next {get;}

Requirements

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

See Also

Reference

LListNode Class
LListNode Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Previous Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode Class : Previous Property

Glossary Item Box

Returns the previous item in the list or null

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Previous As LListNode
C#
public LListNode Previous {get;}

Requirements

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

See Also

Reference

LListNode Class
LListNode Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
LListNode<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode<T> Class

Glossary Item Box

A typed node, used similiarly to LinkedListNode<T>. Can belong to single list at a time, the type of list is usually LListNode<T>.LList

Syntax

Visual Basic (Declaration)
Public Class LListNode(Of T)
   Inherits LListNode
C#
public class LListNode<T> : LListNode

Type Parameters

T

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.LListNode
CSharpTest.Net.Collections.LListNode<T>

Requirements

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

See Also

Reference

LListNode<T> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LListNode<T> Class Members
See Also Fields Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode<T> Class

Glossary Item Box

The following tables list the members exposed by LListNode<T>.

Public Constructors

 | Name | Description
Public Constructor | LListNode<T> Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | Value | Gets/Sets the value of this node
Top

Public Properties

 | Name | Description
Public Property | Next | Returns the next item in the list or null
Public Property | Previous | Returns the previous item in the list or null
Top

See Also

Reference

LListNode<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode<T> Class : LListNode<T> Constructor

Glossary Item Box

Overload List

Overload | Description
LListNode<T> Constructor() | Constructs a node without a value
LListNode<T> Constructor(T) | Constructs a node with a value

Requirements

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

See Also

Reference

LListNode<T> Class
LListNode<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode<T> Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode<T> Class > LListNode<T> Constructor : LListNode<T> Constructor()

Glossary Item Box

Constructs a node without a value

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public LListNode<T>()

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode<T> Class
LListNode<T> Members
Overload List

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode<T> Constructor(T)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode<T> Class > LListNode<T> Constructor : LListNode<T> Constructor(T)

value

Glossary Item Box

Constructs a node with a value

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal value As T _
)
C#
public LListNode<T>(
   T value
)

Parameters

value

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode<T> Class
LListNode<T> Members
Overload List

Source Code

Library/Collections/LListNode.cs

Used By

LListNode.LList.AddFirst(T)
LListNode.LList.AddLast(T)


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LListNode<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode<T> Class

Glossary Item Box

For a list of all members of this type, see LListNode<T> members.

Public Properties

 | Name | Description
Public Property | Next | Returns the next item in the list or null
Public Property | Previous | Returns the previous item in the list or null
Top

See Also

Reference

LListNode<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Next Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode<T> Class : Next Property

Glossary Item Box

Returns the next item in the list or null

Syntax

Visual Basic (Declaration)
Public Shadows ReadOnly Property Next As LListNode(Of T)
C#
public new LListNode<T> Next {get;}

Requirements

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

See Also

Reference

LListNode<T> Class
LListNode<T> Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Previous Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode<T> Class : Previous Property

Glossary Item Box

Returns the previous item in the list or null

Syntax

Visual Basic (Declaration)
Public Shadows ReadOnly Property Previous As LListNode(Of T)
C#
public new LListNode<T> Previous {get;}

Requirements

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

See Also

Reference

LListNode<T> Class
LListNode<T> Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
LListNode<T> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode<T> Class

Glossary Item Box

For a list of all members of this type, see LListNode<T> members.

Public Fields

 | Name | Description
Public Field | Value | Gets/Sets the value of this node
Top

See Also

Reference

LListNode<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode<T> Class : Value Field

Glossary Item Box

Gets/Sets the value of this node

Syntax

Visual Basic (Declaration)
Public Value As T
C#
public T Value

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string>.LList list = new LListNode<string>.LList();
Assert.IsTrue(list.IsEmpty);
list.AddLast("B");
Assert.IsFalse(list.IsEmpty);
list.AddFirst("A");
Assert.AreEqual("A", list.First.Value);
Assert.AreEqual("B", list.Last.Value);
VB.NET Copy Code
Dim list As New LListNode(Of String).LList()
Assert.IsTrue(list.IsEmpty)
list.AddLast("B")
Assert.IsFalse(list.IsEmpty)
list.AddFirst("A")
Assert.AreEqual("A", list.First.Value)
Assert.AreEqual("B", list.Last.Value)

Requirements

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

See Also

Reference

LListNode<T> Class
LListNode<T> Members

Source Code

Library/Collections/LListNode.cs

Used By

WaitAndContinueList.Dispose()
Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)


%%PageItemTitle%%

T
[image]
CSharpTest.Net
LListNode.LList<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList<T> Class

Glossary Item Box

Provides a linked list of nodes of type T

Syntax

Visual Basic (Declaration)
Public Class LListNode.LList(Of T)
   Inherits CSharpTest.Net.Collections.LListNode.LList(Of LListNode(Of T))
C#
public class LListNode.LList<T> : CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>

Type Parameters

T

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.LListNode.LList<TNode>
CSharpTest.Net.Collections.LListNode`1.LList<T>

Requirements

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

See Also

Reference

LListNode.LList<T> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LListNode.LList<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList<T> Class

Glossary Item Box

The following tables list the members exposed by LListNode.LList<T>.

Public Constructors

 | Name | Description
Public Constructor | LListNode.LList<T> Constructor |
Top

Public Properties

 | Name | Description
Public Property | Count | Returns the number of items in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Property | First | Returns the first node in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Property | IsEmpty | Returns true if the list is empty (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Property | Last | Returns the last node in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Top

Public Methods

 | Name | Description
Public Method | AddFirst | Overloaded. Adds the node to the front of the list
Public Method | AddLast | Overloaded. Adds the node to the end of the list
Public Method | Clear | Remvoes all the nodes from the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection. (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Method | Remove | Remvoes the node from the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Top

See Also

Reference

LListNode.LList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode.LList<T> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<T> Class : LListNode.LList<T> Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public LListNode.LList<T>()

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode.LList<T> Class
LListNode.LList<T> Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LListNode.LList<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList<T> Class

Glossary Item Box

For a list of all members of this type, see LListNode.LList<T> members.

Public Methods

 | Name | Description
Public Method | AddFirst | Overloaded. Adds the node to the front of the list
Public Method | AddLast | Overloaded. Adds the node to the end of the list
Public Method | Clear | Remvoes all the nodes from the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection. (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Method | Remove | Remvoes the node from the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Top

See Also

Reference

LListNode.LList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddFirst Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<T> Class : AddFirst Method

Glossary Item Box

Adds the node to the front of the list

Overload List

Overload | Description
AddFirst(T) | Adds the node to the front of the list
AddFirst | Adds the node to the front of the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)

Requirements

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

See Also

Reference

LListNode.LList<T> Class
LListNode.LList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddFirst(T) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<T> Class > AddFirst Method : AddFirst(T) Method

value

Glossary Item Box

Adds the node to the front of the list

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddFirst( _
   ByVal value As T _
)
C#
public void AddFirst(
   T value
)

Parameters

value

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string>.LList list = new LListNode<string>.LList();
Assert.IsTrue(list.IsEmpty);
list.AddLast("B");
Assert.IsFalse(list.IsEmpty);
list.AddFirst("A");
Assert.AreEqual("A", list.First.Value);
Assert.AreEqual("B", list.Last.Value);
VB.NET Copy Code
Dim list As New LListNode(Of String).LList()
Assert.IsTrue(list.IsEmpty)
list.AddLast("B")
Assert.IsFalse(list.IsEmpty)
list.AddFirst("A")
Assert.AreEqual("A", list.First.Value)
Assert.AreEqual("B", list.Last.Value)

Requirements

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

See Also

Reference

LListNode.LList<T> Class
LListNode.LList<T> Members
Overload List

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddLast Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<T> Class : AddLast Method

Glossary Item Box

Adds the node to the end of the list

Overload List

Overload | Description
AddLast(T) | Adds the node to the end of the list
AddLast | Adds the node to the end of the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)

Requirements

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

See Also

Reference

LListNode.LList<T> Class
LListNode.LList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddLast(T) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<T> Class > AddLast Method : AddLast(T) Method

value

Glossary Item Box

Adds the node to the end of the list

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddLast( _
   ByVal value As T _
)
C#
public void AddLast(
   T value
)

Parameters

value

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string>.LList list = new LListNode<string>.LList();
Assert.IsTrue(list.IsEmpty);
list.AddLast("B");
Assert.IsFalse(list.IsEmpty);
list.AddFirst("A");
Assert.AreEqual("A", list.First.Value);
Assert.AreEqual("B", list.Last.Value);
VB.NET Copy Code
Dim list As New LListNode(Of String).LList()
Assert.IsTrue(list.IsEmpty)
list.AddLast("B")
Assert.IsFalse(list.IsEmpty)
list.AddFirst("A")
Assert.AreEqual("A", list.First.Value)
Assert.AreEqual("B", list.Last.Value)

Requirements

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

See Also

Reference

LListNode.LList<T> Class
LListNode.LList<T> Members
Overload List

Source Code

Library/Collections/LListNode.cs

Used By

WaitAndContinueList.AddWork(IWaitAndContinue)


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode.LList Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList Class

Glossary Item Box

Provides a linked list of nodes of type T

Syntax

Visual Basic (Declaration)
Public Class LListNode.LList
   Inherits CSharpTest.Net.Collections.LListNode.LList(Of LListNode)
C#
public class LListNode.LList : CSharpTest.Net.Collections.LListNode.LList<LListNode>

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.LListNode.LList<TNode>
CSharpTest.Net.Collections.LListNode.LList

Requirements

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

See Also

Reference

LListNode.LList Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LListNode.LList Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList Class

Glossary Item Box

The following tables list the members exposed by LListNode.LList.

Public Constructors

 | Name | Description
Public Constructor | LListNode.LList Constructor |
Top

Public Properties

 | Name | Description
Public Property | Count | Returns the number of items in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Property | First | Returns the first node in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Property | IsEmpty | Returns true if the list is empty (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Property | Last | Returns the last node in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Top

Public Methods

 | Name | Description
Public Method | AddFirst | Adds the node to the front of the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Method | AddLast | Adds the node to the end of the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Method | Clear | Remvoes all the nodes from the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection. (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Method | Remove | Remvoes the node from the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Top

See Also

Reference

LListNode.LList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode.LList Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList Class : LListNode.LList Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public LListNode.LList()

Requirements

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

See Also

Reference

LListNode.LList Class
LListNode.LList Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

TNode
[image]
CSharpTest.Net
LListNode.LList<TNode> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList<TNode> Class

Glossary Item Box

Provides a linked list of nodes of type T

Syntax

Visual Basic (Declaration)
Public Class LListNode.LList(Of TNode As LListNode)
C#
public class LListNode.LList<TNode>
where TNode: LListNode

Type Parameters

TNode

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.LListNode.LList<TNode>
CSharpTest.Net.Collections.LListNode`1.LList<T>
CSharpTest.Net.Collections.LListNode.LList

Requirements

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

See Also

Reference

LListNode.LList<TNode> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LListNode.LList<TNode> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList<TNode> Class

Glossary Item Box

The following tables list the members exposed by LListNode.LList<TNode>.

Public Constructors

 | Name | Description
Public Constructor | LListNode.LList<TNode> Constructor |
Top

Public Properties

 | Name | Description
Public Property | Count | Returns the number of items in the list
Public Property | First | Returns the first node in the list
Public Property | IsEmpty | Returns true if the list is empty
Public Property | Last | Returns the last node in the list
Top

Public Methods

 | Name | Description
Public Method | AddFirst | Adds the node to the front of the list
Public Method | AddLast | Adds the node to the end of the list
Public Method | Clear | Remvoes all the nodes from the list
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | Remove | Remvoes the node from the list
Top

See Also

Reference

LListNode.LList<TNode> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LListNode.LList<TNode> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : LListNode.LList<TNode> Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public LListNode.LList<TNode>()

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LListNode.LList<TNode> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList<TNode> Class

Glossary Item Box

For a list of all members of this type, see LListNode.LList<TNode> members.

Public Methods

 | Name | Description
Public Method | AddFirst | Adds the node to the front of the list
Public Method | AddLast | Adds the node to the end of the list
Public Method | Clear | Remvoes all the nodes from the list
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | Remove | Remvoes the node from the list
Top

See Also

Reference

LListNode.LList<TNode> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddFirst Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : AddFirst Method

value

Glossary Item Box

Adds the node to the front of the list

Syntax

Visual Basic (Declaration)
Public Sub AddFirst( _
   ByVal value As TNode _
)
C#
public void AddFirst(
   TNode value
)

Parameters

value

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs

Used By

LListNode.LList.AddFirst(T)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddLast Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : AddLast Method

value

Glossary Item Box

Adds the node to the end of the list

Syntax

Visual Basic (Declaration)
Public Sub AddLast( _
   ByVal value As TNode _
)
C#
public void AddLast(
   TNode value
)

Parameters

value

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs

Used By

LListNode.LList.AddLast(T)
WaitAndContinueList.AddWork(WaitAndContinueList)


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : Clear Method

Glossary Item Box

Remvoes all the nodes from the list

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs

Used By

WaitAndContinueList.Dispose()


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of TNode)
C#
public IEnumerator<TNode> GetEnumerator()

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string>.LList list = new LListNode<string>.LList();
list.AddLast("B");
list.AddFirst("A");
System.Collections.Generic.IEnumerator<LListNode<string>> e = list.GetEnumerator();
using (e)
{
    Assert.IsTrue(e.MoveNext());
    Assert.IsTrue(ReferenceEquals(e.Current, ((System.Collections.IEnumerator)e).Current));
    Assert.AreEqual("A", e.Current.Value);
    list.Remove(e.Current);

    Assert.IsTrue(e.MoveNext());
    Assert.IsTrue(ReferenceEquals(e.Current, ((System.Collections.IEnumerator)e).Current));
    Assert.AreEqual("B", e.Current.Value);
    list.Remove(e.Current);

    Assert.IsFalse(e.MoveNext());

    Assert.IsTrue(list.IsEmpty);
    list.AddLast(String.Empty);

    e.Reset();
    Assert.IsTrue(e.MoveNext());
    Assert.AreEqual(String.Empty, e.Current.Value);
    Assert.IsFalse(e.MoveNext());

    try
    {
        GC.KeepAlive(e.Current);
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }
}

//now e is disposed...
try
{
    e.MoveNext();
    Assert.Fail();
}
catch (ObjectDisposedException) { }
try
{
    GC.KeepAlive(e.Current);
    Assert.Fail();
}
catch (ObjectDisposedException) { }
try
{
    e.Reset();
    Assert.Fail();
}
catch (ObjectDisposedException) { }
VB.NET Copy Code
Dim list As New LListNode(Of String).LList()
list.AddLast("B")
list.AddFirst("A")
Dim e As System.Collections.Generic.IEnumerator(Of LListNode(Of String)) = list.GetEnumerator()
Using e
    Assert.IsTrue(e.MoveNext())
    Assert.IsTrue(ReferenceEquals(e.Current, (DirectCast(e, System.Collections.IEnumerator)).Current))
    Assert.AreEqual("A", e.Current.Value)
    list.Remove(e.Current)

    Assert.IsTrue(e.MoveNext())
    Assert.IsTrue(ReferenceEquals(e.Current, (DirectCast(e, System.Collections.IEnumerator)).Current))
    Assert.AreEqual("B", e.Current.Value)
    list.Remove(e.Current)

    Assert.IsFalse(e.MoveNext())

    Assert.IsTrue(list.IsEmpty)
    list.AddLast([String].Empty)

    e.Reset()
    Assert.IsTrue(e.MoveNext())
    Assert.AreEqual([String].Empty, e.Current.Value)
    Assert.IsFalse(e.MoveNext())

    Try
        GC.KeepAlive(e.Current)
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try
End Using

'now e is disposed...
Try
    e.MoveNext()
    Assert.Fail()
Catch generatedExceptionName As ObjectDisposedException
End Try
Try
    GC.KeepAlive(e.Current)
    Assert.Fail()
Catch generatedExceptionName As ObjectDisposedException
End Try
Try
    e.Reset()
    Assert.Fail()
Catch generatedExceptionName As ObjectDisposedException
End Try

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Used By

LListNode.LList.Clear()
WaitAndContinueList.Dispose()

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : Remove Method

value

Glossary Item Box

Remvoes the node from the list

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal value As TNode _
) As Boolean
C#
public bool Remove(
   TNode value
)

Parameters

value

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs

Used By

WaitAndContinueList.AddWork(WaitAndContinueList)


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LListNode.LList<TNode> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList<TNode> Class

Glossary Item Box

For a list of all members of this type, see LListNode.LList<TNode> members.

Public Properties

 | Name | Description
Public Property | Count | Returns the number of items in the list
Public Property | First | Returns the first node in the list
Public Property | IsEmpty | Returns true if the list is empty
Public Property | Last | Returns the last node in the list
Top

See Also

Reference

LListNode.LList<TNode> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : Count Property

Glossary Item Box

Returns the number of items in the list

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
First Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : First Property

Glossary Item Box

Returns the first node in the list

Syntax

Visual Basic (Declaration)
Public ReadOnly Property First As TNode
C#
public TNode First {get;}

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs

Used By

WaitAndContinueList.AddWork(WaitAndContinueList)
Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)


%%PageItemTitle%%

[image]
CSharpTest.Net
IsEmpty Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : IsEmpty Property

Glossary Item Box

Returns true if the list is empty

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsEmpty As Boolean
C#
public bool IsEmpty {get;}

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string>.LList list = new LListNode<string>.LList();
Assert.IsTrue(list.IsEmpty);
list.AddLast("B");
Assert.IsFalse(list.IsEmpty);
list.AddFirst("A");
Assert.AreEqual("A", list.First.Value);
Assert.AreEqual("B", list.Last.Value);
VB.NET Copy Code
Dim list As New LListNode(Of String).LList()
Assert.IsTrue(list.IsEmpty)
list.AddLast("B")
Assert.IsFalse(list.IsEmpty)
list.AddFirst("A")
Assert.AreEqual("A", list.First.Value)
Assert.AreEqual("B", list.Last.Value)

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Last Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode.LList<TNode> Class : Last Property

Glossary Item Box

Returns the last node in the list

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Last As TNode
C#
public TNode Last {get;}

Example

Library/Library.Test/TestLinkList.cs

C# Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NET Copy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

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

See Also

Reference

LListNode.LList<TNode> Class
LListNode.LList<TNode> Members

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%%

TKey
The type of keys in the dictionary.
TValue
The type of values in the dictionary.
[image]
CSharpTest.Net
LurchTable<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable<TKey,TValue> Class

Glossary Item Box

LurchTable stands for "Least Used Recently Concurrent Hash Table" and has definate similarities to both the .NET 4 ConcurrentDictionary as well as Java's LinkedHashMap. This gives you a thread-safe dictionary/hashtable that stores element ordering by insertion, updates, or access. In addition it can be configured to use a 'hard-limit' count of items that will automatically 'pop' the oldest item in the collection.

Object Model

LurchTable<TKey,TValue> ClassTValue Class

Syntax

Visual Basic (Declaration)
Public Class LurchTable
    (Of TKey,TValue)
   Implements IConcurrentDictionary(Of TKey,TValue), IDictionaryEx(Of TKey,TValue)
C#
public class LurchTable<TKey,TValue> : IConcurrentDictionary<TKey,TValue>, IDictionaryEx<TKey,TValue>

Type Parameters

TKey
The type of keys in the dictionary.
TValue
The type of values in the dictionary.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
//multiple of prime will produce hash collision, thus testing removal of non-first elements
const int prime = 1103;
var test = new LurchTable<int, string>(LurchTableOrder.Access, 10, prime, 10, 10, EqualityComparer<int>.Default);
test[1 * prime] = "a";
test[2 * prime] = "b";
test[3 * prime] = "c";
test[4 * prime] = "d";
test[5 * prime] = "e";
Assert.IsTrue(test.Remove(4 * prime));
Assert.IsTrue(test.Remove(2 * prime));
Assert.IsTrue(test.Remove(5 * prime));
Assert.IsTrue(test.Remove(1 * prime));
Assert.IsTrue(test.Remove(3 * prime));
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
'multiple of prime will produce hash collision, thus testing removal of non-first elements
Const  prime As Integer = 1103
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 10, prime, 10, 10, EqualityComparer(Of Integer).[Default])
test(1 * prime) = "a"
test(2 * prime) = "b"
test(3 * prime) = "c"
test(4 * prime) = "d"
test(5 * prime) = "e"
Assert.IsTrue(test.Remove(4 * prime))
Assert.IsTrue(test.Remove(2 * prime))
Assert.IsTrue(test.Remove(5 * prime))
Assert.IsTrue(test.Remove(1 * prime))
Assert.IsTrue(test.Remove(3 * prime))
Assert.AreEqual(0, test.Count)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.LurchTable<TKey,TValue>

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by LurchTable<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | LurchTable<TKey,TValue> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Comparer | Retrives the key comparer being used by this instance.
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | Item | Gets or sets the element with the specified key.
Public Property | Keys | Gets an ICollection containing the keys of the IDictionary.
Public Property | Limit | Retrives the record limit allowed in this instance.
Public Property | Ordering | Retrieves the LurchTableOrder Ordering enumeration this instance was created with.
Public Property | Values | Gets an ICollection containing the values in the IDictionary.
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an element with the provided key and value to the IDictionary.
Public Method | AddOrUpdate | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
Public Method | Clear | Removes all items from the ICollection.
Public Method | ContainsKey | Determines whether the IDictionary contains an element with the specified key.
Public Method | Dequeue | Removes the oldest entry in the collection based on the ordering supplied to the constructor. If an item is not available a busy-wait loop is used to wait for for an item.
Public Method | Dispose | Clears references to all objects and invalidates the collection
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | GetOrAdd | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist.
Public Method | Initialize | WARNING: not thread-safe, reinitializes all internal structures. Use Clear() for a thread-safe delete all. If you have externally provided exclusive access this method may be used to more efficiently clear the collection.
Public Method | Peek | Retrieves the oldest entry in the collection based on the ordering supplied to the constructor.
Public Method | Remove | Removes the element with the specified key from the IDictionary.
Public Method | TryAdd | Overloaded. Adds an element with the provided key and value to the IDictionary.
Public Method | TryDequeue | Overloaded. Removes the oldest entry in the collection based on the ordering supplied to the constructor.
Public Method | TryGetValue | Gets the value associated with the specified key.
Public Method | TryRemove | Overloaded. Removes the element with the specified key from the IDictionary.
Public Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Top

Public Events

 | Name | Description
Public Event | ItemAdded | Event raised after an item is added to the collection
Public Event | ItemRemoved | Event raised after an item is removed from the collection
Public Event | ItemUpdated | Event raised after an item is updated in the collection
Top

See Also

Reference

LurchTable<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : LurchTable<TKey,TValue> Constructor

Glossary Item Box

Overload List

Overload | Description
LurchTable<TKey,TValue> Constructor(Int32) | Creates a LurchTable that can store up to (capacity) items efficiently.
LurchTable<TKey,TValue> Constructor(Int32,LurchTableOrder) | Creates a LurchTable that can store up to (capacity) items efficiently.
LurchTable<TKey,TValue> Constructor(Int32,LurchTableOrder,IEqualityComparer<TKey>) | Creates a LurchTable that can store up to (capacity) items efficiently.
LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32) | Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached.
LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32,IEqualityComparer<TKey>) | Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached.
LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32,Int32,Int32,Int32,IEqualityComparer<TKey>) | Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Constructor(Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > LurchTable<TKey,TValue> Constructor : LurchTable<TKey,TValue> Constructor(Int32)

capacity

Glossary Item Box

Creates a LurchTable that can store up to (capacity) items efficiently.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal capacity As Integer _
)
C#
public LurchTable<TKey,TValue>(
   int capacity
)

Parameters

capacity

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var cmp = new IntComparer();
const int limit = 5;

Assert.AreEqual(LurchTableOrder.None, new LurchTable<int, int>(1).Ordering);
Assert.AreEqual(LurchTableOrder.Insertion, new LurchTable<int, int>(1, LurchTableOrder.Insertion).Ordering);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(1, LurchTableOrder.Insertion, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Modified, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Limit);
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer));
VB.NET Copy Code
Dim cmp As var = New IntComparer()
Const  limit As Integer = 5

Assert.AreEqual(LurchTableOrder.None, New LurchTable(Of Integer, Integer)(1).Ordering)
Assert.AreEqual(LurchTableOrder.Insertion, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion).Ordering)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Modified, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Limit)
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Constructor(Int32,LurchTableOrder)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > LurchTable<TKey,TValue> Constructor : LurchTable<TKey,TValue> Constructor(Int32,LurchTableOrder)

capacity
ordering

Glossary Item Box

Creates a LurchTable that can store up to (capacity) items efficiently.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal capacity As Integer, _
   ByVal ordering As LurchTableOrder _
)
C#
public LurchTable<TKey,TValue>(
   int capacity,
   LurchTableOrder ordering
)

Parameters

capacity
ordering

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var cmp = new IntComparer();
const int limit = 5;

Assert.AreEqual(LurchTableOrder.None, new LurchTable<int, int>(1).Ordering);
Assert.AreEqual(LurchTableOrder.Insertion, new LurchTable<int, int>(1, LurchTableOrder.Insertion).Ordering);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(1, LurchTableOrder.Insertion, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Modified, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Limit);
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer));
VB.NET Copy Code
Dim cmp As var = New IntComparer()
Const  limit As Integer = 5

Assert.AreEqual(LurchTableOrder.None, New LurchTable(Of Integer, Integer)(1).Ordering)
Assert.AreEqual(LurchTableOrder.Insertion, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion).Ordering)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Modified, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Limit)
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Constructor(Int32,LurchTableOrder,IEqualityComparer<TKey>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > LurchTable<TKey,TValue> Constructor : LurchTable<TKey,TValue> Constructor(Int32,LurchTableOrder,IEqualityComparer<TKey>)

capacity
ordering
comparer

Glossary Item Box

Creates a LurchTable that can store up to (capacity) items efficiently.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal capacity As Integer, _
   ByVal ordering As LurchTableOrder, _
   ByVal comparer As IEqualityComparer(Of TKey) _
)
C#
public LurchTable<TKey,TValue>(
   int capacity,
   LurchTableOrder ordering,
   IEqualityComparer<TKey> comparer
)

Parameters

capacity
ordering
comparer

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var cmp = new IntComparer();
const int limit = 5;

Assert.AreEqual(LurchTableOrder.None, new LurchTable<int, int>(1).Ordering);
Assert.AreEqual(LurchTableOrder.Insertion, new LurchTable<int, int>(1, LurchTableOrder.Insertion).Ordering);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(1, LurchTableOrder.Insertion, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Modified, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Limit);
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer));
VB.NET Copy Code
Dim cmp As var = New IntComparer()
Const  limit As Integer = 5

Assert.AreEqual(LurchTableOrder.None, New LurchTable(Of Integer, Integer)(1).Ordering)
Assert.AreEqual(LurchTableOrder.Insertion, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion).Ordering)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Modified, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Limit)
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > LurchTable<TKey,TValue> Constructor : LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32)

ordering
limit

Glossary Item Box

Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ordering As LurchTableOrder, _
   ByVal limit As Integer _
)
C#
public LurchTable<TKey,TValue>(
   LurchTableOrder ordering,
   int limit
)

Parameters

ordering
limit

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var cmp = new IntComparer();
const int limit = 5;

Assert.AreEqual(LurchTableOrder.None, new LurchTable<int, int>(1).Ordering);
Assert.AreEqual(LurchTableOrder.Insertion, new LurchTable<int, int>(1, LurchTableOrder.Insertion).Ordering);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(1, LurchTableOrder.Insertion, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Modified, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Limit);
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer));
VB.NET Copy Code
Dim cmp As var = New IntComparer()
Const  limit As Integer = 5

Assert.AreEqual(LurchTableOrder.None, New LurchTable(Of Integer, Integer)(1).Ordering)
Assert.AreEqual(LurchTableOrder.Insertion, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion).Ordering)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Modified, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Limit)
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32,IEqualityComparer<TKey>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > LurchTable<TKey,TValue> Constructor : LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32,IEqualityComparer<TKey>)

ordering
limit
comparer

Glossary Item Box

Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ordering As LurchTableOrder, _
   ByVal limit As Integer, _
   ByVal comparer As IEqualityComparer(Of TKey) _
)
C#
public LurchTable<TKey,TValue>(
   LurchTableOrder ordering,
   int limit,
   IEqualityComparer<TKey> comparer
)

Parameters

ordering
limit
comparer

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var cmp = new IntComparer();
const int limit = 5;

Assert.AreEqual(LurchTableOrder.None, new LurchTable<int, int>(1).Ordering);
Assert.AreEqual(LurchTableOrder.Insertion, new LurchTable<int, int>(1, LurchTableOrder.Insertion).Ordering);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(1, LurchTableOrder.Insertion, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Modified, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Limit);
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer));
VB.NET Copy Code
Dim cmp As var = New IntComparer()
Const  limit As Integer = 5

Assert.AreEqual(LurchTableOrder.None, New LurchTable(Of Integer, Integer)(1).Ordering)
Assert.AreEqual(LurchTableOrder.Insertion, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion).Ordering)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Modified, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Limit)
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32,Int32,Int32,Int32,IEqualityComparer<TKey>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > LurchTable<TKey,TValue> Constructor : LurchTable<TKey,TValue> Constructor(LurchTableOrder,Int32,Int32,Int32,Int32,IEqualityComparer<TKey>)

ordering
The type of linking for the items
limit
The maximum allowable number of items, or int.MaxValue for unlimited
hashSize
The number of hash buckets to use for the collection, usually 1/2 estimated capacity
allocSize
The number of entries to allocate at a time, usually 1/16 estimated capacity
lockSize
The number of concurrency locks to preallocate, usually 1/256 estimated capacity
comparer
The element hash generator for keys

Glossary Item Box

Creates a LurchTable that orders items by (ordering) and removes items once the specified (limit) is reached.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ordering As LurchTableOrder, _
   ByVal limit As Integer, _
   ByVal hashSize As Integer, _
   ByVal allocSize As Integer, _
   ByVal lockSize As Integer, _
   ByVal comparer As IEqualityComparer(Of TKey) _
)
C#
public LurchTable<TKey,TValue>(
   LurchTableOrder ordering,
   int limit,
   int hashSize,
   int allocSize,
   int lockSize,
   IEqualityComparer<TKey> comparer
)

Parameters

ordering
The type of linking for the items
limit
The maximum allowable number of items, or int.MaxValue for unlimited
hashSize
The number of hash buckets to use for the collection, usually 1/2 estimated capacity
allocSize
The number of entries to allocate at a time, usually 1/16 estimated capacity
lockSize
The number of concurrency locks to preallocate, usually 1/256 estimated capacity
comparer
The element hash generator for keys

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
//multiple of prime will produce hash collision, thus testing removal of non-first elements
const int prime = 1103;
var test = new LurchTable<int, string>(LurchTableOrder.Access, 10, prime, 10, 10, EqualityComparer<int>.Default);
test[1 * prime] = "a";
test[2 * prime] = "b";
test[3 * prime] = "c";
test[4 * prime] = "d";
test[5 * prime] = "e";
Assert.IsTrue(test.Remove(4 * prime));
Assert.IsTrue(test.Remove(2 * prime));
Assert.IsTrue(test.Remove(5 * prime));
Assert.IsTrue(test.Remove(1 * prime));
Assert.IsTrue(test.Remove(3 * prime));
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
'multiple of prime will produce hash collision, thus testing removal of non-first elements
Const  prime As Integer = 1103
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 10, prime, 10, 10, EqualityComparer(Of Integer).[Default])
test(1 * prime) = "a"
test(2 * prime) = "b"
test(3 * prime) = "c"
test(4 * prime) = "d"
test(5 * prime) = "e"
Assert.IsTrue(test.Remove(4 * prime))
Assert.IsTrue(test.Remove(2 * prime))
Assert.IsTrue(test.Remove(5 * prime))
Assert.IsTrue(test.Remove(1 * prime))
Assert.IsTrue(test.Remove(3 * prime))
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see LurchTable<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Add | Adds an element with the provided key and value to the IDictionary.
Public Method | AddOrUpdate | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
Public Method | Clear | Removes all items from the ICollection.
Public Method | ContainsKey | Determines whether the IDictionary contains an element with the specified key.
Public Method | Dequeue | Removes the oldest entry in the collection based on the ordering supplied to the constructor. If an item is not available a busy-wait loop is used to wait for for an item.
Public Method | Dispose | Clears references to all objects and invalidates the collection
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | GetOrAdd | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist.
Public Method | Initialize | WARNING: not thread-safe, reinitializes all internal structures. Use Clear() for a thread-safe delete all. If you have externally provided exclusive access this method may be used to more efficiently clear the collection.
Public Method | Peek | Retrieves the oldest entry in the collection based on the ordering supplied to the constructor.
Public Method | Remove | Removes the element with the specified key from the IDictionary.
Public Method | TryAdd | Overloaded. Adds an element with the provided key and value to the IDictionary.
Public Method | TryDequeue | Overloaded. Removes the oldest entry in the collection based on the ordering supplied to the constructor.
Public Method | TryGetValue | Gets the value associated with the specified key.
Public Method | TryRemove | Overloaded. Removes the element with the specified key from the IDictionary.
Public Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Top

See Also

Reference

LurchTable<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Add Method

key
value

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Public Sub Add( _
   ByVal key As TKey, _
   ByVal value As TValue _
)
C#
public void Add(
   TKey key,
   TValue value
)

Parameters

key
value

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
LurchTableTest<int, string> test = new LurchTableTest<int, string>();
for (int i = 0; i < 10; i++)
    test.Add(i, i.ToString());

for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.ContainsKey(i));

string cmp;
for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.TryGetValue(i, out cmp) && cmp == i.ToString());

for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.Remove(i));
VB.NET Copy Code
Dim test As New LurchTableTest(Of Integer, String)()
Dim i As Integer = 0
While i < 10
    test.Add(i, i.ToString())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.ContainsKey(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim cmp As String
Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.TryGetValue(i, cmp) AndAlso cmp = i.ToString())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.Remove(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : AddOrUpdate Method

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Overload List

Overload | Description
AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
AddOrUpdate<T>(TKey,T) | Add, update, or fetche a key/value pair from the dictionary via an implementation of the ICreateOrUpdateValue<TKey,TValue> interface.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > AddOrUpdate Method : AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) Method

key
addValue
fnUpdate

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddOrUpdate( _
   ByVal key As TKey, _
   ByVal addValue As TValue, _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As TValue
C#
public TValue AddOrUpdate(
   TKey key,
   TValue addValue,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
addValue
fnUpdate

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();
Assert.AreEqual("a", data.AddOrUpdate(1, "a", (k, v) => k.ToString()));
Assert.AreEqual("1", data.AddOrUpdate(1, "a", (k, v) => k.ToString()));

Assert.AreEqual("b", data.AddOrUpdate(2, k => "b", (k, v) => k.ToString()));
Assert.AreEqual("2", data.AddOrUpdate(2, k => "b", (k, v) => k.ToString()));
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()
Assert.AreEqual("a", data.AddOrUpdate(1, "a", Function(k, v) k.ToString()))
Assert.AreEqual("1", data.AddOrUpdate(1, "a", Function(k, v) k.ToString()))

Assert.AreEqual("b", data.AddOrUpdate(2, Function(k) "b", Function(k, v) k.ToString()))
Assert.AreEqual("2", data.AddOrUpdate(2, Function(k) "b", Function(k, v) k.ToString()))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > AddOrUpdate Method : AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) Method

key
fnCreate
fnUpdate

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddOrUpdate( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue), _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As TValue
C#
public TValue AddOrUpdate(
   TKey key,
   Converter<TKey,TValue> fnCreate,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
fnCreate
fnUpdate

Remarks

Adds or modifies an element with the provided key and value. If the key does not exist in the collection, the factory method fnCreate will be called to produce the new value, if the key exists, the converter method fnUpdate will be called to create an updated value.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();
Assert.AreEqual("a", data.AddOrUpdate(1, "a", (k, v) => k.ToString()));
Assert.AreEqual("1", data.AddOrUpdate(1, "a", (k, v) => k.ToString()));

Assert.AreEqual("b", data.AddOrUpdate(2, k => "b", (k, v) => k.ToString()));
Assert.AreEqual("2", data.AddOrUpdate(2, k => "b", (k, v) => k.ToString()));
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()
Assert.AreEqual("a", data.AddOrUpdate(1, "a", Function(k, v) k.ToString()))
Assert.AreEqual("1", data.AddOrUpdate(1, "a", Function(k, v) k.ToString()))

Assert.AreEqual("b", data.AddOrUpdate(2, Function(k) "b", Function(k, v) k.ToString()))
Assert.AreEqual("2", data.AddOrUpdate(2, Function(k) "b", Function(k, v) k.ToString()))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
AddOrUpdate<T>(TKey,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > AddOrUpdate Method : AddOrUpdate<T>(TKey,T) Method

key
createOrUpdateValue

Glossary Item Box

Add, update, or fetche a key/value pair from the dictionary via an implementation of the ICreateOrUpdateValue<TKey,TValue> interface.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddOrUpdate(Of T As ICreateOrUpdateValue(Of TKey,TValue))( _
   ByVal key As TKey, _
   ByRef createOrUpdateValue As T _
) As Boolean
C#
public bool AddOrUpdate<T>(
   TKey key,
   ref T createOrUpdateValue
)
where T: ICreateOrUpdateValue<TKey,TValue>

Parameters

key
createOrUpdateValue

Type Parameters

T

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Clear Method

Glossary Item Box

Removes all items from the ICollection.

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContainsKey Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : ContainsKey Method

key

Glossary Item Box

Determines whether the IDictionary contains an element with the specified key.

Syntax

Visual Basic (Declaration)
Public Function ContainsKey( _
   ByVal key As TKey _
) As Boolean
C#
public bool ContainsKey(
   TKey key
)

Parameters

key

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var test = new LurchTableTest<string, string>(StringComparer.OrdinalIgnoreCase);
test["a"] = "b";
Assert.IsTrue(test.ContainsKey("A"));

test = new LurchTableTest<string, string>(StringComparer.OrdinalIgnoreCase);
test["a"] = "b";
Assert.IsTrue(test.ContainsKey("A"));
VB.NET Copy Code
Dim test As var = New LurchTableTest(Of String, String)(StringComparer.OrdinalIgnoreCase)
test("a") = "b"
Assert.IsTrue(test.ContainsKey("A"))

test = New LurchTableTest(Of String, String)(StringComparer.OrdinalIgnoreCase)
test("a") = "b"
Assert.IsTrue(test.ContainsKey("A"))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs

Used By

Boolean LurchTable.KeyCollection.Contains(TKey)


%%PageItemTitle%%

[image]
CSharpTest.Net
Dequeue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Dequeue Method

Glossary Item Box

Removes the oldest entry in the collection based on the ordering supplied to the constructor. If an item is not available a busy-wait loop is used to wait for for an item.

Syntax

Visual Basic (Declaration)
Public Function Dequeue() As KeyValuePair(Of TKey,TValue)
C#
public KeyValuePair<TKey,TValue> Dequeue()

Return Value

The Key/Value pair removed.

Exceptions

Exception | Description
System.InvalidOperationException | Raised if the table is unordered
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var recorder = new RecordEvents<int, string>();
var test = new LurchTable<int, string>(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer<int>.Default);
test.ItemAdded += recorder.ItemAdded;
test.ItemUpdated += recorder.ItemUpdated;
test.ItemRemoved += recorder.ItemRemoved;
test[1] = "a";
Assert.AreEqual("a", recorder.LastAdded.Value);
test[2] = "b";
Assert.AreEqual("b", recorder.LastAdded.Value);
test[3] = "c";
Assert.AreEqual("c", recorder.LastAdded.Value);
Assert.AreEqual(3, test.Count);
Assert.AreEqual("b", test[2]); //access moves to front..
test[4] = "d";
Assert.AreEqual("d", recorder.LastAdded.Value);
Assert.AreEqual("a", recorder.LastRemove.Value);
test[5] = "e";
Assert.AreEqual("e", recorder.LastAdded.Value);
Assert.AreEqual("c", recorder.LastRemove.Value);
test[2] = "B";
Assert.AreEqual("B", recorder.LastUpdate.Value);
test[6] = "f";
Assert.AreEqual("f", recorder.LastAdded.Value);
Assert.AreEqual("d", recorder.LastRemove.Value);

Assert.AreEqual(3, test.Count); // still 3 items
string value;
Assert.IsTrue(test.TryRemove(5, out value));
Assert.AreEqual("e", value);
Assert.AreEqual("e", recorder.LastRemove.Value);

Assert.AreEqual("B", test.Dequeue().Value);
Assert.AreEqual("f", test.Dequeue().Value);
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim recorder As var = New RecordEvents(Of Integer, String)()
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer(Of Integer).[Default])
test.ItemAdded += recorder.ItemAdded
test.ItemUpdated += recorder.ItemUpdated
test.ItemRemoved += recorder.ItemRemoved
test(1) = "a"
Assert.AreEqual("a", recorder.LastAdded.Value)
test(2) = "b"
Assert.AreEqual("b", recorder.LastAdded.Value)
test(3) = "c"
Assert.AreEqual("c", recorder.LastAdded.Value)
Assert.AreEqual(3, test.Count)
Assert.AreEqual("b", test(2))
'access moves to front..
test(4) = "d"
Assert.AreEqual("d", recorder.LastAdded.Value)
Assert.AreEqual("a", recorder.LastRemove.Value)
test(5) = "e"
Assert.AreEqual("e", recorder.LastAdded.Value)
Assert.AreEqual("c", recorder.LastRemove.Value)
test(2) = "B"
Assert.AreEqual("B", recorder.LastUpdate.Value)
test(6) = "f"
Assert.AreEqual("f", recorder.LastAdded.Value)
Assert.AreEqual("d", recorder.LastRemove.Value)

Assert.AreEqual(3, test.Count)
' still 3 items
Dim value As String
Assert.IsTrue(test.TryRemove(5, value))
Assert.AreEqual("e", value)
Assert.AreEqual("e", recorder.LastRemove.Value)

Assert.AreEqual("B", test.Dequeue().Value)
Assert.AreEqual("f", test.Dequeue().Value)
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Dispose Method

Glossary Item Box

Clears references to all objects and invalidates the collection

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As LurchTable(Of TKey,TValue)
C#
public LurchTable<TKey,TValue> GetEnumerator()

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
LurchTable.Enumerator

Used By

LurchTable.Clear()
LurchTable.KeyCollection.CopyTo(TKey[],Int32)
Boolean LurchTable.ValueCollection.Contains(TValue)
LurchTable.ValueCollection.CopyTo(TValue[],Int32)

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : GetOrAdd Method

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Overload List

Overload | Description
GetOrAdd(TKey,TValue) | Adds a key/value pair to the IDictionary if the key does not already exist.
GetOrAdd(TKey,Converter<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > GetOrAdd Method : GetOrAdd(TKey,TValue) Method

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As TValue
C#
public TValue GetOrAdd(
   TKey key,
   TValue value
)

Parameters

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();
Assert.AreEqual("a", data.GetOrAdd(1, "a"));
Assert.AreEqual("a", data.GetOrAdd(1, "b"));

Assert.AreEqual("b", data.GetOrAdd(2, k => "b"));
Assert.AreEqual("b", data.GetOrAdd(2, k => "c"));
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()
Assert.AreEqual("a", data.GetOrAdd(1, "a"))
Assert.AreEqual("a", data.GetOrAdd(1, "b"))

Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "b"))
Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "c"))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd(TKey,Converter<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > GetOrAdd Method : GetOrAdd(TKey,Converter<TKey,TValue>) Method

key
The key of the element to add.
fnCreate
Constructs a new value for the key.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue) _
) As TValue
C#
public TValue GetOrAdd(
   TKey key,
   Converter<TKey,TValue> fnCreate
)

Parameters

key
The key of the element to add.
fnCreate
Constructs a new value for the key.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();
Assert.AreEqual("a", data.GetOrAdd(1, "a"));
Assert.AreEqual("a", data.GetOrAdd(1, "b"));

Assert.AreEqual("b", data.GetOrAdd(2, k => "b"));
Assert.AreEqual("b", data.GetOrAdd(2, k => "c"));
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()
Assert.AreEqual("a", data.GetOrAdd(1, "a"))
Assert.AreEqual("a", data.GetOrAdd(1, "b"))

Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "b"))
Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "c"))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Initialize Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Initialize Method

Glossary Item Box

WARNING: not thread-safe, reinitializes all internal structures. Use Clear() for a thread-safe delete all. If you have externally provided exclusive access this method may be used to more efficiently clear the collection.

Syntax

Visual Basic (Declaration)
Public Sub Initialize()
C#
public void Initialize()

Exceptions

Exception | Description
LurchTableCorruptionException | Exception class: LurchTableCorruptionException The LurchTable internal datastructure appears to be corrupted.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
LurchTableTest<string, string> test = new LurchTableTest<string, string>(StringComparer.Ordinal);
test["a"] = "b";
Assert.AreEqual(1, test.Count);
test.Initialize();
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim test As New LurchTableTest(Of String, String)(StringComparer.Ordinal)
test("a") = "b"
Assert.AreEqual(1, test.Count)
test.Initialize()
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Peek Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Peek Method

value

Glossary Item Box

Retrieves the oldest entry in the collection based on the ordering supplied to the constructor.

Syntax

Visual Basic (Declaration)
Public Function Peek( _
   ByRef value As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool Peek(
   out KeyValuePair<TKey,TValue> value
)

Parameters

value

Return Value

True if the out parameter value was set.

Exceptions

Exception | Description
System.InvalidOperationException | Raised if the table is unordered
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var test = new LurchTableTest<int, string>(LurchTableOrder.Access);
Assert.AreEqual(LurchTableOrder.Access, test.Ordering);
var sample = GetSample();
foreach (var item in sample)
    test.Add(item.Key, item.Value);

Array.Reverse(sample);
foreach (var item in sample)
    Assert.AreEqual(item.Value, test[item.Key]);

KeyValuePair<int, string> value;
foreach (var item in sample)
{
    Assert.IsTrue(test.TryDequeue(out value));
    Assert.AreEqual(item.Key, value.Key);
    Assert.AreEqual(item.Value, value.Value);
}

Assert.IsFalse(test.Peek(out value));
Assert.IsFalse(test.TryDequeue(out value));
VB.NET Copy Code
Dim test As var = New LurchTableTest(Of Integer, String)(LurchTableOrder.Access)
Assert.AreEqual(LurchTableOrder.Access, test.Ordering)
Dim sample As var = GetSample()
For Each item As var In sample
    test.Add(item.Key, item.Value)
Next

Array.Reverse(sample)
For Each item As var In sample
    Assert.AreEqual(item.Value, test(item.Key))
Next

Dim value As KeyValuePair(Of Integer, String)
For Each item As var In sample
    Assert.IsTrue(test.TryDequeue(value))
    Assert.AreEqual(item.Key, value.Key)
    Assert.AreEqual(item.Value, value.Value)
Next

Assert.IsFalse(test.Peek(value))
Assert.IsFalse(test.TryDequeue(value))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Remove Method

key
The key of the element to remove.

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal key As TKey _
) As Boolean
C#
public bool Remove(
   TKey key
)

Parameters

key
The key of the element to remove.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
LurchTableTest<int, string> test = new LurchTableTest<int, string>();
for (int i = 0; i < 10; i++)
    test.Add(i, i.ToString());

for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.ContainsKey(i));

string cmp;
for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.TryGetValue(i, out cmp) && cmp == i.ToString());

for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.Remove(i));
VB.NET Copy Code
Dim test As New LurchTableTest(Of Integer, String)()
Dim i As Integer = 0
While i < 10
    test.Add(i, i.ToString())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.ContainsKey(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim cmp As String
Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.TryGetValue(i, cmp) AndAlso cmp = i.ToString())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.Remove(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Used By

LurchTable.Clear()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : TryAdd Method

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Overload List

Overload | Description
TryAdd(TKey,TValue) | Adds an element with the provided key and value to the IDictionary.
TryAdd(TKey,Converter<TKey,TValue>) | Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryAdd Method : TryAdd(TKey,TValue) Method

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
public bool TryAdd(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd(TKey,Converter<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryAdd Method : TryAdd(TKey,Converter<TKey,TValue>) Method

key
fnCreate

Glossary Item Box

Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryAdd( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue) _
) As Boolean
C#
public bool TryAdd(
   TKey key,
   Converter<TKey,TValue> fnCreate
)

Parameters

key
fnCreate

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryDequeue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : TryDequeue Method

Glossary Item Box

Removes the oldest entry in the collection based on the ordering supplied to the constructor.

Overload List

Overload | Description
TryDequeue(KeyValuePair<TKey,TValue>) | Removes the oldest entry in the collection based on the ordering supplied to the constructor.
TryDequeue(Predicate<KeyValuePair<TKey,TValue>>,KeyValuePair<TKey,TValue>) | Removes the oldest entry in the collection based on the ordering supplied to the constructor.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryDequeue(KeyValuePair<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryDequeue Method : TryDequeue(KeyValuePair<TKey,TValue>) Method

value

Glossary Item Box

Removes the oldest entry in the collection based on the ordering supplied to the constructor.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryDequeue( _
   ByRef value As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool TryDequeue(
   out KeyValuePair<TKey,TValue> value
)

Parameters

value

Return Value

False if no item was available

Exceptions

Exception | Description
System.InvalidOperationException | Raised if the table is unordered

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var test = new LurchTableTest<int, string>(LurchTableOrder.Access);
Assert.AreEqual(LurchTableOrder.Access, test.Ordering);
var sample = GetSample();
foreach (var item in sample)
    test.Add(item.Key, item.Value);

Array.Reverse(sample);
foreach (var item in sample)
    Assert.AreEqual(item.Value, test[item.Key]);

KeyValuePair<int, string> value;
foreach (var item in sample)
{
    Assert.IsTrue(test.TryDequeue(out value));
    Assert.AreEqual(item.Key, value.Key);
    Assert.AreEqual(item.Value, value.Value);
}

Assert.IsFalse(test.Peek(out value));
Assert.IsFalse(test.TryDequeue(out value));
VB.NET Copy Code
Dim test As var = New LurchTableTest(Of Integer, String)(LurchTableOrder.Access)
Assert.AreEqual(LurchTableOrder.Access, test.Ordering)
Dim sample As var = GetSample()
For Each item As var In sample
    test.Add(item.Key, item.Value)
Next

Array.Reverse(sample)
For Each item As var In sample
    Assert.AreEqual(item.Value, test(item.Key))
Next

Dim value As KeyValuePair(Of Integer, String)
For Each item As var In sample
    Assert.IsTrue(test.TryDequeue(value))
    Assert.AreEqual(item.Key, value.Key)
    Assert.AreEqual(item.Value, value.Value)
Next

Assert.IsFalse(test.Peek(value))
Assert.IsFalse(test.TryDequeue(value))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Used By

KeyValuePair LurchTable.Dequeue()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryDequeue(Predicate<KeyValuePair<TKey,TValue>>,KeyValuePair<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryDequeue Method : TryDequeue(Predicate<KeyValuePair<TKey,TValue>>,KeyValuePair<TKey,TValue>) Method

predicate
value

Glossary Item Box

Removes the oldest entry in the collection based on the ordering supplied to the constructor.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryDequeue( _
   ByVal predicate As Predicate(Of KeyValuePair(Of TKey,TValue)), _
   ByRef value As KeyValuePair(Of TKey,TValue) _
) As Boolean
C#
public bool TryDequeue(
   Predicate<KeyValuePair<TKey,TValue>> predicate,
   out KeyValuePair<TKey,TValue> value
)

Parameters

predicate
value

Return Value

False if no item was available

Exceptions

Exception | Description
System.InvalidOperationException | Raised if the table is unordered
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.
LurchTableCorruptionException | Exception class: LurchTableCorruptionException The LurchTable internal datastructure appears to be corrupted.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Used By

Boolean LurchTable.TryDequeue(KeyValuePair)

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : TryGetValue Method

key
value

Glossary Item Box

Gets the value associated with the specified key.

Syntax

Visual Basic (Declaration)
Public Function TryGetValue( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
public bool TryGetValue(
   TKey key,
   out TValue value
)

Parameters

key
value

Return Value

true if the object that implements IDictionary contains an element with the specified key; otherwise, false.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
LurchTableTest<int, string> test = new LurchTableTest<int, string>();
for (int i = 0; i < 10; i++)
    test.Add(i, i.ToString());

for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.ContainsKey(i));

string cmp;
for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.TryGetValue(i, out cmp) && cmp == i.ToString());

for (int i = 0; i < 10; i++)
    Assert.IsTrue(test.Remove(i));
VB.NET Copy Code
Dim test As New LurchTableTest(Of Integer, String)()
Dim i As Integer = 0
While i < 10
    test.Add(i, i.ToString())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.ContainsKey(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim cmp As String
Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.TryGetValue(i, cmp) AndAlso cmp = i.ToString())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Dim i As Integer = 0
While i < 10
    Assert.IsTrue(test.Remove(i))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Used By

Boolean LurchTable.ContainsKey(TKey)

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : TryRemove Method

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Overload List

Overload | Description
TryRemove(TKey,TValue) | Removes the element with the specified key from the IDictionary.
TryRemove(TKey,KeyValuePredicate<TKey,TValue>) | Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.
TryRemove<T>(TKey,T) | Conditionally removes a key/value pair from the dictionary via an implementation of the IRemoveValue<TKey,TValue> interface.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryRemove Method : TryRemove(TKey,TValue) Method

key
The key of the element to remove.
value
The value that was removed.

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
public bool TryRemove(
   TKey key,
   out TValue value
)

Parameters

key
The key of the element to remove.
value
The value that was removed.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove(TKey,KeyValuePredicate<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryRemove Method : TryRemove(TKey,KeyValuePredicate<TKey,TValue>) Method

key
fnCondition

Glossary Item Box

Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove( _
   ByVal key As TKey, _
   ByVal fnCondition As CSharpTest.Net.Collections.KeyValuePredicate(Of TKey,TValue) _
) As Boolean
C#
public bool TryRemove(
   TKey key,
   CSharpTest.Net.Collections.KeyValuePredicate<TKey,TValue> fnCondition
)

Parameters

key
fnCondition

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List
KeyValuePredicate

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
TryRemove<T>(TKey,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryRemove Method : TryRemove<T>(TKey,T) Method

key
removeValue

Glossary Item Box

Conditionally removes a key/value pair from the dictionary via an implementation of the IRemoveValue<TKey,TValue> interface.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove(Of T As IRemoveValue(Of TKey,TValue))( _
   ByVal key As TKey, _
   ByRef removeValue As T _
) As Boolean
C#
public bool TryRemove<T>(
   TKey key,
   ref T removeValue
)
where T: IRemoveValue<TKey,TValue>

Parameters

key
removeValue

Type Parameters

T

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : TryUpdate Method

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Overload List

Overload | Description
TryUpdate(TKey,TValue) | Updates an element with the provided key to the value if it exists.
TryUpdate(TKey,TValue,TValue) | Updates an element with the provided key to the value if it exists.
TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) | Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the syncronization lock.

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Return Value

Returns true if the key provided was found and updated to the value.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,TValue,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue, _
   ByVal comparisonValue As TValue _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   TValue value,
   TValue comparisonValue
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Return Value

Returns true if the key provided was found and updated to the value.

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) Method

key
fnUpdate

Glossary Item Box

Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the syncronization lock.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
fnUpdate

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var data = new LurchTableTest<int, string>();

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As var = New LurchTableTest(Of Integer, String)()

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see LurchTable<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Comparer | Retrives the key comparer being used by this instance.
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | Item | Gets or sets the element with the specified key.
Public Property | Keys | Gets an ICollection containing the keys of the IDictionary.
Public Property | Limit | Retrives the record limit allowed in this instance.
Public Property | Ordering | Retrieves the LurchTableOrder Ordering enumeration this instance was created with.
Public Property | Values | Gets an ICollection containing the values in the IDictionary.
Top

See Also

Reference

LurchTable<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Comparer Property

Glossary Item Box

Retrives the key comparer being used by this instance.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Comparer As IEqualityComparer(Of TKey)
C#
public IEqualityComparer<TKey> Comparer {get;}

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var cmp = new IntComparer();
const int limit = 5;

Assert.AreEqual(LurchTableOrder.None, new LurchTable<int, int>(1).Ordering);
Assert.AreEqual(LurchTableOrder.Insertion, new LurchTable<int, int>(1, LurchTableOrder.Insertion).Ordering);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(1, LurchTableOrder.Insertion, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Modified, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Limit);
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer));
VB.NET Copy Code
Dim cmp As var = New IntComparer()
Const  limit As Integer = 5

Assert.AreEqual(LurchTableOrder.None, New LurchTable(Of Integer, Integer)(1).Ordering)
Assert.AreEqual(LurchTableOrder.Insertion, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion).Ordering)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Modified, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Limit)
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Count Property

Glossary Item Box

Gets the number of elements contained in the ICollection.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
LurchTableTest<string, string> test = new LurchTableTest<string, string>(StringComparer.Ordinal);
test["a"] = "b";
Assert.AreEqual(1, test.Count);
test.Initialize();
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim test As New LurchTableTest(Of String, String)(StringComparer.Ordinal)
test("a") = "b"
Assert.AreEqual(1, test.Count)
test.Initialize()
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Item Property

key

Glossary Item Box

Gets or sets the element with the specified key.

Syntax

Visual Basic (Declaration)
Public Default Property Item( _
   ByVal key As TKey _
) As TValue
C#
public TValue this[
   TKey key
]; {get; set;}

Parameters

key

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
LurchTableTest<string, string> test = new LurchTableTest<string, string>(StringComparer.Ordinal);
test["a"] = "b";
Assert.AreEqual(1, test.Count);
test.Initialize();
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim test As New LurchTableTest(Of String, String)(StringComparer.Ordinal)
test("a") = "b"
Assert.AreEqual(1, test.Count)
test.Initialize()
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Keys Property

Glossary Item Box

Gets an ICollection containing the keys of the IDictionary.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As LurchTable(Of TKey,TValue)
C#
public LurchTable<TKey,TValue> Keys {get;}

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var items = CreateSample(sample);
IDictionary<int, string> dict = items;
var keys = new List<int>();
foreach (var kv in sample)
    keys.Add(kv.Key);
VerifyCollection(EqualityComparer<int>.Default, keys.AsReadOnly(), items.Keys);
VerifyCollection(EqualityComparer<int>.Default, keys.AsReadOnly(), dict.Keys);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim items As var = CreateSample(sample)
Dim dict As IDictionary(Of Integer, String) = items
Dim keys As var = New List(Of Integer)()
For Each kv As var In sample
    keys.Add(kv.Key)
Next
VerifyCollection(EqualityComparer(Of Integer).[Default], keys.AsReadOnly(), items.Keys)
VerifyCollection(EqualityComparer(Of Integer).[Default], keys.AsReadOnly(), dict.Keys)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
LurchTable.KeyCollection

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Limit Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Limit Property

Glossary Item Box

Retrives the record limit allowed in this instance.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Limit As Integer
C#
public int Limit {get;}

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var cmp = new IntComparer();
const int limit = 5;

Assert.AreEqual(LurchTableOrder.None, new LurchTable<int, int>(1).Ordering);
Assert.AreEqual(LurchTableOrder.Insertion, new LurchTable<int, int>(1, LurchTableOrder.Insertion).Ordering);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(1, LurchTableOrder.Insertion, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Modified, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Modified, limit).Limit);
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, cmp).Comparer));
Assert.AreEqual(LurchTableOrder.Access, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering);
Assert.AreEqual(limit, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit);
Assert.IsTrue(ReferenceEquals(cmp, new LurchTable<int, int>(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer));
VB.NET Copy Code
Dim cmp As var = New IntComparer()
Const  limit As Integer = 5

Assert.AreEqual(LurchTableOrder.None, New LurchTable(Of Integer, Integer)(1).Ordering)
Assert.AreEqual(LurchTableOrder.Insertion, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion).Ordering)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(1, LurchTableOrder.Insertion, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Modified, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Modified, limit).Limit)
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, cmp).Comparer))
Assert.AreEqual(LurchTableOrder.Access, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Ordering)
Assert.AreEqual(limit, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Limit)
Assert.IsTrue(ReferenceEquals(cmp, New LurchTable(Of Integer, Integer)(LurchTableOrder.Access, limit, 1, 1, 1, cmp).Comparer))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Ordering Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Ordering Property

Glossary Item Box

Retrieves the LurchTableOrder Ordering enumeration this instance was created with.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Ordering As LurchTableOrder
C#
public LurchTableOrder Ordering {get;}

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var test = new LurchTableTest<int, string>(LurchTableOrder.Access);
Assert.AreEqual(LurchTableOrder.Access, test.Ordering);
var sample = GetSample();
foreach (var item in sample)
    test.Add(item.Key, item.Value);

Array.Reverse(sample);
foreach (var item in sample)
    Assert.AreEqual(item.Value, test[item.Key]);

KeyValuePair<int, string> value;
foreach (var item in sample)
{
    Assert.IsTrue(test.TryDequeue(out value));
    Assert.AreEqual(item.Key, value.Key);
    Assert.AreEqual(item.Value, value.Value);
}

Assert.IsFalse(test.Peek(out value));
Assert.IsFalse(test.TryDequeue(out value));
VB.NET Copy Code
Dim test As var = New LurchTableTest(Of Integer, String)(LurchTableOrder.Access)
Assert.AreEqual(LurchTableOrder.Access, test.Ordering)
Dim sample As var = GetSample()
For Each item As var In sample
    test.Add(item.Key, item.Value)
Next

Array.Reverse(sample)
For Each item As var In sample
    Assert.AreEqual(item.Value, test(item.Key))
Next

Dim value As KeyValuePair(Of Integer, String)
For Each item As var In sample
    Assert.IsTrue(test.TryDequeue(value))
    Assert.AreEqual(item.Key, value.Key)
    Assert.AreEqual(item.Value, value.Value)
Next

Assert.IsFalse(test.Peek(value))
Assert.IsFalse(test.TryDequeue(value))

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
LurchTableOrder

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Values Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Values Property

Glossary Item Box

Gets an ICollection containing the values in the IDictionary.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Values As LurchTable(Of TKey,TValue)
C#
public LurchTable<TKey,TValue> Values {get;}

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var items = CreateSample(sample);
IDictionary<int, string> dict = items;
var values = new List<string>();
foreach (var kv in sample)
    values.Add(kv.Value);
VerifyCollection(EqualityComparer<string>.Default, values.AsReadOnly(), items.Values);
VerifyCollection(EqualityComparer<string>.Default, values.AsReadOnly(), dict.Values);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim items As var = CreateSample(sample)
Dim dict As IDictionary(Of Integer, String) = items
Dim values As var = New List(Of String)()
For Each kv As var In sample
    values.Add(kv.Value)
Next
VerifyCollection(EqualityComparer(Of String).[Default], values.AsReadOnly(), items.Values)
VerifyCollection(EqualityComparer(Of String).[Default], values.AsReadOnly(), dict.Values)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members
LurchTable.ValueCollection

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
LurchTable<TKey,TValue> Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see LurchTable<TKey,TValue> members.

Public Events

 | Name | Description
Public Event | ItemAdded | Event raised after an item is added to the collection
Public Event | ItemRemoved | Event raised after an item is removed from the collection
Public Event | ItemUpdated | Event raised after an item is updated in the collection
Top

See Also

Reference

LurchTable<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ItemAdded Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : ItemAdded Event

Glossary Item Box

Event raised after an item is added to the collection

Syntax

Visual Basic (Declaration)
Public Event ItemAdded As Action(Of KeyValuePair(Of TKey,TValue))
C#
public event Action<KeyValuePair<TKey,TValue>> ItemAdded

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var recorder = new RecordEvents<int, string>();
var test = new LurchTable<int, string>(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer<int>.Default);
test.ItemAdded += recorder.ItemAdded;
test.ItemUpdated += recorder.ItemUpdated;
test.ItemRemoved += recorder.ItemRemoved;
test[1] = "a";
Assert.AreEqual("a", recorder.LastAdded.Value);
test[2] = "b";
Assert.AreEqual("b", recorder.LastAdded.Value);
test[3] = "c";
Assert.AreEqual("c", recorder.LastAdded.Value);
Assert.AreEqual(3, test.Count);
Assert.AreEqual("b", test[2]); //access moves to front..
test[4] = "d";
Assert.AreEqual("d", recorder.LastAdded.Value);
Assert.AreEqual("a", recorder.LastRemove.Value);
test[5] = "e";
Assert.AreEqual("e", recorder.LastAdded.Value);
Assert.AreEqual("c", recorder.LastRemove.Value);
test[2] = "B";
Assert.AreEqual("B", recorder.LastUpdate.Value);
test[6] = "f";
Assert.AreEqual("f", recorder.LastAdded.Value);
Assert.AreEqual("d", recorder.LastRemove.Value);

Assert.AreEqual(3, test.Count); // still 3 items
string value;
Assert.IsTrue(test.TryRemove(5, out value));
Assert.AreEqual("e", value);
Assert.AreEqual("e", recorder.LastRemove.Value);

Assert.AreEqual("B", test.Dequeue().Value);
Assert.AreEqual("f", test.Dequeue().Value);
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim recorder As var = New RecordEvents(Of Integer, String)()
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer(Of Integer).[Default])
test.ItemAdded += recorder.ItemAdded
test.ItemUpdated += recorder.ItemUpdated
test.ItemRemoved += recorder.ItemRemoved
test(1) = "a"
Assert.AreEqual("a", recorder.LastAdded.Value)
test(2) = "b"
Assert.AreEqual("b", recorder.LastAdded.Value)
test(3) = "c"
Assert.AreEqual("c", recorder.LastAdded.Value)
Assert.AreEqual(3, test.Count)
Assert.AreEqual("b", test(2))
'access moves to front..
test(4) = "d"
Assert.AreEqual("d", recorder.LastAdded.Value)
Assert.AreEqual("a", recorder.LastRemove.Value)
test(5) = "e"
Assert.AreEqual("e", recorder.LastAdded.Value)
Assert.AreEqual("c", recorder.LastRemove.Value)
test(2) = "B"
Assert.AreEqual("B", recorder.LastUpdate.Value)
test(6) = "f"
Assert.AreEqual("f", recorder.LastAdded.Value)
Assert.AreEqual("d", recorder.LastRemove.Value)

Assert.AreEqual(3, test.Count)
' still 3 items
Dim value As String
Assert.IsTrue(test.TryRemove(5, value))
Assert.AreEqual("e", value)
Assert.AreEqual("e", recorder.LastRemove.Value)

Assert.AreEqual("B", test.Dequeue().Value)
Assert.AreEqual("f", test.Dequeue().Value)
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ItemRemoved Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : ItemRemoved Event

Glossary Item Box

Event raised after an item is removed from the collection

Syntax

Visual Basic (Declaration)
Public Event ItemRemoved As Action(Of KeyValuePair(Of TKey,TValue))
C#
public event Action<KeyValuePair<TKey,TValue>> ItemRemoved

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var recorder = new RecordEvents<int, string>();
var test = new LurchTable<int, string>(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer<int>.Default);
test.ItemAdded += recorder.ItemAdded;
test.ItemUpdated += recorder.ItemUpdated;
test.ItemRemoved += recorder.ItemRemoved;
test[1] = "a";
Assert.AreEqual("a", recorder.LastAdded.Value);
test[2] = "b";
Assert.AreEqual("b", recorder.LastAdded.Value);
test[3] = "c";
Assert.AreEqual("c", recorder.LastAdded.Value);
Assert.AreEqual(3, test.Count);
Assert.AreEqual("b", test[2]); //access moves to front..
test[4] = "d";
Assert.AreEqual("d", recorder.LastAdded.Value);
Assert.AreEqual("a", recorder.LastRemove.Value);
test[5] = "e";
Assert.AreEqual("e", recorder.LastAdded.Value);
Assert.AreEqual("c", recorder.LastRemove.Value);
test[2] = "B";
Assert.AreEqual("B", recorder.LastUpdate.Value);
test[6] = "f";
Assert.AreEqual("f", recorder.LastAdded.Value);
Assert.AreEqual("d", recorder.LastRemove.Value);

Assert.AreEqual(3, test.Count); // still 3 items
string value;
Assert.IsTrue(test.TryRemove(5, out value));
Assert.AreEqual("e", value);
Assert.AreEqual("e", recorder.LastRemove.Value);

Assert.AreEqual("B", test.Dequeue().Value);
Assert.AreEqual("f", test.Dequeue().Value);
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim recorder As var = New RecordEvents(Of Integer, String)()
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer(Of Integer).[Default])
test.ItemAdded += recorder.ItemAdded
test.ItemUpdated += recorder.ItemUpdated
test.ItemRemoved += recorder.ItemRemoved
test(1) = "a"
Assert.AreEqual("a", recorder.LastAdded.Value)
test(2) = "b"
Assert.AreEqual("b", recorder.LastAdded.Value)
test(3) = "c"
Assert.AreEqual("c", recorder.LastAdded.Value)
Assert.AreEqual(3, test.Count)
Assert.AreEqual("b", test(2))
'access moves to front..
test(4) = "d"
Assert.AreEqual("d", recorder.LastAdded.Value)
Assert.AreEqual("a", recorder.LastRemove.Value)
test(5) = "e"
Assert.AreEqual("e", recorder.LastAdded.Value)
Assert.AreEqual("c", recorder.LastRemove.Value)
test(2) = "B"
Assert.AreEqual("B", recorder.LastUpdate.Value)
test(6) = "f"
Assert.AreEqual("f", recorder.LastAdded.Value)
Assert.AreEqual("d", recorder.LastRemove.Value)

Assert.AreEqual(3, test.Count)
' still 3 items
Dim value As String
Assert.IsTrue(test.TryRemove(5, value))
Assert.AreEqual("e", value)
Assert.AreEqual("e", recorder.LastRemove.Value)

Assert.AreEqual("B", test.Dequeue().Value)
Assert.AreEqual("f", test.Dequeue().Value)
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ItemUpdated Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : ItemUpdated Event

Glossary Item Box

Event raised after an item is updated in the collection

Syntax

Visual Basic (Declaration)
Public Event ItemUpdated As LurchTable(Of TKey,TValue)
C#
public event LurchTable<TKey,TValue> ItemUpdated

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var recorder = new RecordEvents<int, string>();
var test = new LurchTable<int, string>(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer<int>.Default);
test.ItemAdded += recorder.ItemAdded;
test.ItemUpdated += recorder.ItemUpdated;
test.ItemRemoved += recorder.ItemRemoved;
test[1] = "a";
Assert.AreEqual("a", recorder.LastAdded.Value);
test[2] = "b";
Assert.AreEqual("b", recorder.LastAdded.Value);
test[3] = "c";
Assert.AreEqual("c", recorder.LastAdded.Value);
Assert.AreEqual(3, test.Count);
Assert.AreEqual("b", test[2]); //access moves to front..
test[4] = "d";
Assert.AreEqual("d", recorder.LastAdded.Value);
Assert.AreEqual("a", recorder.LastRemove.Value);
test[5] = "e";
Assert.AreEqual("e", recorder.LastAdded.Value);
Assert.AreEqual("c", recorder.LastRemove.Value);
test[2] = "B";
Assert.AreEqual("B", recorder.LastUpdate.Value);
test[6] = "f";
Assert.AreEqual("f", recorder.LastAdded.Value);
Assert.AreEqual("d", recorder.LastRemove.Value);

Assert.AreEqual(3, test.Count); // still 3 items
string value;
Assert.IsTrue(test.TryRemove(5, out value));
Assert.AreEqual("e", value);
Assert.AreEqual("e", recorder.LastRemove.Value);

Assert.AreEqual("B", test.Dequeue().Value);
Assert.AreEqual("f", test.Dequeue().Value);
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim recorder As var = New RecordEvents(Of Integer, String)()
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer(Of Integer).[Default])
test.ItemAdded += recorder.ItemAdded
test.ItemUpdated += recorder.ItemUpdated
test.ItemRemoved += recorder.ItemRemoved
test(1) = "a"
Assert.AreEqual("a", recorder.LastAdded.Value)
test(2) = "b"
Assert.AreEqual("b", recorder.LastAdded.Value)
test(3) = "c"
Assert.AreEqual("c", recorder.LastAdded.Value)
Assert.AreEqual(3, test.Count)
Assert.AreEqual("b", test(2))
'access moves to front..
test(4) = "d"
Assert.AreEqual("d", recorder.LastAdded.Value)
Assert.AreEqual("a", recorder.LastRemove.Value)
test(5) = "e"
Assert.AreEqual("e", recorder.LastAdded.Value)
Assert.AreEqual("c", recorder.LastRemove.Value)
test(2) = "B"
Assert.AreEqual("B", recorder.LastUpdate.Value)
test(6) = "f"
Assert.AreEqual("f", recorder.LastAdded.Value)
Assert.AreEqual("d", recorder.LastRemove.Value)

Assert.AreEqual(3, test.Count)
' still 3 items
Dim value As String
Assert.IsTrue(test.TryRemove(5, value))
Assert.AreEqual("e", value)
Assert.AreEqual("e", recorder.LastRemove.Value)

Assert.AreEqual("B", test.Dequeue().Value)
Assert.AreEqual("f", test.Dequeue().Value)
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable<TKey,TValue> Class
LurchTable<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
LurchTable.KeyCollection<TKey,TValue> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.KeyCollection<TKey,TValue> Class

Glossary Item Box

Provides the collection of Keys for the LurchTable

Syntax

Visual Basic (Declaration)
Public Class LurchTable.KeyCollection
    (Of TKey,TValue)
C#
public class LurchTable.KeyCollection<TKey,TValue>

Type Parameters

TKey
TValue

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.LurchTable`2.KeyCollection<TKey,TValue>

Requirements

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

See Also

Reference

LurchTable.KeyCollection<TKey,TValue> Members
CSharpTest.Net.Collections Namespace
LurchTable.KeyCollection LurchTable.Keys

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LurchTable.KeyCollection<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.KeyCollection<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by LurchTable.KeyCollection<TKey,TValue>.

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements contained in the ICollection.
Top

Public Methods

 | Name | Description
Public Method | Contains | Determines whether the ICollection contains a specific value.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Top

See Also

Reference

LurchTable.KeyCollection<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
LurchTable.KeyCollection LurchTable.Keys

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LurchTable.KeyCollection<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.KeyCollection<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see LurchTable.KeyCollection<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Contains | Determines whether the ICollection contains a specific value.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Top

See Also

Reference

LurchTable.KeyCollection<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
LurchTable.KeyCollection LurchTable.Keys

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.KeyCollection<TKey,TValue> Class : Contains Method

item

Glossary Item Box

Determines whether the ICollection contains a specific value.

Syntax

Visual Basic (Declaration)
Public Function Contains( _
   ByVal item As TKey _
) As Boolean
C#
public bool Contains(
   TKey item
)

Parameters

item

Requirements

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

See Also

Reference

LurchTable.KeyCollection<TKey,TValue> Class
LurchTable.KeyCollection<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.KeyCollection<TKey,TValue> Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As TKey, _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   TKey[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Requirements

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

See Also

Reference

LurchTable.KeyCollection<TKey,TValue> Class
LurchTable.KeyCollection<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.KeyCollection<TKey,TValue> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As LurchTable(Of TKey,TValue)
C#
public LurchTable<TKey,TValue> GetEnumerator()

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var test = CreateSample(sample);
int ix = 0;
foreach (var key in test.Keys)
    Assert.AreEqual(sample[ix++].Value, test[key]);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim test As var = CreateSample(sample)
Dim ix As Integer = 0
For Each key As var In test.Keys
    Assert.AreEqual(sample(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)).Value, test(key))
Next

Requirements

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

See Also

Reference

LurchTable.KeyCollection<TKey,TValue> Class
LurchTable.KeyCollection<TKey,TValue> Members
LurchTable.KeyCollection.Enumerator

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LurchTable.KeyCollection<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.KeyCollection<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see LurchTable.KeyCollection<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements contained in the ICollection.
Top

See Also

Reference

LurchTable.KeyCollection<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
LurchTable.KeyCollection LurchTable.Keys

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.KeyCollection<TKey,TValue> Class : Count Property

Glossary Item Box

Gets the number of elements contained in the ICollection.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Requirements

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

See Also

Reference

LurchTable.KeyCollection<TKey,TValue> Class
LurchTable.KeyCollection<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
LurchTable.ValueCollection<TKey,TValue> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ValueCollection<TKey,TValue> Class

Glossary Item Box

Provides the collection of Values for the LurchTable

Syntax

Visual Basic (Declaration)
Public Class LurchTable.ValueCollection
    (Of TKey,TValue)
C#
public class LurchTable.ValueCollection<TKey,TValue>

Type Parameters

TKey
TValue

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.LurchTable`2.ValueCollection<TKey,TValue>

Requirements

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

See Also

Reference

LurchTable.ValueCollection<TKey,TValue> Members
CSharpTest.Net.Collections Namespace
LurchTable.ValueCollection LurchTable.Values

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LurchTable.ValueCollection<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ValueCollection<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by LurchTable.ValueCollection<TKey,TValue>.

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements contained in the ICollection.
Top

Public Methods

 | Name | Description
Public Method | Contains | Determines whether the ICollection contains a specific value.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Top

See Also

Reference

LurchTable.ValueCollection<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
LurchTable.ValueCollection LurchTable.Values

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LurchTable.ValueCollection<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ValueCollection<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see LurchTable.ValueCollection<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Contains | Determines whether the ICollection contains a specific value.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Top

See Also

Reference

LurchTable.ValueCollection<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
LurchTable.ValueCollection LurchTable.Values

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.ValueCollection<TKey,TValue> Class : Contains Method

value

Glossary Item Box

Determines whether the ICollection contains a specific value.

Syntax

Visual Basic (Declaration)
Public Function Contains( _
   ByVal value As TValue _
) As Boolean
C#
public bool Contains(
   TValue value
)

Parameters

value

Requirements

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

See Also

Reference

LurchTable.ValueCollection<TKey,TValue> Class
LurchTable.ValueCollection<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.ValueCollection<TKey,TValue> Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As TValue, _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   TValue[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Requirements

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

See Also

Reference

LurchTable.ValueCollection<TKey,TValue> Class
LurchTable.ValueCollection<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.ValueCollection<TKey,TValue> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As LurchTable(Of TKey,TValue)
C#
public LurchTable<TKey,TValue> GetEnumerator()

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var test = CreateSample(sample);
int ix = 0;
foreach (var value in test.Values)
    Assert.AreEqual(sample[ix++].Value, value);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim test As var = CreateSample(sample)
Dim ix As Integer = 0
For Each value As var In test.Values
    Assert.AreEqual(sample(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)).Value, value)
Next

Requirements

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

See Also

Reference

LurchTable.ValueCollection<TKey,TValue> Class
LurchTable.ValueCollection<TKey,TValue> Members
LurchTable.ValueCollection.Enumerator

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LurchTable.ValueCollection<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ValueCollection<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see LurchTable.ValueCollection<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements contained in the ICollection.
Top

See Also

Reference

LurchTable.ValueCollection<TKey,TValue> Class
CSharpTest.Net.Collections Namespace
LurchTable.ValueCollection LurchTable.Values

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.ValueCollection<TKey,TValue> Class : Count Property

Glossary Item Box

Gets the number of elements contained in the ICollection.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Requirements

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

See Also

Reference

LurchTable.ValueCollection<TKey,TValue> Class
LurchTable.ValueCollection<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MergeSort Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : MergeSort Class

Glossary Item Box

Provides a stable array sort based on merge-sort using O(n) additional memory. As a release build, this routine will operate faster than Array.Sort when using a custom (non-default) comparison. It also has the advantange of being stable, that is it preserves the order of elements that compare as being of equal value.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class MergeSort
C#
public static class MergeSort

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.MergeSort

Requirements

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

See Also

Reference

MergeSort Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/MergeSort.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
MergeSort Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : MergeSort Class

Glossary Item Box

The following tables list the members exposed by MergeSort.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Sort | Overloaded. Sorts the contents of the array using a stable merge-sort with O(n) additional memory
Top

See Also

Reference

MergeSort Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/MergeSort.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
MergeSort Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : MergeSort Class

Glossary Item Box

For a list of all members of this type, see MergeSort members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Sort | Overloaded. Sorts the contents of the array using a stable merge-sort with O(n) additional memory
Top

See Also

Reference

MergeSort Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/MergeSort.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Sort Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > MergeSort Class : Sort Method

Glossary Item Box

Sorts the contents of the array using a stable merge-sort with O(n) additional memory

Overload List

Overload | Description
Sort<T>(T[]) | Sorts the contents of the array using a stable merge-sort with O(n) additional memory
Sort<T>(T[],IComparer<T>) | Sorts the contents of the array using a stable merge-sort with O(n) additional memory
Sort<T>(T[],Int32,Int32,IComparer<T>) | Sorts the contents of the array using a stable merge-sort with O(n) additional memory
Sort<T>(T[],Comparison<T>) | Sorts the contents of the array using a stable merge-sort with O(n) additional memory
Sort<T>(T[],Int32,Int32,Comparison<T>) | Sorts the contents of the array using a stable merge-sort with O(n) additional memory

Requirements

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

See Also

Reference

MergeSort Class
MergeSort Members


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Sort<T>(T[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > MergeSort Class > Sort Method : Sort<T>(T[]) Method

list

Glossary Item Box

Sorts the contents of the array using a stable merge-sort with O(n) additional memory

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Sort(Of T)( _
   ByVal list() As T _
)
C#
public static void Sort<T>(
   T[] list
)

Parameters

list

Type Parameters

T

Requirements

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

See Also

Reference

MergeSort Class
MergeSort Members
Overload List

Source Code

Library/Collections/MergeSort.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Sort<T>(T[],IComparer<T>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > MergeSort Class > Sort Method : Sort<T>(T[],IComparer<T>) Method

list
compare

Glossary Item Box

Sorts the contents of the array using a stable merge-sort with O(n) additional memory

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Sort(Of T)( _
   ByVal list() As T, _
   ByVal compare As IComparer(Of T) _
)
C#
public static void Sort<T>(
   T[] list,
   IComparer<T> compare
)

Parameters

list
compare

Type Parameters

T

Requirements

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

See Also

Reference

MergeSort Class
MergeSort Members
Overload List

Source Code

Library/Collections/MergeSort.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Sort<T>(T[],Int32,Int32,IComparer<T>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > MergeSort Class > Sort Method : Sort<T>(T[],Int32,Int32,IComparer<T>) Method

list
offset
count
compare

Glossary Item Box

Sorts the contents of the array using a stable merge-sort with O(n) additional memory

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Sort(Of T)( _
   ByVal list() As T, _
   ByVal offset As Integer, _
   ByVal count As Integer, _
   ByVal compare As IComparer(Of T) _
)
C#
public static void Sort<T>(
   T[] list,
   int offset,
   int count,
   IComparer<T> compare
)

Parameters

list
offset
count
compare

Type Parameters

T

Requirements

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

See Also

Reference

MergeSort Class
MergeSort Members
Overload List

Source Code

Library/Collections/MergeSort.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Sort<T>(T[],Comparison<T>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > MergeSort Class > Sort Method : Sort<T>(T[],Comparison<T>) Method

list
compare

Glossary Item Box

Sorts the contents of the array using a stable merge-sort with O(n) additional memory

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Sort(Of T)( _
   ByVal list() As T, _
   ByVal compare As Comparison(Of T) _
)
C#
public static void Sort<T>(
   T[] list,
   Comparison<T> compare
)

Parameters

list
compare

Type Parameters

T

Requirements

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

See Also

Reference

MergeSort Class
MergeSort Members
Overload List

Source Code

Library/Collections/MergeSort.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Sort<T>(T[],Int32,Int32,Comparison<T>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > MergeSort Class > Sort Method : Sort<T>(T[],Int32,Int32,Comparison<T>) Method

list
offset
count
compare

Glossary Item Box

Sorts the contents of the array using a stable merge-sort with O(n) additional memory

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Sort(Of T)( _
   ByVal list() As T, _
   ByVal offset As Integer, _
   ByVal count As Integer, _
   ByVal compare As Comparison(Of T) _
)
C#
public static void Sort<T>(
   T[] list,
   int offset,
   int count,
   Comparison<T> compare
)

Parameters

list
offset
count
compare

Type Parameters

T

Requirements

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

See Also

Reference

MergeSort Class
MergeSort Members
Overload List

Source Code

Library/Collections/MergeSort.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
OrderedEnumeration<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedEnumeration<T> Class

Glossary Item Box

Creates an ordered enumeration from an unordered enumeration by paginating the data, sorting the page, and then performing a binary-tree grouped mergesort on the resulting pages. When the page size (memoryLimit) is hit, the page will be unloaded to disk and restored on demand if a serializer is provided.

Syntax

Visual Basic (Declaration)
Public Class OrderedEnumeration(Of T)
C#
public class OrderedEnumeration<T>

Type Parameters

T

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
var order = new OrderedEnumeration<byte>(new byte[1]);
System.Collections.IEnumerator e = ((System.Collections.IEnumerable)order).GetEnumerator();
Assert.IsTrue(e.MoveNext());
Assert.IsFalse(e.MoveNext());
try
{
    object val = e.Current;
    GC.KeepAlive(val);
    Assert.Fail();
}
catch (InvalidOperationException) { }

try
{
    e.Reset();
    Assert.Fail();
}
catch (NotSupportedException) { }
VB.NET Copy Code
Dim order As var = New OrderedEnumeration(Of Byte)(New Byte(1) {})
Dim e As System.Collections.IEnumerator = (DirectCast(order, System.Collections.IEnumerable)).GetEnumerator()
Assert.IsTrue(e.MoveNext())
Assert.IsFalse(e.MoveNext())
Try
    Dim val As Object = e.Current
    GC.KeepAlive(val)
    Assert.Fail()
Catch generatedExceptionName As InvalidOperationException
End Try

Try
    e.Reset()
    Assert.Fail()
Catch generatedExceptionName As NotSupportedException
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.OrderedEnumeration<T>
CSharpTest.Net.Collections.OrderedKeyValuePairs<TKey,TValue>

Requirements

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

See Also

Reference

OrderedEnumeration<T> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
OrderedEnumeration<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedEnumeration<T> Class

Glossary Item Box

The following tables list the members exposed by OrderedEnumeration<T>.

Public Constructors

 | Name | Description
Public Constructor | OrderedEnumeration<T> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Comparer | Gets or sets the comparer to use when ordering the items.
Public Property | DuplicateHandling | Gets or sets the duplicate item handling policy
Public Property | InMemoryLimit | Gets or sets the number of instances to keep in memory before sorting/paging to disk.
Public Property | Serializer | Gets or sets the serializer to use when paging to disk.
Top

Public Methods

 | Name | Description
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
static (Shared in Visual Basic) | Merge | Overloaded. Merges two ordered enumerations based on the comparer provided.
static (Shared in Visual Basic) | WithDuplicateHandling | Wraps an existing enumeration of Key/value pairs with an assertion about ascending order and handling for duplicate keys.
Top

See Also

Reference

OrderedEnumeration<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedEnumeration<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : OrderedEnumeration<T> Constructor

Glossary Item Box

Overload List

Overload | Description
OrderedEnumeration<T> Constructor(IEnumerable<T>) | Constructs an ordered enumeration from an unordered enumeration
OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>) | Constructs an ordered enumeration from an unordered enumeration
OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>,ISerializer<T>) | Constructs an ordered enumeration from an unordered enumeration
OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>,ISerializer<T>,Int32) | Constructs an ordered enumeration from an unordered enumeration

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedEnumeration<T> Constructor(IEnumerable<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > OrderedEnumeration<T> Constructor : OrderedEnumeration<T> Constructor(IEnumerable<T>)

unordered

Glossary Item Box

Constructs an ordered enumeration from an unordered enumeration

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal unordered As IEnumerable(Of T) _
)
C#
public OrderedEnumeration<T>(
   IEnumerable<T> unordered
)

Parameters

unordered

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
var order = new OrderedEnumeration<byte>(new byte[1]);
System.Collections.IEnumerator e = ((System.Collections.IEnumerable)order).GetEnumerator();
Assert.IsTrue(e.MoveNext());
Assert.IsFalse(e.MoveNext());
try
{
    object val = e.Current;
    GC.KeepAlive(val);
    Assert.Fail();
}
catch (InvalidOperationException) { }

try
{
    e.Reset();
    Assert.Fail();
}
catch (NotSupportedException) { }
VB.NET Copy Code
Dim order As var = New OrderedEnumeration(Of Byte)(New Byte(1) {})
Dim e As System.Collections.IEnumerator = (DirectCast(order, System.Collections.IEnumerable)).GetEnumerator()
Assert.IsTrue(e.MoveNext())
Assert.IsFalse(e.MoveNext())
Try
    Dim val As Object = e.Current
    GC.KeepAlive(val)
    Assert.Fail()
Catch generatedExceptionName As InvalidOperationException
End Try

Try
    e.Reset()
    Assert.Fail()
Catch generatedExceptionName As NotSupportedException
End Try

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
Overload List

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > OrderedEnumeration<T> Constructor : OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>)

comparer
unordered

Glossary Item Box

Constructs an ordered enumeration from an unordered enumeration

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of T), _
   ByVal unordered As IEnumerable(Of T) _
)
C#
public OrderedEnumeration<T>(
   IComparer<T> comparer,
   IEnumerable<T> unordered
)

Parameters

comparer
unordered

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
var ordered = new OrderedEnumeration<byte>(Comparer<byte>.Default, FailBeforeYield<byte>(true));

Assert.IsTrue(ReferenceEquals(Comparer<byte>.Default, ordered.Comparer));
ordered.Comparer = new ReverseOrder<byte>(ordered.Comparer);
Assert.IsTrue(ordered.Comparer is ReverseOrder<byte>);

Assert.IsNull(ordered.Serializer);
ordered.Serializer = PrimitiveSerializer.Byte;
Assert.IsTrue(ReferenceEquals(ordered.Serializer, PrimitiveSerializer.Byte));

Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(10, ordered.InMemoryLimit = 10);

Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(DuplicateHandling.FirstValueWins,
                ordered.DuplicateHandling = DuplicateHandling.FirstValueWins);
VB.NET Copy Code
Dim ordered As var = New OrderedEnumeration(Of Byte)(Comparer(Of Byte).[Default], FailBeforeYield(Of Byte)(True))

Assert.IsTrue(ReferenceEquals(Comparer(Of Byte).[Default], ordered.Comparer))
ordered.Comparer = New ReverseOrder(Of Byte)(ordered.Comparer)
Assert.IsTrue(TypeOf ordered.Comparer Is ReverseOrder(Of Byte))

Assert.IsNull(ordered.Serializer)
ordered.Serializer = PrimitiveSerializer.[Byte]
Assert.IsTrue(ReferenceEquals(ordered.Serializer, PrimitiveSerializer.[Byte]))

Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(10, ordered.InMemoryLimit = 10)

Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(DuplicateHandling.FirstValueWins, ordered.DuplicateHandling = DuplicateHandling.FirstValueWins)

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
Overload List

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>,ISerializer<T>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > OrderedEnumeration<T> Constructor : OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>,ISerializer<T>)

comparer
unordered
serializer

Glossary Item Box

Constructs an ordered enumeration from an unordered enumeration

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of T), _
   ByVal unordered As IEnumerable(Of T), _
   ByVal serializer As ISerializer(Of T) _
)
C#
public OrderedEnumeration<T>(
   IComparer<T> comparer,
   IEnumerable<T> unordered,
   ISerializer<T> serializer
)

Parameters

comparer
unordered
serializer

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
Overload List

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>,ISerializer<T>,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > OrderedEnumeration<T> Constructor : OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>,ISerializer<T>,Int32)

comparer
unordered
serializer
memoryLimit

Glossary Item Box

Constructs an ordered enumeration from an unordered enumeration

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of T), _
   ByVal unordered As IEnumerable(Of T), _
   ByVal serializer As ISerializer(Of T), _
   ByVal memoryLimit As Integer _
)
C#
public OrderedEnumeration<T>(
   IComparer<T> comparer,
   IEnumerable<T> unordered,
   ISerializer<T> serializer,
   int memoryLimit
)

Parameters

comparer
unordered
serializer
memoryLimit

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
Overload List

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
OrderedEnumeration<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedEnumeration<T> Class

Glossary Item Box

For a list of all members of this type, see OrderedEnumeration<T> members.

Public Methods

 | Name | Description
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
static (Shared in Visual Basic) | Merge | Overloaded. Merges two ordered enumerations based on the comparer provided.
static (Shared in Visual Basic) | WithDuplicateHandling | Wraps an existing enumeration of Key/value pairs with an assertion about ascending order and handling for duplicate keys.
Top

See Also

Reference

OrderedEnumeration<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of T)
C#
public IEnumerator<T> GetEnumerator()

Exceptions

Exception | Description
System.InvalidOperationException | GetEnumerator() may only be called once.
System.IO.InvalidDataException | Enumeration is out of sequence.
System.ArgumentException | Duplicate item in enumeration.

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
var ordered = new OrderedEnumeration<byte>(new byte[0]);
using (var e = ordered.GetEnumerator())
    Assert.IsFalse(e.MoveNext());

try
{
    ((System.Collections.IEnumerable) ordered).GetEnumerator();
    Assert.Fail();
}
catch (InvalidOperationException) { }
VB.NET Copy Code
Dim ordered As var = New OrderedEnumeration(Of Byte)(New Byte(0) {})
Using e As var = ordered.GetEnumerator()
    Assert.IsFalse(e.MoveNext())
End Using

Try
    (DirectCast(ordered, System.Collections.IEnumerable)).GetEnumerator()
    Assert.Fail()
Catch generatedExceptionName As InvalidOperationException
End Try

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Merge Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : Merge Method

Glossary Item Box

Merges two ordered enumerations based on the comparer provided.

Overload List

Overload | Description
Merge(IComparer<T>,IEnumerable<T>,IEnumerable<T>) | Merges two ordered enumerations based on the comparer provided.
Merge(IEnumerable<T>[]) | Merges n-number of ordered enumerations based on the default comparer of T.
Merge(IComparer<T>,IEnumerable<T>[]) | Merges n-number of ordered enumerations based on the comparer provided.
Merge(IComparer<T>,DuplicateHandling,IEnumerable<T>[]) | Merges n-number of ordered enumerations based on the comparer provided.

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Merge(IComparer<T>,IEnumerable<T>,IEnumerable<T>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > Merge Method : Merge(IComparer<T>,IEnumerable<T>,IEnumerable<T>) Method

comparer
x
y

Glossary Item Box

Merges two ordered enumerations based on the comparer provided.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Merge( _
   ByVal comparer As IComparer(Of T), _
   ByVal x As IEnumerable(Of T), _
   ByVal y As IEnumerable(Of T) _
) As IEnumerable(Of T)
C#
public static IEnumerable<T> Merge(
   IComparer<T> comparer,
   IEnumerable<T> x,
   IEnumerable<T> y
)

Parameters

comparer
x
y

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
char[] x = "aeiou".ToCharArray();
char[] y = "bcdfg".ToCharArray();
char[] z = "ez".ToCharArray();

var order = OrderedEnumeration<char>.Merge(x, y, z);
Assert.AreEqual("abcdeefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, DuplicateHandling.LastValueWins, x, y, z);
Assert.AreEqual("abcdefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, x, y);
order = OrderedEnumeration<char>.WithDuplicateHandling(order, Comparer<char>.Default,
                                                       DuplicateHandling.FirstValueWins);
Assert.AreEqual("abcdefgiou", new string(new List<char>(order).ToArray()));
VB.NET Copy Code
Dim x As Char() = "aeiou".ToCharArray()
Dim y As Char() = "bcdfg".ToCharArray()
Dim z As Char() = "ez".ToCharArray()

Dim order As var = OrderedEnumeration(Of Char).Merge(x, y, z)
Assert.AreEqual("abcdeefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], DuplicateHandling.LastValueWins, x, y, z)
Assert.AreEqual("abcdefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], x, y)
order = OrderedEnumeration(Of Char).WithDuplicateHandling(order, Comparer(Of Char).[Default], DuplicateHandling.FirstValueWins)
Assert.AreEqual("abcdefgiou", New String(New List(Of Char)(order).ToArray()))

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
Overload List

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Merge(IEnumerable<T>[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > Merge Method : Merge(IEnumerable<T>[]) Method

enums

Glossary Item Box

Merges n-number of ordered enumerations based on the default comparer of T.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Merge( _
   ByVal ParamArray enums() As IEnumerable(Of T) _
) As IEnumerable(Of T)
C#
public static IEnumerable<T> Merge(
   params IEnumerable<T>[] enums
)

Parameters

enums

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
char[] x = "aeiou".ToCharArray();
char[] y = "bcdfg".ToCharArray();
char[] z = "ez".ToCharArray();

var order = OrderedEnumeration<char>.Merge(x, y, z);
Assert.AreEqual("abcdeefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, DuplicateHandling.LastValueWins, x, y, z);
Assert.AreEqual("abcdefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, x, y);
order = OrderedEnumeration<char>.WithDuplicateHandling(order, Comparer<char>.Default,
                                                       DuplicateHandling.FirstValueWins);
Assert.AreEqual("abcdefgiou", new string(new List<char>(order).ToArray()));
VB.NET Copy Code
Dim x As Char() = "aeiou".ToCharArray()
Dim y As Char() = "bcdfg".ToCharArray()
Dim z As Char() = "ez".ToCharArray()

Dim order As var = OrderedEnumeration(Of Char).Merge(x, y, z)
Assert.AreEqual("abcdeefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], DuplicateHandling.LastValueWins, x, y, z)
Assert.AreEqual("abcdefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], x, y)
order = OrderedEnumeration(Of Char).WithDuplicateHandling(order, Comparer(Of Char).[Default], DuplicateHandling.FirstValueWins)
Assert.AreEqual("abcdefgiou", New String(New List(Of Char)(order).ToArray()))

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
Overload List

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Merge(IComparer<T>,IEnumerable<T>[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > Merge Method : Merge(IComparer<T>,IEnumerable<T>[]) Method

comparer
enums

Glossary Item Box

Merges n-number of ordered enumerations based on the comparer provided.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Merge( _
   ByVal comparer As IComparer(Of T), _
   ByVal ParamArray enums() As IEnumerable(Of T) _
) As IEnumerable(Of T)
C#
public static IEnumerable<T> Merge(
   IComparer<T> comparer,
   params IEnumerable<T>[] enums
)

Parameters

comparer
enums

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
Overload List

Source Code

Library/Collections/OrderedEnumeration.cs

Used By

IEnumerable OrderedEnumeration.Merge(IComparer,DuplicateHandling,IEnumerable[])
IEnumerable> OrderedKeyValuePairs.Merge(IComparer,IEnumerable>[])
IEnumerable> OrderedKeyValuePairs.Merge(IComparer,DuplicateHandling,IEnumerable>[])


%%PageItemTitle%%

[image]
CSharpTest.Net
Merge(IComparer<T>,DuplicateHandling,IEnumerable<T>[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > Merge Method : Merge(IComparer<T>,DuplicateHandling,IEnumerable<T>[]) Method

comparer
duplicateHandling
enums

Glossary Item Box

Merges n-number of ordered enumerations based on the comparer provided.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Merge( _
   ByVal comparer As IComparer(Of T), _
   ByVal duplicateHandling As DuplicateHandling, _
   ByVal ParamArray enums() As IEnumerable(Of T) _
) As IEnumerable(Of T)
C#
public static IEnumerable<T> Merge(
   IComparer<T> comparer,
   DuplicateHandling duplicateHandling,
   params IEnumerable<T>[] enums
)

Parameters

comparer
duplicateHandling
enums

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
char[] x = "aeiou".ToCharArray();
char[] y = "bcdfg".ToCharArray();
char[] z = "ez".ToCharArray();

var order = OrderedEnumeration<char>.Merge(x, y, z);
Assert.AreEqual("abcdeefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, DuplicateHandling.LastValueWins, x, y, z);
Assert.AreEqual("abcdefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, x, y);
order = OrderedEnumeration<char>.WithDuplicateHandling(order, Comparer<char>.Default,
                                                       DuplicateHandling.FirstValueWins);
Assert.AreEqual("abcdefgiou", new string(new List<char>(order).ToArray()));
VB.NET Copy Code
Dim x As Char() = "aeiou".ToCharArray()
Dim y As Char() = "bcdfg".ToCharArray()
Dim z As Char() = "ez".ToCharArray()

Dim order As var = OrderedEnumeration(Of Char).Merge(x, y, z)
Assert.AreEqual("abcdeefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], DuplicateHandling.LastValueWins, x, y, z)
Assert.AreEqual("abcdefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], x, y)
order = OrderedEnumeration(Of Char).WithDuplicateHandling(order, Comparer(Of Char).[Default], DuplicateHandling.FirstValueWins)
Assert.AreEqual("abcdefgiou", New String(New List(Of Char)(order).ToArray()))

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
Overload List
DuplicateHandling

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WithDuplicateHandling Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : WithDuplicateHandling Method

items
comparer
duplicateHandling

Glossary Item Box

Wraps an existing enumeration of Key/value pairs with an assertion about ascending order and handling for duplicate keys.

Syntax

Visual Basic (Declaration)
Public Shared Function WithDuplicateHandling( _
   ByVal items As IEnumerable(Of T), _
   ByVal comparer As IComparer(Of T), _
   ByVal duplicateHandling As DuplicateHandling _
) As IEnumerable(Of T)
C#
public static IEnumerable<T> WithDuplicateHandling(
   IEnumerable<T> items,
   IComparer<T> comparer,
   DuplicateHandling duplicateHandling
)

Parameters

items
comparer
duplicateHandling

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
char[] x = "aeiou".ToCharArray();
char[] y = "bcdfg".ToCharArray();
char[] z = "ez".ToCharArray();

var order = OrderedEnumeration<char>.Merge(x, y, z);
Assert.AreEqual("abcdeefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, DuplicateHandling.LastValueWins, x, y, z);
Assert.AreEqual("abcdefgiouz", new string(new List<char>(order).ToArray()));

order = OrderedEnumeration<char>.Merge(Comparer<char>.Default, x, y);
order = OrderedEnumeration<char>.WithDuplicateHandling(order, Comparer<char>.Default,
                                                       DuplicateHandling.FirstValueWins);
Assert.AreEqual("abcdefgiou", new string(new List<char>(order).ToArray()));
VB.NET Copy Code
Dim x As Char() = "aeiou".ToCharArray()
Dim y As Char() = "bcdfg".ToCharArray()
Dim z As Char() = "ez".ToCharArray()

Dim order As var = OrderedEnumeration(Of Char).Merge(x, y, z)
Assert.AreEqual("abcdeefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], DuplicateHandling.LastValueWins, x, y, z)
Assert.AreEqual("abcdefgiouz", New String(New List(Of Char)(order).ToArray()))

order = OrderedEnumeration(Of Char).Merge(Comparer(Of Char).[Default], x, y)
order = OrderedEnumeration(Of Char).WithDuplicateHandling(order, Comparer(Of Char).[Default], DuplicateHandling.FirstValueWins)
Assert.AreEqual("abcdefgiou", New String(New List(Of Char)(order).ToArray()))

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
DuplicateHandling

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)
IEnumerable OrderedEnumeration.Merge(IComparer,DuplicateHandling,IEnumerable[])
IEnumerable> OrderedKeyValuePairs.Merge(IComparer,DuplicateHandling,IEnumerable>[])

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
OrderedEnumeration<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedEnumeration<T> Class

Glossary Item Box

For a list of all members of this type, see OrderedEnumeration<T> members.

Public Properties

 | Name | Description
Public Property | Comparer | Gets or sets the comparer to use when ordering the items.
Public Property | DuplicateHandling | Gets or sets the duplicate item handling policy
Public Property | InMemoryLimit | Gets or sets the number of instances to keep in memory before sorting/paging to disk.
Public Property | Serializer | Gets or sets the serializer to use when paging to disk.
Top

See Also

Reference

OrderedEnumeration<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : Comparer Property

Glossary Item Box

Gets or sets the comparer to use when ordering the items.

Syntax

Visual Basic (Declaration)
Public Property Comparer As IComparer(Of T)
C#
public IComparer<T> Comparer {get; set;}

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateHandling Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : DuplicateHandling Property

Glossary Item Box

Gets or sets the duplicate item handling policy

Syntax

Visual Basic (Declaration)
Public Property DuplicateHandling As DuplicateHandling
C#
public DuplicateHandling DuplicateHandling {get; set;}

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
DuplicateHandling

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InMemoryLimit Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : InMemoryLimit Property

Glossary Item Box

Gets or sets the number of instances to keep in memory before sorting/paging to disk.

Syntax

Visual Basic (Declaration)
Public Property InMemoryLimit As Integer
C#
public int InMemoryLimit {get; set;}

Exceptions

Exception | Description
System.InvalidOperationException | You must specify the Serializer before setting this property

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Serializer Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class : Serializer Property

Glossary Item Box

Gets or sets the serializer to use when paging to disk.

Syntax

Visual Basic (Declaration)
Public Property Serializer As ISerializer(Of T)
C#
public ISerializer<T> Serializer {get; set;}

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedEnumeration<T> Class
OrderedEnumeration<T> Members
ISerializer

Source Code

Library/Collections/OrderedEnumeration.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedKeyValuePairs<TKey,TValue> Class

Glossary Item Box

Speicalizes the OrderedEnumeration of T to use key/value pairs with a key comparer.

Syntax

Visual Basic (Declaration)
Public Class OrderedKeyValuePairs
    (Of TKey,TValue)
   Inherits CSharpTest.Net.Collections.OrderedEnumeration(Of KeyValuePair(Of TKey,TValue))
C#
public class OrderedKeyValuePairs<TKey,TValue> : CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.OrderedEnumeration<T>
CSharpTest.Net.Collections.OrderedKeyValuePairs<TKey,TValue>

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedKeyValuePairs<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by OrderedKeyValuePairs<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | OrderedKeyValuePairs<TKey,TValue> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Comparer | Gets or sets the comparer to use when ordering the items. (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
Public Property | DuplicateHandling | Gets or sets the duplicate item handling policy (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
Public Property | InMemoryLimit | Gets or sets the number of instances to keep in memory before sorting/paging to disk. (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
Public Property | Serializer | Gets or sets the serializer to use when paging to disk. (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
Top

Public Methods

 | Name | Description
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection. (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
static (Shared in Visual Basic) | Merge | Overloaded. Merges n-number of ordered enumerations based on the comparer provided.
Top

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class : OrderedKeyValuePairs<TKey,TValue> Constructor

Glossary Item Box

Overload List

Overload | Description
OrderedKeyValuePairs<TKey,TValue> Constructor(IEnumerable<KeyValuePair<TKey,TValue>>) | Constructs an ordered set of KeyValuePair structs
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>) | Constructs an ordered set of KeyValuePair structs
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<KeyValuePair<TKey,TValue>>) | Constructs an ordered set of KeyValuePair structs
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<KeyValuePair<TKey,TValue>>,Int32) | Constructs an ordered set of KeyValuePair structs
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<TKey>,ISerializer<TValue>) | Constructs an ordered set of KeyValuePair structs
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<TKey>,ISerializer<TValue>,Int32) | Constructs an ordered set of KeyValuePair structs

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Constructor(IEnumerable<KeyValuePair<TKey,TValue>>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > OrderedKeyValuePairs<TKey,TValue> Constructor : OrderedKeyValuePairs<TKey,TValue> Constructor(IEnumerable<KeyValuePair<TKey,TValue>>)

unordered

Glossary Item Box

Constructs an ordered set of KeyValuePair structs

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal unordered As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
)
C#
public OrderedKeyValuePairs<TKey,TValue>(
   IEnumerable<KeyValuePair<TKey,TValue>> unordered
)

Parameters

unordered

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members
Overload List

Used By

TestBulkInsert.TestBulkInsertSorted()
TestBulkInsert.TestReplaceContents()

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > OrderedKeyValuePairs<TKey,TValue> Constructor : OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>)

comparer
unordered

Glossary Item Box

Constructs an ordered set of KeyValuePair structs

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal unordered As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
)
C#
public OrderedKeyValuePairs<TKey,TValue>(
   IComparer<TKey> comparer,
   IEnumerable<KeyValuePair<TKey,TValue>> unordered
)

Parameters

comparer
unordered

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members
Overload List

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<KeyValuePair<TKey,TValue>>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > OrderedKeyValuePairs<TKey,TValue> Constructor : OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<KeyValuePair<TKey,TValue>>)

comparer
unordered
serializer

Glossary Item Box

Constructs an ordered set of KeyValuePair structs

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal unordered As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal serializer As ISerializer(Of KeyValuePair(Of TKey,TValue)) _
)
C#
public OrderedKeyValuePairs<TKey,TValue>(
   IComparer<TKey> comparer,
   IEnumerable<KeyValuePair<TKey,TValue>> unordered,
   ISerializer<KeyValuePair<TKey,TValue>> serializer
)

Parameters

comparer
unordered
serializer

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members
Overload List

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<KeyValuePair<TKey,TValue>>,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > OrderedKeyValuePairs<TKey,TValue> Constructor : OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<KeyValuePair<TKey,TValue>>,Int32)

comparer
unordered
serializer
memoryLimit

Glossary Item Box

Constructs an ordered set of KeyValuePair structs

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal unordered As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal serializer As ISerializer(Of KeyValuePair(Of TKey,TValue)), _
   ByVal memoryLimit As Integer _
)
C#
public OrderedKeyValuePairs<TKey,TValue>(
   IComparer<TKey> comparer,
   IEnumerable<KeyValuePair<TKey,TValue>> unordered,
   ISerializer<KeyValuePair<TKey,TValue>> serializer,
   int memoryLimit
)

Parameters

comparer
unordered
serializer
memoryLimit

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members
Overload List

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<TKey>,ISerializer<TValue>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > OrderedKeyValuePairs<TKey,TValue> Constructor : OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<TKey>,ISerializer<TValue>)

comparer
unordered
keySerializer
valueSerializer

Glossary Item Box

Constructs an ordered set of KeyValuePair structs

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal unordered As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue) _
)
C#
public OrderedKeyValuePairs<TKey,TValue>(
   IComparer<TKey> comparer,
   IEnumerable<KeyValuePair<TKey,TValue>> unordered,
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer
)

Parameters

comparer
unordered
keySerializer
valueSerializer

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members
Overload List

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<TKey>,ISerializer<TValue>,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > OrderedKeyValuePairs<TKey,TValue> Constructor : OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<TKey>,ISerializer<TValue>,Int32)

comparer
unordered
keySerializer
valueSerializer
memoryLimit

Glossary Item Box

Constructs an ordered set of KeyValuePair structs

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal unordered As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue), _
   ByVal memoryLimit As Integer _
)
C#
public OrderedKeyValuePairs<TKey,TValue>(
   IComparer<TKey> comparer,
   IEnumerable<KeyValuePair<TKey,TValue>> unordered,
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer,
   int memoryLimit
)

Parameters

comparer
unordered
keySerializer
valueSerializer
memoryLimit

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members
Overload List

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedKeyValuePairs<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see OrderedKeyValuePairs<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection. (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
static (Shared in Visual Basic) | Merge | Overloaded. Merges n-number of ordered enumerations based on the comparer provided.
Top

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Merge Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class : Merge Method

Glossary Item Box

Merges n-number of ordered enumerations based on the comparer provided.

Overload List

Overload | Description
Merge(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>[]) | Merges n-number of ordered enumerations based on the comparer provided.
Merge(IComparer<TKey>,DuplicateHandling,IEnumerable<KeyValuePair<TKey,TValue>>[]) | Merges n-number of ordered enumerations based on the comparer provided.

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Merge(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > Merge Method : Merge(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>[]) Method

comparer
enums

Glossary Item Box

Merges n-number of ordered enumerations based on the comparer provided.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Merge( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal ParamArray enums() As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public static IEnumerable<KeyValuePair<TKey,TValue>> Merge(
   IComparer<TKey> comparer,
   params IEnumerable<KeyValuePair<TKey,TValue>>[] enums
)

Parameters

comparer
enums

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
var x = new[] { new KeyValuePair<int, int>(1, 1) };
var y = new[] { new KeyValuePair<int, int>(2, 2) };

IEnumerator<KeyValuePair<int, int>> e =
    OrderedKeyValuePairs<int, int>
    .Merge(new ReverseOrder<int>(Comparer<int>.Default), x, y)
    .GetEnumerator();

Assert.IsTrue(e.MoveNext());
Assert.AreEqual(2, e.Current.Key);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual(1, e.Current.Key);
Assert.IsFalse(e.MoveNext());
VB.NET Copy Code
Dim x As var = New () {New KeyValuePair(Of Integer, Integer)(1, 1)}
Dim y As var = New () {New KeyValuePair(Of Integer, Integer)(2, 2)}

Dim e As IEnumerator(Of KeyValuePair(Of Integer, Integer)) = OrderedKeyValuePairs(Of Integer, Integer).Merge(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), x, y).GetEnumerator()

Assert.IsTrue(e.MoveNext())
Assert.AreEqual(2, e.Current.Key)
Assert.IsTrue(e.MoveNext())
Assert.AreEqual(1, e.Current.Key)
Assert.IsFalse(e.MoveNext())

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members
Overload List

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Merge(IComparer<TKey>,DuplicateHandling,IEnumerable<KeyValuePair<TKey,TValue>>[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > Merge Method : Merge(IComparer<TKey>,DuplicateHandling,IEnumerable<KeyValuePair<TKey,TValue>>[]) Method

comparer
duplicateHandling
enums

Glossary Item Box

Merges n-number of ordered enumerations based on the comparer provided.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Merge( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal duplicateHandling As DuplicateHandling, _
   ByVal ParamArray enums() As IEnumerable(Of KeyValuePair(Of TKey,TValue)) _
) As IEnumerable(Of KeyValuePair(Of TKey,TValue))
C#
public static IEnumerable<KeyValuePair<TKey,TValue>> Merge(
   IComparer<TKey> comparer,
   DuplicateHandling duplicateHandling,
   params IEnumerable<KeyValuePair<TKey,TValue>>[] enums
)

Parameters

comparer
duplicateHandling
enums

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
var x = new[] { new KeyValuePair<int, int>(1, 1) };
var y = new[] { new KeyValuePair<int, int>(1, 2), new KeyValuePair<int, int>(2, 2) };

IEnumerator<KeyValuePair<int, int>> e =
    OrderedKeyValuePairs<int, int>
    .Merge(Comparer<int>.Default, DuplicateHandling.FirstValueWins, x, y)
    .GetEnumerator();

Assert.IsTrue(e.MoveNext());
Assert.AreEqual(1, e.Current.Key);
Assert.AreEqual(1, e.Current.Value);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual(2, e.Current.Key);
Assert.AreEqual(2, e.Current.Value);
Assert.IsFalse(e.MoveNext());

e = OrderedKeyValuePairs<int, int>
    .Merge(Comparer<int>.Default, DuplicateHandling.LastValueWins, x, y)
    .GetEnumerator();

Assert.IsTrue(e.MoveNext());
Assert.AreEqual(1, e.Current.Key);
Assert.AreEqual(2, e.Current.Value);
Assert.IsTrue(e.MoveNext());
Assert.AreEqual(2, e.Current.Key);
Assert.AreEqual(2, e.Current.Value);
Assert.IsFalse(e.MoveNext());
VB.NET Copy Code
Dim x As var = New () {New KeyValuePair(Of Integer, Integer)(1, 1)}
Dim y As var = New () {New KeyValuePair(Of Integer, Integer)(1, 2), New KeyValuePair(Of Integer, Integer)(2, 2)}

Dim e As IEnumerator(Of KeyValuePair(Of Integer, Integer)) = OrderedKeyValuePairs(Of Integer, Integer).Merge(Comparer(Of Integer).[Default], DuplicateHandling.FirstValueWins, x, y).GetEnumerator()

Assert.IsTrue(e.MoveNext())
Assert.AreEqual(1, e.Current.Key)
Assert.AreEqual(1, e.Current.Value)
Assert.IsTrue(e.MoveNext())
Assert.AreEqual(2, e.Current.Key)
Assert.AreEqual(2, e.Current.Value)
Assert.IsFalse(e.MoveNext())

e = OrderedKeyValuePairs(Of Integer, Integer).Merge(Comparer(Of Integer).[Default], DuplicateHandling.LastValueWins, x, y).GetEnumerator()

Assert.IsTrue(e.MoveNext())
Assert.AreEqual(1, e.Current.Key)
Assert.AreEqual(2, e.Current.Value)
Assert.IsTrue(e.MoveNext())
Assert.AreEqual(2, e.Current.Key)
Assert.AreEqual(2, e.Current.Value)
Assert.IsFalse(e.MoveNext())

Requirements

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

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
OrderedKeyValuePairs<TKey,TValue> Members
Overload List
DuplicateHandling

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)
TestBulkInsert.TestMergeSortedEnumerations()

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrdinalList Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrdinalList Class

Glossary Item Box

An ordinal list is a list optimized to store lists of integer data that can then be manipulated as a set with intersect/union etc. Each integer stored is translated to a bit offset and thus cann't be stored more than once or in any particular order. Note: adding the value int.Max will allocate int.Max/8 bytes of memory, so this is best used with ordinal indexes into a list that is smaller than 8,388,608 (one megabyte of bits). Pre-allocate with Ceiling = max for better performance, or add the integers in reverse order (highest to lowest).

Syntax

Visual Basic (Declaration)
Public Class OrdinalList
C#
public class OrdinalList

Example

Previously it was thought to be invalid to set a negative ceiling; however, since ceiling is an 'inclusive' value, the value of '0' actually requires 1 byte to be allocated. In order to allow explicitly clearing the array length, a -1 must be allowed;

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
list.Ceiling = -1;
Assert.AreEqual(-1, list.Ceiling);
VB.NET Copy Code
Dim list As New OrdinalList()
list.Ceiling = -1
Assert.AreEqual(-1, list.Ceiling)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.OrdinalList

Requirements

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

See Also

Reference

OrdinalList Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
OrdinalList Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrdinalList Class

Glossary Item Box

The following tables list the members exposed by OrdinalList.

Public Constructors

 | Name | Description
Public Constructor | OrdinalList Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Ceiling | Gets or sets the maximum inclusive ordinal that can be stored in the memory currently allocated, ranges from -1 to int.MaxValue
Public Property | Count | Semi-expensive, returns the count of ordinals in the collection
Public Property | IsReadOnly | Returns false
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an integer ordinal into the collection
Public Method | AddRange | Adds a range of integer ordinals into the collection
Public Method | Clear | Empty the OrdinalList
Public Method | Clone | Creates a new object that is a copy of the current instance.
Public Method | Contains | Returns true if the ordinal is in the collection
Public Method | CopyTo | Extracts the ordinals into an array
Public Method | EnumerateFrom | Returns an enumeration of the ordinal values
Public Method | EnumerateRange | Returns an enumeration of the ordinal values
Public Method | GetEnumerator | Returns an enumeration of the ordinal values
Public Method | IntersectWith | Returns the set of items that are in both this set and the provided set
Public Method | Invert | Returns the 1's compliment (inverts) of the list up to Ceiling
Public Method | Remove | Removes an ordinal from the collection
Public Method | ToArray | Returns the array of ordinals that have been added.
Public Method | ToByteArray | Returns the complete set of raw bytes for storage and reconstitution
Public Method | UnionWith | Returns the set of items that are in either this set or the provided set
Top

See Also

Reference

OrdinalList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrdinalList Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : OrdinalList Constructor

Glossary Item Box

Overload List

Overload | Description
OrdinalList Constructor() | Constructs an empty OrdinalList
OrdinalList Constructor(Byte[]) | Constructs an OrdinalList from a set of bits represeting the ordinals
OrdinalList Constructor(IEnumerable<Int32>) | Constructs an OrdinalList from the integer ordinals provided

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
OrdinalList Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class > OrdinalList Constructor : OrdinalList Constructor()

Glossary Item Box

Constructs an empty OrdinalList

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public OrdinalList()

Example

Previously it was thought to be invalid to set a negative ceiling; however, since ceiling is an 'inclusive' value, the value of '0' actually requires 1 byte to be allocated. In order to allow explicitly clearing the array length, a -1 must be allowed;

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
list.Ceiling = -1;
Assert.AreEqual(-1, list.Ceiling);
VB.NET Copy Code
Dim list As New OrdinalList()
list.Ceiling = -1
Assert.AreEqual(-1, list.Ceiling)

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members
Overload List

Used By

OrdinalList OrdinalList.Invert(Int32)
OrdinalList OrdinalList.IntersectWith(OrdinalList)
OrdinalList OrdinalList.UnionWith(OrdinalList)
OrdinalList OrdinalList.Clone()

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrdinalList Constructor(Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class > OrdinalList Constructor : OrdinalList Constructor(Byte[])

fromBits

Glossary Item Box

Constructs an OrdinalList from a set of bits represeting the ordinals

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal fromBits() As Byte _
)
C#
public OrdinalList(
   byte[] fromBits
)

Parameters

fromBits

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
Assert.IsFalse(list.IsReadOnly);
list.Ceiling = 0;

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);
Assert.AreEqual(519, list.Ceiling);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);
Assert.AreEqual(23, list.Ceiling);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

byte[] bits = list.ToByteArray();
Assert.AreEqual(3, bits.Length);
Assert.AreEqual(2, new OrdinalList(bits).Count);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New OrdinalList()
Assert.IsFalse(list.IsReadOnly)
list.Ceiling = 0

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)
Assert.AreEqual(519, list.Ceiling)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)
Assert.AreEqual(23, list.Ceiling)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim bits As Byte() = list.ToByteArray()
Assert.AreEqual(3, bits.Length)
Assert.AreEqual(2, New OrdinalList(bits).Count)

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members
Overload List

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OrdinalList Constructor(IEnumerable<Int32>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class > OrdinalList Constructor : OrdinalList Constructor(IEnumerable<Int32>)

contents

Glossary Item Box

Constructs an OrdinalList from the integer ordinals provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal contents As IEnumerable(Of Integer) _
)
C#
public OrdinalList(
   IEnumerable<int> contents
)

Parameters

contents

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList lista = new OrdinalList(new int[] { 1, 4, 5 });
OrdinalList listb = new OrdinalList(new int[] { 2, 4, 6 });

OrdinalList union = lista.UnionWith(listb);
Assert.AreEqual(5, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

OrdinalList inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(4, i);
VB.NET Copy Code
Dim lista As New OrdinalList(New Integer() {1, 4, 5})
Dim listb As New OrdinalList(New Integer() {2, 4, 6})

Dim union As OrdinalList = lista.UnionWith(listb)
Assert.AreEqual(5, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Dim inter As OrdinalList = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(4, i)
Next

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members
Overload List

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
OrdinalList Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrdinalList Class

Glossary Item Box

For a list of all members of this type, see OrdinalList members.

Public Methods

 | Name | Description
Public Method | Add | Adds an integer ordinal into the collection
Public Method | AddRange | Adds a range of integer ordinals into the collection
Public Method | Clear | Empty the OrdinalList
Public Method | Clone | Creates a new object that is a copy of the current instance.
Public Method | Contains | Returns true if the ordinal is in the collection
Public Method | CopyTo | Extracts the ordinals into an array
Public Method | EnumerateFrom | Returns an enumeration of the ordinal values
Public Method | EnumerateRange | Returns an enumeration of the ordinal values
Public Method | GetEnumerator | Returns an enumeration of the ordinal values
Public Method | IntersectWith | Returns the set of items that are in both this set and the provided set
Public Method | Invert | Returns the 1's compliment (inverts) of the list up to Ceiling
Public Method | Remove | Removes an ordinal from the collection
Public Method | ToArray | Returns the array of ordinals that have been added.
Public Method | ToByteArray | Returns the complete set of raw bytes for storage and reconstitution
Public Method | UnionWith | Returns the set of items that are in either this set or the provided set
Top

See Also

Reference

OrdinalList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : Add Method

item

Glossary Item Box

Adds an integer ordinal into the collection

Syntax

Visual Basic (Declaration)
Public Sub Add( _
   ByVal item As Integer _
)
C#
public void Add(
   int item
)

Parameters

item

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList lista = new OrdinalList(new int[] { 0 });
OrdinalList listb = (OrdinalList) ((ICloneable) lista).Clone();
Assert.IsFalse(ReferenceEquals(lista, listb));
Assert.AreEqual(lista.Count, listb.Count);
Assert.IsTrue(listb.Contains(0));

listb.Add(1);
Assert.IsTrue(listb.Contains(1));
Assert.IsFalse(lista.Contains(1));
VB.NET Copy Code
Dim lista As New OrdinalList(New Integer() {0})
Dim listb As OrdinalList = DirectCast((DirectCast(lista, ICloneable)).Clone(), OrdinalList)
Assert.IsFalse(ReferenceEquals(lista, listb))
Assert.AreEqual(lista.Count, listb.Count)
Assert.IsTrue(listb.Contains(0))

listb.Add(1)
Assert.IsTrue(listb.Contains(1))
Assert.IsFalse(lista.Contains(1))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs

Used By

OrdinalList OrdinalList.Invert(Int32)
TransactedCompoundFile.Delete(UInt32)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : AddRange Method

contents

Glossary Item Box

Adds a range of integer ordinals into the collection

Syntax

Visual Basic (Declaration)
Public Sub AddRange( _
   ByVal contents As IEnumerable(Of Integer) _
)
C#
public void AddRange(
   IEnumerable<int> contents
)

Parameters

contents

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
list.AddRange(new int[] { 5, 10, 20 });

ICollection coll = list;
Assert.IsFalse(coll.IsSynchronized);
Assert.IsTrue(Object.ReferenceEquals(coll, coll.SyncRoot));

int[] copy = new int[3];
coll.CopyTo(copy, 0);
Assert.AreEqual(5, copy[0]);
Assert.AreEqual(10, copy[1]);
Assert.AreEqual(20, copy[2]);

byte[] bits = new byte[3];
coll.CopyTo(bits, 0);
Assert.AreEqual(32, bits[0]);
Assert.AreEqual(4, bits[1]);
Assert.AreEqual(16, bits[2]);

List<int> tmp = new List<int>();
foreach (int i in coll)
    tmp.Add(i);
Assert.AreEqual(3, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
Assert.AreEqual(20, tmp[2]);
VB.NET Copy Code
Dim list As New OrdinalList()
list.AddRange(New Integer() {5, 10, 20})

Dim coll As ICollection = list
Assert.IsFalse(coll.IsSynchronized)
Assert.IsTrue([Object].ReferenceEquals(coll, coll.SyncRoot))

Dim copy As Integer() = New Integer(3) {}
coll.CopyTo(copy, 0)
Assert.AreEqual(5, copy(0))
Assert.AreEqual(10, copy(1))
Assert.AreEqual(20, copy(2))

Dim bits As Byte() = New Byte(3) {}
coll.CopyTo(bits, 0)
Assert.AreEqual(32, bits(0))
Assert.AreEqual(4, bits(1))
Assert.AreEqual(16, bits(2))

Dim tmp As New List(Of Integer)()
For Each i As Integer In coll
    tmp.Add(i)
Next
Assert.AreEqual(3, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))
Assert.AreEqual(20, tmp(2))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : Clear Method

Glossary Item Box

Empty the OrdinalList

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
Assert.IsFalse(list.IsReadOnly);
list.Ceiling = 0;

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);
Assert.AreEqual(519, list.Ceiling);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);
Assert.AreEqual(23, list.Ceiling);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

byte[] bits = list.ToByteArray();
Assert.AreEqual(3, bits.Length);
Assert.AreEqual(2, new OrdinalList(bits).Count);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New OrdinalList()
Assert.IsFalse(list.IsReadOnly)
list.Ceiling = 0

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)
Assert.AreEqual(519, list.Ceiling)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)
Assert.AreEqual(23, list.Ceiling)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim bits As Byte() = list.ToByteArray()
Assert.AreEqual(3, bits.Length)
Assert.AreEqual(2, New OrdinalList(bits).Count)

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs

Used By

TransactedCompoundFile.Dispose()
TransactedCompoundFile.Clear()


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : Clone Method

Glossary Item Box

Creates a new object that is a copy of the current instance.

Syntax

Visual Basic (Declaration)
Public Function Clone() As OrdinalList
C#
public OrdinalList Clone()

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : Contains Method

item

Glossary Item Box

Returns true if the ordinal is in the collection

Syntax

Visual Basic (Declaration)
Public Function Contains( _
   ByVal item As Integer _
) As Boolean
C#
public bool Contains(
   int item
)

Parameters

item

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList lista = new OrdinalList(new int[] { 1, 4, 5 });
OrdinalList listb = new OrdinalList(new int[] { 2, 4, 6 });

OrdinalList union = lista.UnionWith(listb);
Assert.AreEqual(5, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

OrdinalList inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(4, i);
VB.NET Copy Code
Dim lista As New OrdinalList(New Integer() {1, 4, 5})
Dim listb As New OrdinalList(New Integer() {2, 4, 6})

Dim union As OrdinalList = lista.UnionWith(listb)
Assert.AreEqual(5, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Dim inter As OrdinalList = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(4, i)
Next

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs

Used By

TransactedCompoundFile.Write(UInt32,Byte[],Int32,Int32)
Stream TransactedCompoundFile.Read(UInt32)
TransactedCompoundFile.Delete(UInt32)


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Extracts the ordinals into an array

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As Integer, _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   int[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
Assert.IsFalse(list.IsReadOnly);
list.Ceiling = 0;

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);
Assert.AreEqual(519, list.Ceiling);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);
Assert.AreEqual(23, list.Ceiling);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

byte[] bits = list.ToByteArray();
Assert.AreEqual(3, bits.Length);
Assert.AreEqual(2, new OrdinalList(bits).Count);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New OrdinalList()
Assert.IsFalse(list.IsReadOnly)
list.Ceiling = 0

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)
Assert.AreEqual(519, list.Ceiling)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)
Assert.AreEqual(23, list.Ceiling)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim bits As Byte() = list.ToByteArray()
Assert.AreEqual(3, bits.Length)
Assert.AreEqual(2, New OrdinalList(bits).Count)

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateFrom Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : EnumerateFrom Method

startAt

Glossary Item Box

Returns an enumeration of the ordinal values

Syntax

Visual Basic (Declaration)
Public Function EnumerateFrom( _
   ByVal startAt As Integer _
) As IEnumerable(Of Integer)
C#
public IEnumerable<int> EnumerateFrom(
   int startAt
)

Parameters

startAt

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs

Used By

IEnumerator OrdinalList.GetEnumerator()
UInt32 TransactedCompoundFile.Create()


%%PageItemTitle%%

[image]
CSharpTest.Net
EnumerateRange Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : EnumerateRange Method

startAt
endAt

Glossary Item Box

Returns an enumeration of the ordinal values

Syntax

Visual Basic (Declaration)
Public Function EnumerateRange( _
   ByVal startAt As Integer, _
   ByVal endAt As Integer _
) As IEnumerable(Of Integer)
C#
public IEnumerable<int> EnumerateRange(
   int startAt,
   int endAt
)

Parameters

startAt
endAt

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Used By

IEnumerable OrdinalList.EnumerateFrom(Int32)

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : GetEnumerator Method

Glossary Item Box

Returns an enumeration of the ordinal values

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of Integer)
C#
public IEnumerator<int> GetEnumerator()

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList lista = new OrdinalList(new int[] { 1, 4, 5 });
OrdinalList listb = new OrdinalList(new int[] { 2, 4, 6 });

OrdinalList union = lista.UnionWith(listb);
Assert.AreEqual(5, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

OrdinalList inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(4, i);
VB.NET Copy Code
Dim lista As New OrdinalList(New Integer() {1, 4, 5})
Dim listb As New OrdinalList(New Integer() {2, 4, 6})

Dim union As OrdinalList = lista.UnionWith(listb)
Assert.AreEqual(5, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Dim inter As OrdinalList = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(4, i)
Next

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Used By

OrdinalList.CopyTo(Int32[],Int32)
TransactedCompoundFile.Commit(Action,T)

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IntersectWith Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : IntersectWith Method

other

Glossary Item Box

Returns the set of items that are in both this set and the provided set

Syntax

Visual Basic (Declaration)
Public Function IntersectWith( _
   ByVal other As OrdinalList _
) As OrdinalList
C#
public OrdinalList IntersectWith(
   OrdinalList other
)

Parameters

other

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList lista = new OrdinalList(new int[] { 1, 4, 5 });
OrdinalList listb = new OrdinalList(new int[] { 2, 4, 6 });

OrdinalList union = lista.UnionWith(listb);
Assert.AreEqual(5, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

OrdinalList inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(4, i);
VB.NET Copy Code
Dim lista As New OrdinalList(New Integer() {1, 4, 5})
Dim listb As New OrdinalList(New Integer() {2, 4, 6})

Dim union As OrdinalList = lista.UnionWith(listb)
Assert.AreEqual(5, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Dim inter As OrdinalList = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(4, i)
Next

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Invert Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : Invert Method

ceiling

Glossary Item Box

Returns the 1's compliment (inverts) of the list up to Ceiling

Syntax

Visual Basic (Declaration)
Public Function Invert( _
   ByVal ceiling As Integer _
) As OrdinalList
C#
public OrdinalList Invert(
   int ceiling
)

Parameters

ceiling

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList lista = new OrdinalList(new int[] {0, 2, 4, 6, 8, 10, 12});
OrdinalList listb = new OrdinalList(new int[] {1, 3, 5, 7, 9, 11, 13});

OrdinalList invta = lista.Invert(13);
string invtatext = "", listbtext = "";
foreach (int i in invta)
    invtatext += "," + i;
foreach (int i in listb)
    listbtext += "," + i;
Assert.AreEqual(listbtext, invtatext);

lista = new OrdinalList(new int[] { 0 });
listb = new OrdinalList(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
invta = lista.Invert(13);
invtatext = "";
listbtext = "";
foreach (int i in invta)
    invtatext += "," + i;
foreach (int i in listb)
    listbtext += "," + i;
Assert.AreEqual(listbtext, invtatext);

lista = new OrdinalList(new int[] { 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 13 });
listb = new OrdinalList(new int[] { 3 });
invta = lista.Invert(4);
invtatext = "";
listbtext = "";
foreach (int i in invta)
    invtatext += "," + i;
foreach (int i in listb)
    listbtext += "," + i;
Assert.AreEqual(listbtext, invtatext);
VB.NET Copy Code
Dim lista As New OrdinalList(New Integer() {0, 2, 4, 6, 8, 10, _
    12})
Dim listb As New OrdinalList(New Integer() {1, 3, 5, 7, 9, 11, _
    13})

Dim invta As OrdinalList = lista.Invert(13)
Dim invtatext As String = "", listbtext As String = ""
For Each i As Integer In invta
    invtatext += "," + i
Next
For Each i As Integer In listb
    listbtext += "," + i
Next
Assert.AreEqual(listbtext, invtatext)

lista = New OrdinalList(New Integer() {0})
listb = New OrdinalList(New Integer() {1, 2, 3, 4, 5, 6, _
    7, 8, 9, 10, 11, 12, _
    13})
invta = lista.Invert(13)
invtatext = ""
listbtext = ""
For Each i As Integer In invta
    invtatext += "," + i
Next
For Each i As Integer In listb
    listbtext += "," + i
Next
Assert.AreEqual(listbtext, invtatext)

lista = New OrdinalList(New Integer() {0, 1, 2, 4, 5, 6, _
    7, 8, 9, 10, 11, 13})
listb = New OrdinalList(New Integer() {3})
invta = lista.Invert(4)
invtatext = ""
listbtext = ""
For Each i As Integer In invta
    invtatext += "," + i
Next
For Each i As Integer In listb
    listbtext += "," + i
Next
Assert.AreEqual(listbtext, invtatext)

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs

Used By

TransactedCompoundFile.Commit(Action,T)


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : Remove Method

item

Glossary Item Box

Removes an ordinal from the collection

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal item As Integer _
) As Boolean
C#
public bool Remove(
   int item
)

Parameters

item

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
Assert.IsFalse(list.IsReadOnly);
list.Ceiling = 0;

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);
Assert.AreEqual(519, list.Ceiling);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);
Assert.AreEqual(23, list.Ceiling);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

byte[] bits = list.ToByteArray();
Assert.AreEqual(3, bits.Length);
Assert.AreEqual(2, new OrdinalList(bits).Count);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New OrdinalList()
Assert.IsFalse(list.IsReadOnly)
list.Ceiling = 0

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)
Assert.AreEqual(519, list.Ceiling)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)
Assert.AreEqual(23, list.Ceiling)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim bits As Byte() = list.ToByteArray()
Assert.AreEqual(3, bits.Length)
Assert.AreEqual(2, New OrdinalList(bits).Count)

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs

Used By

OrdinalList OrdinalList.Invert(Int32)
UInt32 TransactedCompoundFile.Create()


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : ToArray Method

Glossary Item Box

Returns the array of ordinals that have been added.

Syntax

Visual Basic (Declaration)
Public Function ToArray() As Integer()
C#
public int[] ToArray()

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
Assert.IsFalse(list.IsReadOnly);
list.Ceiling = 0;

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);
Assert.AreEqual(519, list.Ceiling);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);
Assert.AreEqual(23, list.Ceiling);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

byte[] bits = list.ToByteArray();
Assert.AreEqual(3, bits.Length);
Assert.AreEqual(2, new OrdinalList(bits).Count);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New OrdinalList()
Assert.IsFalse(list.IsReadOnly)
list.Ceiling = 0

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)
Assert.AreEqual(519, list.Ceiling)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)
Assert.AreEqual(23, list.Ceiling)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim bits As Byte() = list.ToByteArray()
Assert.AreEqual(3, bits.Length)
Assert.AreEqual(2, New OrdinalList(bits).Count)

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToByteArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : ToByteArray Method

Glossary Item Box

Returns the complete set of raw bytes for storage and reconstitution

Syntax

Visual Basic (Declaration)
Public Function ToByteArray() As Byte()
C#
public byte[] ToByteArray()

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
Assert.IsFalse(list.IsReadOnly);
list.Ceiling = 0;

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);
Assert.AreEqual(519, list.Ceiling);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);
Assert.AreEqual(23, list.Ceiling);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

byte[] bits = list.ToByteArray();
Assert.AreEqual(3, bits.Length);
Assert.AreEqual(2, new OrdinalList(bits).Count);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New OrdinalList()
Assert.IsFalse(list.IsReadOnly)
list.Ceiling = 0

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)
Assert.AreEqual(519, list.Ceiling)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)
Assert.AreEqual(23, list.Ceiling)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim bits As Byte() = list.ToByteArray()
Assert.AreEqual(3, bits.Length)
Assert.AreEqual(2, New OrdinalList(bits).Count)

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UnionWith Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : UnionWith Method

other

Glossary Item Box

Returns the set of items that are in either this set or the provided set

Syntax

Visual Basic (Declaration)
Public Function UnionWith( _
   ByVal other As OrdinalList _
) As OrdinalList
C#
public OrdinalList UnionWith(
   OrdinalList other
)

Parameters

other

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList lista = new OrdinalList(new int[] { 1, 4, 5 });
OrdinalList listb = new OrdinalList(new int[] { 2, 4, 6 });

OrdinalList union = lista.UnionWith(listb);
Assert.AreEqual(5, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

OrdinalList inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(4, i);
VB.NET Copy Code
Dim lista As New OrdinalList(New Integer() {1, 4, 5})
Dim listb As New OrdinalList(New Integer() {2, 4, 6})

Dim union As OrdinalList = lista.UnionWith(listb)
Assert.AreEqual(5, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Dim inter As OrdinalList = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(4, i)
Next

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
OrdinalList Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrdinalList Class

Glossary Item Box

For a list of all members of this type, see OrdinalList members.

Public Properties

 | Name | Description
Public Property | Ceiling | Gets or sets the maximum inclusive ordinal that can be stored in the memory currently allocated, ranges from -1 to int.MaxValue
Public Property | Count | Semi-expensive, returns the count of ordinals in the collection
Public Property | IsReadOnly | Returns false
Top

See Also

Reference

OrdinalList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Ceiling Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : Ceiling Property

Glossary Item Box

Gets or sets the maximum inclusive ordinal that can be stored in the memory currently allocated, ranges from -1 to int.MaxValue

Syntax

Visual Basic (Declaration)
Public Property Ceiling As Integer
C#
public int Ceiling {get; set;}

Example

Previously it was thought to be invalid to set a negative ceiling; however, since ceiling is an 'inclusive' value, the value of '0' actually requires 1 byte to be allocated. In order to allow explicitly clearing the array length, a -1 must be allowed;

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
list.Ceiling = -1;
Assert.AreEqual(-1, list.Ceiling);
VB.NET Copy Code
Dim list As New OrdinalList()
list.Ceiling = -1
Assert.AreEqual(-1, list.Ceiling)

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Used By

OrdinalList OrdinalList.Invert(Int32)

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : Count Property

Glossary Item Box

Semi-expensive, returns the count of ordinals in the collection

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList lista = new OrdinalList(new int[] { 1, 4, 5 });
OrdinalList listb = new OrdinalList(new int[] { 2, 4, 6 });

OrdinalList union = lista.UnionWith(listb);
Assert.AreEqual(5, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

OrdinalList inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(4, i);
VB.NET Copy Code
Dim lista As New OrdinalList(New Integer() {1, 4, 5})
Dim listb As New OrdinalList(New Integer() {2, 4, 6})

Dim union As OrdinalList = lista.UnionWith(listb)
Assert.AreEqual(5, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Dim inter As OrdinalList = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(4, i)
Next

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReadOnly Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrdinalList Class : IsReadOnly Property

Glossary Item Box

Returns false

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReadOnly As Boolean
C#
public bool IsReadOnly {get;}

Example

Library/Library.Test/TestOrdinalList.cs

C# Copy Code
OrdinalList list = new OrdinalList();
Assert.IsFalse(list.IsReadOnly);
list.Ceiling = 0;

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);
Assert.AreEqual(519, list.Ceiling);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);
Assert.AreEqual(23, list.Ceiling);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

byte[] bits = list.ToByteArray();
Assert.AreEqual(3, bits.Length);
Assert.AreEqual(2, new OrdinalList(bits).Count);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New OrdinalList()
Assert.IsFalse(list.IsReadOnly)
list.Ceiling = 0

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)
Assert.AreEqual(519, list.Ceiling)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)
Assert.AreEqual(23, list.Ceiling)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim bits As Byte() = list.ToByteArray()
Assert.AreEqual(3, bits.Length)
Assert.AreEqual(2, New OrdinalList(bits).Count)

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

OrdinalList Class
OrdinalList Members

Source Code

Library/Collections/OrdinalList.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
ReadOnlyList<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ReadOnlyList<T> Class

Glossary Item Box

A readonly list of T

Object Model

ReadOnlyList<T> ClassT Class

Syntax

Visual Basic (Declaration)
Public Class ReadOnlyList(Of T)
   Implements IReadOnlyCollection(Of T), CSharpTest.Net.Interfaces.ICloneable(Of ReadOnlyList(Of T))
C#
public class ReadOnlyList<T> : IReadOnlyCollection<T>, CSharpTest.Net.Interfaces.ICloneable<ReadOnlyList<T>>

Type Parameters

T

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
ICollection read = new ReadOnlyList<int>((IEnumerable<int>)new int[] { 5, 10, 15 });
Assert.AreEqual(3, read.Count);
Assert.IsFalse(read.IsSynchronized);
Assert.IsTrue(Object.ReferenceEquals(read, read.SyncRoot));

long[] lary = new long[3];
read.CopyTo(lary, 0);
Assert.AreEqual(5L, lary[0]);
Assert.AreEqual(10L, lary[1]);
Assert.AreEqual(15L, lary[2]);

ICollection copy = (ICollection)((ICloneable)read).Clone();
Assert.AreEqual(3, copy.Count);
VB.NET Copy Code
Dim read As ICollection = New ReadOnlyList(Of Integer)(DirectCast(New Integer() {5, 10, 15}, IEnumerable(Of Integer)))
Assert.AreEqual(3, read.Count)
Assert.IsFalse(read.IsSynchronized)
Assert.IsTrue([Object].ReferenceEquals(read, read.SyncRoot))

Dim lary As Long() = New Long(3) {}
read.CopyTo(lary, 0)
Assert.AreEqual(5L, lary(0))
Assert.AreEqual(10L, lary(1))
Assert.AreEqual(15L, lary(2))

Dim copy As ICollection = DirectCast((DirectCast(read, ICloneable)).Clone(), ICollection)
Assert.AreEqual(3, copy.Count)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.ReadOnlyList<T>

Requirements

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

See Also

Reference

ReadOnlyList<T> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ReadOnlyList<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ReadOnlyList<T> Class

Glossary Item Box

The following tables list the members exposed by ReadOnlyList<T>.

Public Constructors

 | Name | Description
Public Constructor | ReadOnlyList<T> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Count | Returns the count of items contained in the collection
Public Property | Item | Returns the element at the given offset
Top

Public Methods

 | Name | Description
Public Method | Clone | Returns a shallow clone of this object
Public Method | Contains | Returns true if the list contains the specified element.
Public Method | CopyTo | Copy the elements in the collection to the specified array
Public Method | GetEnumerator | Returns an enumeration of the elements in the collection
Public Method | IndexOf | Returns the zero-based index of the item or -1 if not found.
Public Method | ToArray | Returns the collection as an array
Top

See Also

Reference

ReadOnlyList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadOnlyList<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : ReadOnlyList<T> Constructor

Glossary Item Box

Overload List

Overload | Description
ReadOnlyList<T> Constructor(IEnumerable<T>) | Creates a readonly list of T by copying the enumeration into a List<T>
ReadOnlyList<T> Constructor(IList<T>) | Creates a readonly list of T by copying the collection
ReadOnlyList<T> Constructor(IList<T>,Boolean) | Creates a readonly list of T creating a copy if desired

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadOnlyList<T> Constructor(IEnumerable<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class > ReadOnlyList<T> Constructor : ReadOnlyList<T> Constructor(IEnumerable<T>)

collection

Glossary Item Box

Creates a readonly list of T by copying the enumeration into a List<T>

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal collection As IEnumerable(Of T) _
)
C#
public ReadOnlyList<T>(
   IEnumerable<T> collection
)

Parameters

collection

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
ICollection read = new ReadOnlyList<int>((IEnumerable<int>)new int[] { 5, 10, 15 });
Assert.AreEqual(3, read.Count);
Assert.IsFalse(read.IsSynchronized);
Assert.IsTrue(Object.ReferenceEquals(read, read.SyncRoot));

long[] lary = new long[3];
read.CopyTo(lary, 0);
Assert.AreEqual(5L, lary[0]);
Assert.AreEqual(10L, lary[1]);
Assert.AreEqual(15L, lary[2]);

ICollection copy = (ICollection)((ICloneable)read).Clone();
Assert.AreEqual(3, copy.Count);
VB.NET Copy Code
Dim read As ICollection = New ReadOnlyList(Of Integer)(DirectCast(New Integer() {5, 10, 15}, IEnumerable(Of Integer)))
Assert.AreEqual(3, read.Count)
Assert.IsFalse(read.IsSynchronized)
Assert.IsTrue([Object].ReferenceEquals(read, read.SyncRoot))

Dim lary As Long() = New Long(3) {}
read.CopyTo(lary, 0)
Assert.AreEqual(5L, lary(0))
Assert.AreEqual(10L, lary(1))
Assert.AreEqual(15L, lary(2))

Dim copy As ICollection = DirectCast((DirectCast(read, ICloneable)).Clone(), ICollection)
Assert.AreEqual(3, copy.Count)

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members
Overload List

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadOnlyList<T> Constructor(IList<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class > ReadOnlyList<T> Constructor : ReadOnlyList<T> Constructor(IList<T>)

list

Glossary Item Box

Creates a readonly list of T by copying the collection

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal list As IList(Of T) _
)
C#
public ReadOnlyList<T>(
   IList<T> list
)

Parameters

list

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings);
strings.Add("d");
Assert.AreEqual(3, read.Count);
Assert.IsTrue(read.Contains("a"));
Assert.AreEqual(0, read.IndexOf("a"));
Assert.IsTrue(read.Contains("b"));
Assert.AreEqual(1, read.IndexOf("b"));
Assert.IsTrue(read.Contains("c"));
Assert.AreEqual(2, read.IndexOf("c"));
Assert.IsFalse(read.Contains("d"));
Assert.AreEqual(-1, read.IndexOf("d"));
Assert.AreEqual("a,b,c", String.Join(",", read.ToArray()));
Assert.AreEqual("a,b,c", String.Join(",", new List<String>(read).ToArray()));

string[] arcopy = new string[3];
read.CopyTo(arcopy, 0);
Assert.AreEqual("a,b,c", String.Join(",", arcopy));

System.Collections.IEnumerator en = ((System.Collections.IEnumerable)read).GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("a", en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("b", en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("c", en.Current);
Assert.IsFalse(en.MoveNext());
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings)
strings.Add("d")
Assert.AreEqual(3, read.Count)
Assert.IsTrue(read.Contains("a"))
Assert.AreEqual(0, read.IndexOf("a"))
Assert.IsTrue(read.Contains("b"))
Assert.AreEqual(1, read.IndexOf("b"))
Assert.IsTrue(read.Contains("c"))
Assert.AreEqual(2, read.IndexOf("c"))
Assert.IsFalse(read.Contains("d"))
Assert.AreEqual(-1, read.IndexOf("d"))
Assert.AreEqual("a,b,c", [String].Join(",", read.ToArray()))
Assert.AreEqual("a,b,c", [String].Join(",", New List(Of [String])(read).ToArray()))

Dim arcopy As String() = New String(3) {}
read.CopyTo(arcopy, 0)
Assert.AreEqual("a,b,c", [String].Join(",", arcopy))

Dim en As System.Collections.IEnumerator = (DirectCast(read, System.Collections.IEnumerable)).GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("a", en.Current)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("b", en.Current)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("c", en.Current)
Assert.IsFalse(en.MoveNext())

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members
Overload List

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadOnlyList<T> Constructor(IList<T>,Boolean)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class > ReadOnlyList<T> Constructor : ReadOnlyList<T> Constructor(IList<T>,Boolean)

list
clone

Glossary Item Box

Creates a readonly list of T creating a copy if desired

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal list As IList(Of T), _
   ByVal clone As Boolean _
)
C#
public ReadOnlyList<T>(
   IList<T> list,
   bool clone
)

Parameters

list
clone

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);

Assert.AreEqual(3, read.Count);
strings.RemoveAt(2);
Assert.AreEqual(2, read.Count);
Assert.AreEqual("a", read[0]);
Assert.AreEqual("b", read[1]);

Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray()));
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings, False)

Assert.AreEqual(3, read.Count)
strings.RemoveAt(2)
Assert.AreEqual(2, read.Count)
Assert.AreEqual("a", read(0))
Assert.AreEqual("b", read(1))

Assert.AreEqual("a,b", [String].Join(",", read.Clone().ToArray()))

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members
Overload List

Used By

ReadOnlyList ReadOnlyList.Clone()

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ReadOnlyList<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ReadOnlyList<T> Class

Glossary Item Box

For a list of all members of this type, see ReadOnlyList<T> members.

Public Methods

 | Name | Description
Public Method | Clone | Returns a shallow clone of this object
Public Method | Contains | Returns true if the list contains the specified element.
Public Method | CopyTo | Copy the elements in the collection to the specified array
Public Method | GetEnumerator | Returns an enumeration of the elements in the collection
Public Method | IndexOf | Returns the zero-based index of the item or -1 if not found.
Public Method | ToArray | Returns the collection as an array
Top

See Also

Reference

ReadOnlyList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : Clone Method

Glossary Item Box

Returns a shallow clone of this object

Syntax

Visual Basic (Declaration)
Public Function Clone() As ReadOnlyList(Of T)
C#
public ReadOnlyList<T> Clone()

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);

Assert.AreEqual(3, read.Count);
strings.RemoveAt(2);
Assert.AreEqual(2, read.Count);
Assert.AreEqual("a", read[0]);
Assert.AreEqual("b", read[1]);

Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray()));
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings, False)

Assert.AreEqual(3, read.Count)
strings.RemoveAt(2)
Assert.AreEqual(2, read.Count)
Assert.AreEqual("a", read(0))
Assert.AreEqual("b", read(1))

Assert.AreEqual("a,b", [String].Join(",", read.Clone().ToArray()))

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : Contains Method

item

Glossary Item Box

Returns true if the list contains the specified element.

Syntax

Visual Basic (Declaration)
Public Function Contains( _
   ByVal item As T _
) As Boolean
C#
public bool Contains(
   T item
)

Parameters

item

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings);
strings.Add("d");
Assert.AreEqual(3, read.Count);
Assert.IsTrue(read.Contains("a"));
Assert.AreEqual(0, read.IndexOf("a"));
Assert.IsTrue(read.Contains("b"));
Assert.AreEqual(1, read.IndexOf("b"));
Assert.IsTrue(read.Contains("c"));
Assert.AreEqual(2, read.IndexOf("c"));
Assert.IsFalse(read.Contains("d"));
Assert.AreEqual(-1, read.IndexOf("d"));
Assert.AreEqual("a,b,c", String.Join(",", read.ToArray()));
Assert.AreEqual("a,b,c", String.Join(",", new List<String>(read).ToArray()));

string[] arcopy = new string[3];
read.CopyTo(arcopy, 0);
Assert.AreEqual("a,b,c", String.Join(",", arcopy));

System.Collections.IEnumerator en = ((System.Collections.IEnumerable)read).GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("a", en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("b", en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("c", en.Current);
Assert.IsFalse(en.MoveNext());
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings)
strings.Add("d")
Assert.AreEqual(3, read.Count)
Assert.IsTrue(read.Contains("a"))
Assert.AreEqual(0, read.IndexOf("a"))
Assert.IsTrue(read.Contains("b"))
Assert.AreEqual(1, read.IndexOf("b"))
Assert.IsTrue(read.Contains("c"))
Assert.AreEqual(2, read.IndexOf("c"))
Assert.IsFalse(read.Contains("d"))
Assert.AreEqual(-1, read.IndexOf("d"))
Assert.AreEqual("a,b,c", [String].Join(",", read.ToArray()))
Assert.AreEqual("a,b,c", [String].Join(",", New List(Of [String])(read).ToArray()))

Dim arcopy As String() = New String(3) {}
read.CopyTo(arcopy, 0)
Assert.AreEqual("a,b,c", [String].Join(",", arcopy))

Dim en As System.Collections.IEnumerator = (DirectCast(read, System.Collections.IEnumerable)).GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("a", en.Current)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("b", en.Current)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("c", en.Current)
Assert.IsFalse(en.MoveNext())

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : CopyTo Method

array
index

Glossary Item Box

Copy the elements in the collection to the specified array

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array As Array, _
   ByVal index As Integer _
)
C#
public void CopyTo(
   Array array,
   int index
)

Parameters

array
index

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings);
strings.Add("d");
Assert.AreEqual(3, read.Count);
Assert.IsTrue(read.Contains("a"));
Assert.AreEqual(0, read.IndexOf("a"));
Assert.IsTrue(read.Contains("b"));
Assert.AreEqual(1, read.IndexOf("b"));
Assert.IsTrue(read.Contains("c"));
Assert.AreEqual(2, read.IndexOf("c"));
Assert.IsFalse(read.Contains("d"));
Assert.AreEqual(-1, read.IndexOf("d"));
Assert.AreEqual("a,b,c", String.Join(",", read.ToArray()));
Assert.AreEqual("a,b,c", String.Join(",", new List<String>(read).ToArray()));

string[] arcopy = new string[3];
read.CopyTo(arcopy, 0);
Assert.AreEqual("a,b,c", String.Join(",", arcopy));

System.Collections.IEnumerator en = ((System.Collections.IEnumerable)read).GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("a", en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("b", en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("c", en.Current);
Assert.IsFalse(en.MoveNext());
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings)
strings.Add("d")
Assert.AreEqual(3, read.Count)
Assert.IsTrue(read.Contains("a"))
Assert.AreEqual(0, read.IndexOf("a"))
Assert.IsTrue(read.Contains("b"))
Assert.AreEqual(1, read.IndexOf("b"))
Assert.IsTrue(read.Contains("c"))
Assert.AreEqual(2, read.IndexOf("c"))
Assert.IsFalse(read.Contains("d"))
Assert.AreEqual(-1, read.IndexOf("d"))
Assert.AreEqual("a,b,c", [String].Join(",", read.ToArray()))
Assert.AreEqual("a,b,c", [String].Join(",", New List(Of [String])(read).ToArray()))

Dim arcopy As String() = New String(3) {}
read.CopyTo(arcopy, 0)
Assert.AreEqual("a,b,c", [String].Join(",", arcopy))

Dim en As System.Collections.IEnumerator = (DirectCast(read, System.Collections.IEnumerable)).GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("a", en.Current)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("b", en.Current)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("c", en.Current)
Assert.IsFalse(en.MoveNext())

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : GetEnumerator Method

Glossary Item Box

Returns an enumeration of the elements in the collection

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of T)
C#
public IEnumerator<T> GetEnumerator()

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members

Source Code

Library/Collections/ReadonlyList.cs

Used By

ReadOnlyList.CopyTo(Array,Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
IndexOf Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : IndexOf Method

item

Glossary Item Box

Returns the zero-based index of the item or -1 if not found.

Syntax

Visual Basic (Declaration)
Public Function IndexOf( _
   ByVal item As T _
) As Integer
C#
public int IndexOf(
   T item
)

Parameters

item

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings);
strings.Add("d");
Assert.AreEqual(3, read.Count);
Assert.IsTrue(read.Contains("a"));
Assert.AreEqual(0, read.IndexOf("a"));
Assert.IsTrue(read.Contains("b"));
Assert.AreEqual(1, read.IndexOf("b"));
Assert.IsTrue(read.Contains("c"));
Assert.AreEqual(2, read.IndexOf("c"));
Assert.IsFalse(read.Contains("d"));
Assert.AreEqual(-1, read.IndexOf("d"));
Assert.AreEqual("a,b,c", String.Join(",", read.ToArray()));
Assert.AreEqual("a,b,c", String.Join(",", new List<String>(read).ToArray()));

string[] arcopy = new string[3];
read.CopyTo(arcopy, 0);
Assert.AreEqual("a,b,c", String.Join(",", arcopy));

System.Collections.IEnumerator en = ((System.Collections.IEnumerable)read).GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("a", en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("b", en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("c", en.Current);
Assert.IsFalse(en.MoveNext());
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings)
strings.Add("d")
Assert.AreEqual(3, read.Count)
Assert.IsTrue(read.Contains("a"))
Assert.AreEqual(0, read.IndexOf("a"))
Assert.IsTrue(read.Contains("b"))
Assert.AreEqual(1, read.IndexOf("b"))
Assert.IsTrue(read.Contains("c"))
Assert.AreEqual(2, read.IndexOf("c"))
Assert.IsFalse(read.Contains("d"))
Assert.AreEqual(-1, read.IndexOf("d"))
Assert.AreEqual("a,b,c", [String].Join(",", read.ToArray()))
Assert.AreEqual("a,b,c", [String].Join(",", New List(Of [String])(read).ToArray()))

Dim arcopy As String() = New String(3) {}
read.CopyTo(arcopy, 0)
Assert.AreEqual("a,b,c", [String].Join(",", arcopy))

Dim en As System.Collections.IEnumerator = (DirectCast(read, System.Collections.IEnumerable)).GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("a", en.Current)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("b", en.Current)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("c", en.Current)
Assert.IsFalse(en.MoveNext())

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : ToArray Method

Glossary Item Box

Returns the collection as an array

Syntax

Visual Basic (Declaration)
Public Function ToArray() As T()
C#
public T[] ToArray()

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);

Assert.AreEqual(3, read.Count);
strings.RemoveAt(2);
Assert.AreEqual(2, read.Count);
Assert.AreEqual("a", read[0]);
Assert.AreEqual("b", read[1]);

Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray()));
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings, False)

Assert.AreEqual(3, read.Count)
strings.RemoveAt(2)
Assert.AreEqual(2, read.Count)
Assert.AreEqual("a", read(0))
Assert.AreEqual("b", read(1))

Assert.AreEqual("a,b", [String].Join(",", read.Clone().ToArray()))

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ReadOnlyList<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ReadOnlyList<T> Class

Glossary Item Box

For a list of all members of this type, see ReadOnlyList<T> members.

Public Properties

 | Name | Description
Public Property | Count | Returns the count of items contained in the collection
Public Property | Item | Returns the element at the given offset
Top

See Also

Reference

ReadOnlyList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : Count Property

Glossary Item Box

Returns the count of items contained in the collection

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);

Assert.AreEqual(3, read.Count);
strings.RemoveAt(2);
Assert.AreEqual(2, read.Count);
Assert.AreEqual("a", read[0]);
Assert.AreEqual("b", read[1]);

Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray()));
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings, False)

Assert.AreEqual(3, read.Count)
strings.RemoveAt(2)
Assert.AreEqual(2, read.Count)
Assert.AreEqual("a", read(0))
Assert.AreEqual("b", read(1))

Assert.AreEqual("a,b", [String].Join(",", read.Clone().ToArray()))

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ReadOnlyList<T> Class : Item Property

index

Glossary Item Box

Returns the element at the given offset

Syntax

Visual Basic (Declaration)
Public ReadOnly Default Property Item( _
   ByVal index As Integer _
) As T
C#
public T this[
   int index
]; {get;}

Parameters

index

Example

Library/Library.Test/TestReadOnlyList.cs

C# Copy Code
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);

Assert.AreEqual(3, read.Count);
strings.RemoveAt(2);
Assert.AreEqual(2, read.Count);
Assert.AreEqual("a", read[0]);
Assert.AreEqual("b", read[1]);

Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray()));
VB.NET Copy Code
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings, False)

Assert.AreEqual(3, read.Count)
strings.RemoveAt(2)
Assert.AreEqual(2, read.Count)
Assert.AreEqual("a", read(0))
Assert.AreEqual("b", read(1))

Assert.AreEqual("a,b", [String].Join(",", read.Clone().ToArray()))

Requirements

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

See Also

Reference

ReadOnlyList<T> Class
ReadOnlyList<T> Members

Source Code

Library/Collections/ReadonlyList.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
SetList<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SetList<T> Class

Glossary Item Box

Represents an immutable collection of unique items that can be manipulated as a set, intersect/union/etc.

Object Model

SetList<T> ClassT Class

Syntax

Visual Basic (Declaration)
Public Class SetList(Of T)
   Implements CSharpTest.Net.Interfaces.ICloneable(Of SetList(Of T))
C#
public class SetList<T> : CSharpTest.Net.Interfaces.ICloneable<SetList<T>>

Type Parameters

T

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NET Copy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.SetList<T>

Requirements

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

See Also

Reference

SetList<T> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SetList<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SetList<T> Class

Glossary Item Box

The following tables list the members exposed by SetList<T>.

Public Constructors

 | Name | Description
Public Constructor | SetList<T> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Count | Returns the count of items in the list
static (Shared in Visual Basic) | EmptySet | Provides an empty set
Public Property | IsReadOnly | Returns true if the list is read-only
Public Property | Item | Access an item by it's ordinal offset in the list
Top

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Returns a new collection adding the item provided
Public Method | AddRange | Adds a range of items to the collection
Public Method | Clear | Removes all items from the collection
Public Method | Clone | Returns a shallow clone of this object
Public Method | ComplementOf | Returns the items in the provided set that are not in this set
Public Method | Contains | Returns true if the item is already in the collection
Public Method | CopyTo | Copy the collection to an array
Public Method | ExclusiveOrWith | Returns the items in this set that are not in the provided set
Public Method | GetEnumerator | Returns a typed enumerator
Public Method | IndexOf | Returns the zero-based index of the item or -1
Public Method | IntersectWith | Returns the set of items that are in both this set and the provided set
Public Method | IsEqualTo | Returns true if all items in this set are also in the provided set
Public Method | IsSubsetOf | Returns true if all items in this set are also in the provided set
Public Method | IsSupersetOf | Returns true if all items in the provided set are also in this set
Public Method | Remove | Returns a new collection with the item provided removed
Public Method | RemoveAll | Removes the items in this set that are not in the provided set
Public Method | RemoveAt | Removes an item by it's ordinal index in the collection
Public Method | Replace | Adds or replaces an item in the collection, returns true if an entry was replaced
Public Method | ReplaceAll | Adds or replaces an item in the collection, returns true if any item was replaced
Public Method | SubtractSet | Returns the items in this set that are not in the provided set
Public Method | ToArray | Returns this collection as an array
Public Method | UnionWith | Returns the set of items that are in either this set or the provided set
Top

See Also

Reference

SetList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : SetList<T> Constructor

Glossary Item Box

Overload List

Overload | Description
SetList<T> Constructor() | Constructs a SetList
SetList<T> Constructor(IComparer<T>) | Constructs a SetList
SetList<T> Constructor(Int32) | Constructs a SetList
SetList<T> Constructor(Int32,IComparer<T>) | Constructs a SetList
SetList<T> Constructor(IEnumerable<T>) | Constructs a SetList
SetList<T> Constructor(ICollection<T>) | Constructs a SetList
SetList<T> Constructor(IEnumerable<T>,IComparer<T>) | Constructs a SetList
SetList<T> Constructor(ICollection<T>,IComparer<T>) | Constructs a SetList

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor()

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public SetList<T>()

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> list = new SetList<int>();
list.AddRange(new int[] { 5, 10, 20 });

ICollection coll = list;
Assert.IsFalse(coll.IsSynchronized);
Assert.IsTrue(Object.ReferenceEquals(coll, coll.SyncRoot));

int[] copy = new int[3];
coll.CopyTo(copy, 0);
Assert.AreEqual(5, copy[0]);
Assert.AreEqual(10, copy[1]);
Assert.AreEqual(20, copy[2]);

List<int> tmp = new List<int>();
foreach (int i in coll)
    tmp.Add(i);
Assert.AreEqual(3, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
Assert.AreEqual(20, tmp[2]);
VB.NET Copy Code
Dim list As New SetList(Of Integer)()
list.AddRange(New Integer() {5, 10, 20})

Dim coll As ICollection = list
Assert.IsFalse(coll.IsSynchronized)
Assert.IsTrue([Object].ReferenceEquals(coll, coll.SyncRoot))

Dim copy As Integer() = New Integer(3) {}
coll.CopyTo(copy, 0)
Assert.AreEqual(5, copy(0))
Assert.AreEqual(10, copy(1))
Assert.AreEqual(20, copy(2))

Dim tmp As New List(Of Integer)()
For Each i As Integer In coll
    tmp.Add(i)
Next
Assert.AreEqual(3, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))
Assert.AreEqual(20, tmp(2))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor(IComparer<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor(IComparer<T>)

comparer

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IComparer(Of T) _
)
C#
public SetList<T>(
   IComparer<T> comparer
)

Parameters

comparer

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
IList list = new SetList<string>(StringComparer.Ordinal);
Assert.AreEqual(0, list.Count);
list.Add("a");
Assert.AreEqual(1, list.Count);
list.Add("B");
Assert.AreEqual(2, list.Count);

Assert.AreEqual("B", list[0]);
Assert.AreEqual("a", list[1]);

Assert.IsTrue(list.Contains("a"));
Assert.IsFalse(list.Contains("A"));
Assert.IsFalse(list.Contains("b"));
Assert.IsTrue(list.Contains("B"));

Assert.AreEqual(0, list.IndexOf("B"));
Assert.AreEqual(1, list.IndexOf("a"));

list = new SetList<string>((IEnumerable<string>)list, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual(2, list.Count);
Assert.AreEqual("a", list[0]);
Assert.AreEqual("B", list[1]);

Assert.IsTrue(list.Contains("a"));
Assert.IsTrue(list.Contains("A"));
Assert.IsTrue(list.Contains("b"));
Assert.IsTrue(list.Contains("B"));

Assert.IsFalse(list.Contains(5));
Assert.IsTrue(list.IndexOf(5) < 0);

Assert.IsFalse(list.IsFixedSize);
list.Remove("b");
Assert.IsFalse(list.Contains("b"));
Assert.IsFalse(list.Contains("B"));

list = (IList)((ICloneable)list).Clone();
Assert.AreEqual(typeof(SetList<string>), list.GetType());
Assert.IsTrue(list.Contains("a"));
Assert.IsFalse(list.Contains("b"));
Assert.AreEqual(0, list.IndexOf("a"));
VB.NET Copy Code
Dim list As IList = New SetList(Of String)(StringComparer.Ordinal)
Assert.AreEqual(0, list.Count)
list.Add("a")
Assert.AreEqual(1, list.Count)
list.Add("B")
Assert.AreEqual(2, list.Count)

Assert.AreEqual("B", list(0))
Assert.AreEqual("a", list(1))

Assert.IsTrue(list.Contains("a"))
Assert.IsFalse(list.Contains("A"))
Assert.IsFalse(list.Contains("b"))
Assert.IsTrue(list.Contains("B"))

Assert.AreEqual(0, list.IndexOf("B"))
Assert.AreEqual(1, list.IndexOf("a"))

list = New SetList(Of String)(DirectCast(list, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual(2, list.Count)
Assert.AreEqual("a", list(0))
Assert.AreEqual("B", list(1))

Assert.IsTrue(list.Contains("a"))
Assert.IsTrue(list.Contains("A"))
Assert.IsTrue(list.Contains("b"))
Assert.IsTrue(list.Contains("B"))

Assert.IsFalse(list.Contains(5))
Assert.IsTrue(list.IndexOf(5) < 0)

Assert.IsFalse(list.IsFixedSize)
list.Remove("b")
Assert.IsFalse(list.Contains("b"))
Assert.IsFalse(list.Contains("B"))

list = DirectCast((DirectCast(list, ICloneable)).Clone(), IList)
Assert.AreEqual(GetType(SetList(Of String)), list.[GetType]())
Assert.IsTrue(list.Contains("a"))
Assert.IsFalse(list.Contains("b"))
Assert.AreEqual(0, list.IndexOf("a"))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor(Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor(Int32)

capacity

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal capacity As Integer _
)
C#
public SetList<T>(
   int capacity
)

Parameters

capacity

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NET Copy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor(Int32,IComparer<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor(Int32,IComparer<T>)

capacity
comparer

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal capacity As Integer, _
   ByVal comparer As IComparer(Of T) _
)
C#
public SetList<T>(
   int capacity,
   IComparer<T> comparer
)

Parameters

capacity
comparer

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NET Copy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor(IEnumerable<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor(IEnumerable<T>)

items

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal items As IEnumerable(Of T) _
)
C#
public SetList<T>(
   IEnumerable<T> items
)

Parameters

items

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NET Copy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor(ICollection<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor(ICollection<T>)

items

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal items As ICollection(Of T) _
)
C#
public SetList<T>(
   ICollection<T> items
)

Parameters

items

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs

Used By

Stream ReplaceFile.CreateDerivedFile(String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor(IEnumerable<T>,IComparer<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor(IEnumerable<T>,IComparer<T>)

items
comparer

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal items As IEnumerable(Of T), _
   ByVal comparer As IComparer(Of T) _
)
C#
public SetList<T>(
   IEnumerable<T> items,
   IComparer<T> comparer
)

Parameters

items
comparer

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NET Copy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetList<T> Constructor(ICollection<T>,IComparer<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > SetList<T> Constructor : SetList<T> Constructor(ICollection<T>,IComparer<T>)

items
comparer

Glossary Item Box

Constructs a SetList

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal items As ICollection(Of T), _
   ByVal comparer As IComparer(Of T) _
)
C#
public SetList<T>(
   ICollection<T> items,
   IComparer<T> comparer
)

Parameters

items
comparer

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NET Copy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SetList<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SetList<T> Class

Glossary Item Box

For a list of all members of this type, see SetList<T> members.

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Returns a new collection adding the item provided
Public Method | AddRange | Adds a range of items to the collection
Public Method | Clear | Removes all items from the collection
Public Method | Clone | Returns a shallow clone of this object
Public Method | ComplementOf | Returns the items in the provided set that are not in this set
Public Method | Contains | Returns true if the item is already in the collection
Public Method | CopyTo | Copy the collection to an array
Public Method | ExclusiveOrWith | Returns the items in this set that are not in the provided set
Public Method | GetEnumerator | Returns a typed enumerator
Public Method | IndexOf | Returns the zero-based index of the item or -1
Public Method | IntersectWith | Returns the set of items that are in both this set and the provided set
Public Method | IsEqualTo | Returns true if all items in this set are also in the provided set
Public Method | IsSubsetOf | Returns true if all items in this set are also in the provided set
Public Method | IsSupersetOf | Returns true if all items in the provided set are also in this set
Public Method | Remove | Returns a new collection with the item provided removed
Public Method | RemoveAll | Removes the items in this set that are not in the provided set
Public Method | RemoveAt | Removes an item by it's ordinal index in the collection
Public Method | Replace | Adds or replaces an item in the collection, returns true if an entry was replaced
Public Method | ReplaceAll | Adds or replaces an item in the collection, returns true if any item was replaced
Public Method | SubtractSet | Returns the items in this set that are not in the provided set
Public Method | ToArray | Returns this collection as an array
Public Method | UnionWith | Returns the set of items that are in either this set or the provided set
Top

See Also

Reference

SetList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Add Method

Glossary Item Box

Returns a new collection adding the item provided

Overload List

Overload | Description
Add(T) | Returns a new collection adding the item provided
Add(T,Int32) | Returns a new collection adding the item provided

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(T) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > Add Method : Add(T) Method

item

Glossary Item Box

Returns a new collection adding the item provided

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal item As T _
)
C#
public void Add(
   T item
)

Parameters

item

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NET Copy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(T,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class > Add Method : Add(T,Int32) Method

item
index

Glossary Item Box

Returns a new collection adding the item provided

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal item As T, _
   ByRef index As Integer _
)
C#
public void Add(
   T item,
   out int index
)

Parameters

item
index

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> list = new SetList<int>();
Assert.IsFalse(list.IsReadOnly);

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int pos;
list.Add(10, out pos);
Assert.AreEqual(1, pos);
Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New SetList(Of Integer)()
Assert.IsFalse(list.IsReadOnly)

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim pos As Integer
list.Add(10, pos)
Assert.AreEqual(1, pos)
Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members
Overload List

Used By

SetList.Add(T)

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : AddRange Method

other

Glossary Item Box

Adds a range of items to the collection

Syntax

Visual Basic (Declaration)
Public Sub AddRange( _
   ByVal other As IEnumerable(Of T) _
)
C#
public void AddRange(
   IEnumerable<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> list = new SetList<int>();
list.AddRange(new int[] { 5, 10, 20 });

ICollection coll = list;
Assert.IsFalse(coll.IsSynchronized);
Assert.IsTrue(Object.ReferenceEquals(coll, coll.SyncRoot));

int[] copy = new int[3];
coll.CopyTo(copy, 0);
Assert.AreEqual(5, copy[0]);
Assert.AreEqual(10, copy[1]);
Assert.AreEqual(20, copy[2]);

List<int> tmp = new List<int>();
foreach (int i in coll)
    tmp.Add(i);
Assert.AreEqual(3, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
Assert.AreEqual(20, tmp[2]);
VB.NET Copy Code
Dim list As New SetList(Of Integer)()
list.AddRange(New Integer() {5, 10, 20})

Dim coll As ICollection = list
Assert.IsFalse(coll.IsSynchronized)
Assert.IsTrue([Object].ReferenceEquals(coll, coll.SyncRoot))

Dim copy As Integer() = New Integer(3) {}
coll.CopyTo(copy, 0)
Assert.AreEqual(5, copy(0))
Assert.AreEqual(10, copy(1))
Assert.AreEqual(20, copy(2))

Dim tmp As New List(Of Integer)()
For Each i As Integer In coll
    tmp.Add(i)
Next
Assert.AreEqual(3, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))
Assert.AreEqual(20, tmp(2))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs

Used By

SetList SetList.UnionWith(SetList)


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Clear Method

Glossary Item Box

Removes all items from the collection

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> list = new SetList<int>();
Assert.IsFalse(list.IsReadOnly);

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int pos;
list.Add(10, out pos);
Assert.AreEqual(1, pos);
Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New SetList(Of Integer)()
Assert.IsFalse(list.IsReadOnly)

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim pos As Integer
list.Add(10, pos)
Assert.AreEqual(1, pos)
Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Clone Method

Glossary Item Box

Returns a shallow clone of this object

Syntax

Visual Basic (Declaration)
Public Function Clone() As SetList(Of T)
C#
public SetList<T> Clone()

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Used By

SetList SetList.UnionWith(SetList)

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ComplementOf Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : ComplementOf Method

other

Glossary Item Box

Returns the items in the provided set that are not in this set

Syntax

Visual Basic (Declaration)
Public Function ComplementOf( _
   ByVal other As SetList(Of T) _
) As SetList(Of T)
C#
public SetList<T> ComplementOf(
   SetList<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Contains Method

item

Glossary Item Box

Returns true if the item is already in the collection

Syntax

Visual Basic (Declaration)
Public Function Contains( _
   ByVal item As T _
) As Boolean
C#
public bool Contains(
   T item
)

Parameters

item

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Used By

HtmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Copy the collection to an array

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As T, _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   T[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> list = new SetList<int>();
Assert.IsFalse(list.IsReadOnly);

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int pos;
list.Add(10, out pos);
Assert.AreEqual(1, pos);
Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New SetList(Of Integer)()
Assert.IsFalse(list.IsReadOnly)

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim pos As Integer
list.Add(10, pos)
Assert.AreEqual(1, pos)
Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExclusiveOrWith Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : ExclusiveOrWith Method

other

Glossary Item Box

Returns the items in this set that are not in the provided set

Syntax

Visual Basic (Declaration)
Public Function ExclusiveOrWith( _
   ByVal other As SetList(Of T) _
) As SetList(Of T)
C#
public SetList<T> ExclusiveOrWith(
   SetList<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : GetEnumerator Method

Glossary Item Box

Returns a typed enumerator

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of T)
C#
public IEnumerator<T> GetEnumerator()

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int> union = lista.UnionWith(listb);
Assert.AreEqual(7, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

Assert.AreEqual(0, union.IndexOf(2));
Assert.AreEqual(6, union.IndexOf(20));

SetList<int> inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(10, i);
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim union As SetList(Of Integer) = lista.UnionWith(listb)
Assert.AreEqual(7, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Assert.AreEqual(0, union.IndexOf(2))
Assert.AreEqual(6, union.IndexOf(20))

Dim inter As SetList(Of Integer) = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(10, i)
Next

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IndexOf Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : IndexOf Method

item

Glossary Item Box

Returns the zero-based index of the item or -1

Syntax

Visual Basic (Declaration)
Public Function IndexOf( _
   ByVal item As T _
) As Integer
C#
public int IndexOf(
   T item
)

Parameters

item

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int> union = lista.UnionWith(listb);
Assert.AreEqual(7, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

Assert.AreEqual(0, union.IndexOf(2));
Assert.AreEqual(6, union.IndexOf(20));

SetList<int> inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(10, i);
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim union As SetList(Of Integer) = lista.UnionWith(listb)
Assert.AreEqual(7, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Assert.AreEqual(0, union.IndexOf(2))
Assert.AreEqual(6, union.IndexOf(20))

Dim inter As SetList(Of Integer) = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(10, i)
Next

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IntersectWith Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : IntersectWith Method

other

Glossary Item Box

Returns the set of items that are in both this set and the provided set

Syntax

Visual Basic (Declaration)
Public Function IntersectWith( _
   ByVal other As SetList(Of T) _
) As SetList(Of T)
C#
public SetList<T> IntersectWith(
   SetList<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int> union = lista.UnionWith(listb);
Assert.AreEqual(7, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

Assert.AreEqual(0, union.IndexOf(2));
Assert.AreEqual(6, union.IndexOf(20));

SetList<int> inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(10, i);
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim union As SetList(Of Integer) = lista.UnionWith(listb)
Assert.AreEqual(7, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Assert.AreEqual(0, union.IndexOf(2))
Assert.AreEqual(6, union.IndexOf(20))

Dim inter As SetList(Of Integer) = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(10, i)
Next

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsEqualTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : IsEqualTo Method

other

Glossary Item Box

Returns true if all items in this set are also in the provided set

Syntax

Visual Basic (Declaration)
Public Function IsEqualTo( _
   ByVal other As SetList(Of T) _
) As Boolean
C#
public bool IsEqualTo(
   SetList<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsSubsetOf Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : IsSubsetOf Method

other

Glossary Item Box

Returns true if all items in this set are also in the provided set

Syntax

Visual Basic (Declaration)
Public Function IsSubsetOf( _
   ByVal other As SetList(Of T) _
) As Boolean
C#
public bool IsSubsetOf(
   SetList<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsSupersetOf Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : IsSupersetOf Method

other

Glossary Item Box

Returns true if all items in the provided set are also in this set

Syntax

Visual Basic (Declaration)
Public Function IsSupersetOf( _
   ByVal other As SetList(Of T) _
) As Boolean
C#
public bool IsSupersetOf(
   SetList<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Remove Method

item

Glossary Item Box

Returns a new collection with the item provided removed

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal item As T _
) As Boolean
C#
public bool Remove(
   T item
)

Parameters

item

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> list = new SetList<int>();
Assert.IsFalse(list.IsReadOnly);

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int pos;
list.Add(10, out pos);
Assert.AreEqual(1, pos);
Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New SetList(Of Integer)()
Assert.IsFalse(list.IsReadOnly)

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim pos As Integer
list.Add(10, pos)
Assert.AreEqual(1, pos)
Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RemoveAll Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : RemoveAll Method

other

Glossary Item Box

Removes the items in this set that are not in the provided set

Syntax

Visual Basic (Declaration)
Public Sub RemoveAll( _
   ByVal other As IEnumerable(Of T) _
)
C#
public void RemoveAll(
   IEnumerable<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RemoveAt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : RemoveAt Method

index

Glossary Item Box

Removes an item by it's ordinal index in the collection

Syntax

Visual Basic (Declaration)
Public Sub RemoveAt( _
   ByVal index As Integer _
)
C#
public void RemoveAt(
   int index
)

Parameters

index

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Used By

Boolean SetList.Remove(T)

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Replace Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Replace Method

item

Glossary Item Box

Adds or replaces an item in the collection, returns true if an entry was replaced

Syntax

Visual Basic (Declaration)
Public Function Replace( _
   ByVal item As T _
) As Boolean
C#
public bool Replace(
   T item
)

Parameters

item

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
MyValue one = new MyValue(1);
MyValue two = new MyValue(2);
SetList<MyValue> set = new SetList<MyValue>();
set.Add(one);
set.Add(two);

Assert.IsTrue(Object.ReferenceEquals(one, set[0]));
Assert.IsTrue(set.Replace(new MyValue(1)));
Assert.IsFalse(Object.ReferenceEquals(one, set[0]));

Assert.AreEqual(2, set.Count);
Assert.IsFalse(set.Replace(new MyValue(3))); //not replaced, then added
Assert.AreEqual(3, set.Count);
VB.NET Copy Code
Dim one As New MyValue(1)
Dim two As New MyValue(2)
Dim [set] As New SetList(Of MyValue)()
[set].Add(one)
[set].Add(two)

Assert.IsTrue([Object].ReferenceEquals(one, [set](0)))
Assert.IsTrue([set].Replace(New MyValue(1)))
Assert.IsFalse([Object].ReferenceEquals(one, [set](0)))

Assert.AreEqual(2, [set].Count)
Assert.IsFalse([set].Replace(New MyValue(3)))
'not replaced, then added
Assert.AreEqual(3, [set].Count)

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplaceAll Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : ReplaceAll Method

items

Glossary Item Box

Adds or replaces an item in the collection, returns true if any item was replaced

Syntax

Visual Basic (Declaration)
Public Function ReplaceAll( _
   ByVal items As IEnumerable(Of T) _
) As Boolean
C#
public bool ReplaceAll(
   IEnumerable<T> items
)

Parameters

items

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
MyValue one = new MyValue(1);
MyValue two = new MyValue(2);
SetList<MyValue> set = new SetList<MyValue>();
set.Add(one);
set.Add(two);

Assert.AreEqual(2, set.Count);
Assert.IsTrue(Object.ReferenceEquals(one, set[0]));
Assert.IsTrue(set.ReplaceAll(new MyValue[] { new MyValue(1), new MyValue(3) }));
Assert.IsFalse(Object.ReferenceEquals(one, set[0]));
Assert.AreEqual(3, set.Count);
VB.NET Copy Code
Dim one As New MyValue(1)
Dim two As New MyValue(2)
Dim [set] As New SetList(Of MyValue)()
[set].Add(one)
[set].Add(two)

Assert.AreEqual(2, [set].Count)
Assert.IsTrue([Object].ReferenceEquals(one, [set](0)))
Assert.IsTrue([set].ReplaceAll(New MyValue() {New MyValue(1), New MyValue(3)}))
Assert.IsFalse([Object].ReferenceEquals(one, [set](0)))
Assert.AreEqual(3, [set].Count)

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SubtractSet Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : SubtractSet Method

other

Glossary Item Box

Returns the items in this set that are not in the provided set

Syntax

Visual Basic (Declaration)
Public Function SubtractSet( _
   ByVal other As SetList(Of T) _
) As SetList(Of T)
C#
public SetList<T> SubtractSet(
   SetList<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));

SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : ToArray Method

Glossary Item Box

Returns this collection as an array

Syntax

Visual Basic (Declaration)
Public Function ToArray() As T()
C#
public T[] ToArray()

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NET Copy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UnionWith Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : UnionWith Method

other

Glossary Item Box

Returns the set of items that are in either this set or the provided set

Syntax

Visual Basic (Declaration)
Public Function UnionWith( _
   ByVal other As SetList(Of T) _
) As SetList(Of T)
C#
public SetList<T> UnionWith(
   SetList<T> other
)

Parameters

other

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int> union = lista.UnionWith(listb);
Assert.AreEqual(7, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

Assert.AreEqual(0, union.IndexOf(2));
Assert.AreEqual(6, union.IndexOf(20));

SetList<int> inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(10, i);
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim union As SetList(Of Integer) = lista.UnionWith(listb)
Assert.AreEqual(7, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Assert.AreEqual(0, union.IndexOf(2))
Assert.AreEqual(6, union.IndexOf(20))

Dim inter As SetList(Of Integer) = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(10, i)
Next

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SetList<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SetList<T> Class

Glossary Item Box

For a list of all members of this type, see SetList<T> members.

Public Properties

 | Name | Description
Public Property | Count | Returns the count of items in the list
static (Shared in Visual Basic) | EmptySet | Provides an empty set
Public Property | IsReadOnly | Returns true if the list is read-only
Public Property | Item | Access an item by it's ordinal offset in the list
Top

See Also

Reference

SetList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Count Property

Glossary Item Box

Returns the count of items in the list

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int> union = lista.UnionWith(listb);
Assert.AreEqual(7, union.Count);
foreach (int i in union)
    Assert.IsTrue(lista.Contains(i) || listb.Contains(i));

Assert.AreEqual(0, union.IndexOf(2));
Assert.AreEqual(6, union.IndexOf(20));

SetList<int> inter = lista.IntersectWith(listb);
Assert.AreEqual(1, inter.Count);
foreach (int i in inter)
    Assert.AreEqual(10, i);
VB.NET Copy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim union As SetList(Of Integer) = lista.UnionWith(listb)
Assert.AreEqual(7, union.Count)
For Each i As Integer In union
    Assert.IsTrue(lista.Contains(i) OrElse listb.Contains(i))
Next

Assert.AreEqual(0, union.IndexOf(2))
Assert.AreEqual(6, union.IndexOf(20))

Dim inter As SetList(Of Integer) = lista.IntersectWith(listb)
Assert.AreEqual(1, inter.Count)
For Each i As Integer In inter
    Assert.AreEqual(10, i)
Next

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs

Used By

Stream ReplaceFile.CreateDerivedFile(String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
EmptySet Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : EmptySet Property

Glossary Item Box

Provides an empty set

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property EmptySet As SetList(Of T)
C#
public static SetList<T> EmptySet {get;}

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReadOnly Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : IsReadOnly Property

Glossary Item Box

Returns true if the list is read-only

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReadOnly As Boolean
C#
public bool IsReadOnly {get;}

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
SetList<int> list = new SetList<int>();
Assert.IsFalse(list.IsReadOnly);

for (int i = 512; i >= 0; i--)
    list.Add(i);

int offset = 0;
foreach (int item in list)
    Assert.AreEqual(offset++, item);

Assert.AreEqual(513, offset);
Assert.AreEqual(513, list.Count);

list.Clear();
list.AddRange(new int[] { 5, 10, 20 });
list.AddRange(new int[] { });

Assert.AreEqual(3, list.Count);

Assert.IsTrue(list.Contains(20));
Assert.IsTrue(list.Remove(20));

Assert.IsFalse(list.Contains(20));
Assert.IsFalse(list.Remove(20));

Assert.AreEqual(2, list.Count);

int pos;
list.Add(10, out pos);
Assert.AreEqual(1, pos);
Assert.AreEqual(2, list.Count);

int[] items = new int[2];
list.CopyTo(items, 0);
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

items = list.ToArray();
Assert.AreEqual(5, items[0]);
Assert.AreEqual(10, items[1]);

List<int> tmp = new List<int>();
foreach (int i in list)
    tmp.Add(i);
Assert.AreEqual(2, tmp.Count);
Assert.AreEqual(5, tmp[0]);
Assert.AreEqual(10, tmp[1]);
VB.NET Copy Code
Dim list As New SetList(Of Integer)()
Assert.IsFalse(list.IsReadOnly)

Dim i As Integer = 512
While i >= 0
    list.Add(i)
    System.Math.Max(System.Threading.Interlocked.Decrement(i),i + 1)
End While

Dim offset As Integer = 0
For Each item As Integer In list
    Assert.AreEqual(System.Math.Max(System.Threading.Interlocked.Increment(offset),offset - 1), item)
Next

Assert.AreEqual(513, offset)
Assert.AreEqual(513, list.Count)

list.Clear()
list.AddRange(New Integer() {5, 10, 20})
list.AddRange(New Integer() {})

Assert.AreEqual(3, list.Count)

Assert.IsTrue(list.Contains(20))
Assert.IsTrue(list.Remove(20))

Assert.IsFalse(list.Contains(20))
Assert.IsFalse(list.Remove(20))

Assert.AreEqual(2, list.Count)

Dim pos As Integer
list.Add(10, pos)
Assert.AreEqual(1, pos)
Assert.AreEqual(2, list.Count)

Dim items As Integer() = New Integer(2) {}
list.CopyTo(items, 0)
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

items = list.ToArray()
Assert.AreEqual(5, items(0))
Assert.AreEqual(10, items(1))

Dim tmp As New List(Of Integer)()
For Each i As Integer In list
    tmp.Add(i)
Next
Assert.AreEqual(2, tmp.Count)
Assert.AreEqual(5, tmp(0))
Assert.AreEqual(10, tmp(1))

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Item Property

index

Glossary Item Box

Access an item by it's ordinal offset in the list

Syntax

Visual Basic (Declaration)
Public Default Property Item( _
   ByVal index As Integer _
) As T
C#
public T this[
   int index
]; {get; set;}

Parameters

index

Example

Library/Library.Test/TestSetList.cs

C# Copy Code
MyValue one = new MyValue(1);
MyValue two = new MyValue(2);
SetList<MyValue> set = new SetList<MyValue>();
set.Add(one);
set.Add(two);

Assert.AreEqual(2, set.Count);
Assert.IsTrue(Object.ReferenceEquals(one, set[0]));
Assert.IsTrue(set.ReplaceAll(new MyValue[] { new MyValue(1), new MyValue(3) }));
Assert.IsFalse(Object.ReferenceEquals(one, set[0]));
Assert.AreEqual(3, set.Count);
VB.NET Copy Code
Dim one As New MyValue(1)
Dim two As New MyValue(2)
Dim [set] As New SetList(Of MyValue)()
[set].Add(one)
[set].Add(two)

Assert.AreEqual(2, [set].Count)
Assert.IsTrue([Object].ReferenceEquals(one, [set](0)))
Assert.IsTrue([set].ReplaceAll(New MyValue() {New MyValue(1), New MyValue(3)}))
Assert.IsFalse([Object].ReferenceEquals(one, [set](0)))
Assert.AreEqual(3, [set].Count)

Requirements

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

See Also

Reference

SetList<T> Class
SetList<T> Members

Source Code

Library/Collections/SetList.cs

Used By

Stream ReplaceFile.CreateDerivedFile(String,String)


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SynchronizedDictionary<TKey,TValue> Class

Glossary Item Box

Represents a thread-safe generic collection of key/value pairs.

Object Model

SynchronizedDictionary<TKey,TValue> ClassTValue Class

Syntax

Visual Basic (Declaration)
Public Class SynchronizedDictionary
    (Of TKey,TValue)
   Implements IConcurrentDictionary(Of TKey,TValue), IDictionaryEx(Of TKey,TValue)
C#
public class SynchronizedDictionary<TKey,TValue> : IConcurrentDictionary<TKey,TValue>, IDictionaryEx<TKey,TValue>

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.SynchronizedDictionary<TKey,TValue>

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SynchronizedDictionary<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by SynchronizedDictionary<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | SynchronizedDictionary<TKey,TValue> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | IsReadOnly | Gets a value indicating whether the ICollection is read-only.
Public Property | Item | Gets or sets the element with the specified key.
Public Property | Keys | Gets an ICollection containing the keys of the IDictionary.
Public Property | Lock | Exposes the interal lock so that you can syncronize several calls
Public Property | Values | Gets an ICollection containing the values in the IDictionary.
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an element with the provided key and value to the IDictionary.
Public Method | AddOrUpdate | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
Public Method | Clear | Removes all items from the ICollection.
Public Method | ContainsKey | Determines whether the IDictionary contains an element with the specified key.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | Dispose | Defines a method to release allocated resources.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | GetOrAdd | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist.
Public Method | Remove | Removes the element with the specified key from the IDictionary.
Public Method | ReplaceStorage | Locks the collection and replaces the underlying storage dictionary.
Public Method | TryAdd | Overloaded. Adds an element with the provided key and value to the IDictionary.
Public Method | TryGetValue | Gets the value associated with the specified key.
Public Method | TryRemove | Overloaded. Removes the element with the specified key from the IDictionary.
Public Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Top

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : SynchronizedDictionary<TKey,TValue> Constructor

Glossary Item Box

Overload List

Overload | Description
SynchronizedDictionary<TKey,TValue> Constructor() | Constructs a thread-safe generic collection of key/value pairs using exclusive locking.
SynchronizedDictionary<TKey,TValue> Constructor(IEqualityComparer<TKey>) | Constructs a thread-safe generic collection of key/value pairs using exclusive locking.
SynchronizedDictionary<TKey,TValue> Constructor(IEqualityComparer<TKey>,ILockStrategy) | Constructs a thread-safe generic collection of key/value pairs using the lock provided.
SynchronizedDictionary<TKey,TValue> Constructor(ILockStrategy) | Constructs a thread-safe generic collection of key/value pairs using the lock provided.
SynchronizedDictionary<TKey,TValue> Constructor(IDictionary<TKey,TValue>) | Constructs a thread-safe generic collection of key/value pairs using the default locking type for exclusive access, akin to placing lock(this) around each call. If you want to allow reader/writer locking provide one of those lock types from the Synchronization namespace.
SynchronizedDictionary<TKey,TValue> Constructor(IDictionary<TKey,TValue>,ILockStrategy) | Constructs a thread-safe generic collection of key/value pairs.

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > SynchronizedDictionary<TKey,TValue> Constructor : SynchronizedDictionary<TKey,TValue> Constructor()

Glossary Item Box

Constructs a thread-safe generic collection of key/value pairs using exclusive locking.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public SynchronizedDictionary<TKey,TValue>()

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Constructor(IEqualityComparer<TKey>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > SynchronizedDictionary<TKey,TValue> Constructor : SynchronizedDictionary<TKey,TValue> Constructor(IEqualityComparer<TKey>)

comparer

Glossary Item Box

Constructs a thread-safe generic collection of key/value pairs using exclusive locking.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IEqualityComparer(Of TKey) _
)
C#
public SynchronizedDictionary<TKey,TValue>(
   IEqualityComparer<TKey> comparer
)

Parameters

comparer

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<string, string> test = new SynchronizedDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
test["a"] = "b";
Assert.IsTrue(test.ContainsKey("A"));

test = new SynchronizedDictionary<string, string>(StringComparer.OrdinalIgnoreCase, new IgnoreLocking());
test["a"] = "b";
Assert.IsTrue(test.ContainsKey("A"));
VB.NET Copy Code
Dim test As New SynchronizedDictionary(Of String, String)(StringComparer.OrdinalIgnoreCase)
test("a") = "b"
Assert.IsTrue(test.ContainsKey("A"))

test = New SynchronizedDictionary(Of String, String)(StringComparer.OrdinalIgnoreCase, New IgnoreLocking())
test("a") = "b"
Assert.IsTrue(test.ContainsKey("A"))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Constructor(IEqualityComparer<TKey>,ILockStrategy)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > SynchronizedDictionary<TKey,TValue> Constructor : SynchronizedDictionary<TKey,TValue> Constructor(IEqualityComparer<TKey>,ILockStrategy)

comparer
locking

Glossary Item Box

Constructs a thread-safe generic collection of key/value pairs using the lock provided.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As IEqualityComparer(Of TKey), _
   ByVal locking As ILockStrategy _
)
C#
public SynchronizedDictionary<TKey,TValue>(
   IEqualityComparer<TKey> comparer,
   ILockStrategy locking
)

Parameters

comparer
locking

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<string, string> test = new SynchronizedDictionary<string, string>(StringComparer.Ordinal, new IgnoreLocking());
test["a"] = "b";
Assert.AreEqual(1, test.Count);
test.ReplaceStorage(new Dictionary<string, string>());
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim test As New SynchronizedDictionary(Of String, String)(StringComparer.Ordinal, New IgnoreLocking())
test("a") = "b"
Assert.AreEqual(1, test.Count)
test.ReplaceStorage(New Dictionary(Of String, String)())
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Constructor(ILockStrategy)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > SynchronizedDictionary<TKey,TValue> Constructor : SynchronizedDictionary<TKey,TValue> Constructor(ILockStrategy)

locking

Glossary Item Box

Constructs a thread-safe generic collection of key/value pairs using the lock provided.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal locking As ILockStrategy _
)
C#
public SynchronizedDictionary<TKey,TValue>(
   ILockStrategy locking
)

Parameters

locking

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Constructor(IDictionary<TKey,TValue>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > SynchronizedDictionary<TKey,TValue> Constructor : SynchronizedDictionary<TKey,TValue> Constructor(IDictionary<TKey,TValue>)

storage

Glossary Item Box

Constructs a thread-safe generic collection of key/value pairs using the default locking type for exclusive access, akin to placing lock(this) around each call. If you want to allow reader/writer locking provide one of those lock types from the Synchronization namespace.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal storage As IDictionary(Of TKey,TValue) _
)
C#
public SynchronizedDictionary<TKey,TValue>(
   IDictionary<TKey,TValue> storage
)

Parameters

storage

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Constructor(IDictionary<TKey,TValue>,ILockStrategy)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > SynchronizedDictionary<TKey,TValue> Constructor : SynchronizedDictionary<TKey,TValue> Constructor(IDictionary<TKey,TValue>,ILockStrategy)

storage
locking

Glossary Item Box

Constructs a thread-safe generic collection of key/value pairs.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal storage As IDictionary(Of TKey,TValue), _
   ByVal locking As ILockStrategy _
)
C#
public SynchronizedDictionary<TKey,TValue>(
   IDictionary<TKey,TValue> storage,
   ILockStrategy locking
)

Parameters

storage
locking

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<string, string> test = new SynchronizedDictionary<string, string>(new Dictionary<string,string>(), new IgnoreLocking());
test["a"] = "b";
string all = String.Join("", new List<string>(test.Keys).ToArray());
Assert.AreEqual("a", all);
VB.NET Copy Code
Dim test As New SynchronizedDictionary(Of String, String)(New Dictionary(Of String, String)(), New IgnoreLocking())
test("a") = "b"
Dim all As String = [String].Join("", New List(Of String)(test.Keys).ToArray())
Assert.AreEqual("a", all)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SynchronizedDictionary<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see SynchronizedDictionary<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Add | Adds an element with the provided key and value to the IDictionary.
Public Method | AddOrUpdate | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
Public Method | Clear | Removes all items from the ICollection.
Public Method | ContainsKey | Determines whether the IDictionary contains an element with the specified key.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | Dispose | Defines a method to release allocated resources.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | GetOrAdd | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist.
Public Method | Remove | Removes the element with the specified key from the IDictionary.
Public Method | ReplaceStorage | Locks the collection and replaces the underlying storage dictionary.
Public Method | TryAdd | Overloaded. Adds an element with the provided key and value to the IDictionary.
Public Method | TryGetValue | Gets the value associated with the specified key.
Public Method | TryRemove | Overloaded. Removes the element with the specified key from the IDictionary.
Public Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Top

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Add Method

key
value

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Public Sub Add( _
   ByVal key As TKey, _
   ByVal value As TValue _
)
C#
public void Add(
   TKey key,
   TValue value
)

Parameters

key
value

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : AddOrUpdate Method

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Overload List

Overload | Description
AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
AddOrUpdate<T>(TKey,T) | Add, update, or fetche a key/value pair from the dictionary via an implementation of the ICreateOrUpdateValue<TKey,TValue> interface.

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > AddOrUpdate Method : AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) Method

key
addValue
fnUpdate

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddOrUpdate( _
   ByVal key As TKey, _
   ByVal addValue As TValue, _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As TValue
C#
public TValue AddOrUpdate(
   TKey key,
   TValue addValue,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
addValue
fnUpdate

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());
Assert.AreEqual("a", data.AddOrUpdate(1, "a", (k, v) => k.ToString()));
Assert.AreEqual("1", data.AddOrUpdate(1, "a", (k, v) => k.ToString()));

Assert.AreEqual("b", data.AddOrUpdate(2, k => "b", (k, v) => k.ToString()));
Assert.AreEqual("2", data.AddOrUpdate(2, k => "b", (k, v) => k.ToString()));
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())
Assert.AreEqual("a", data.AddOrUpdate(1, "a", Function(k, v) k.ToString()))
Assert.AreEqual("1", data.AddOrUpdate(1, "a", Function(k, v) k.ToString()))

Assert.AreEqual("b", data.AddOrUpdate(2, Function(k) "b", Function(k, v) k.ToString()))
Assert.AreEqual("2", data.AddOrUpdate(2, Function(k) "b", Function(k, v) k.ToString()))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > AddOrUpdate Method : AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) Method

key
fnCreate
fnUpdate

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddOrUpdate( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue), _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As TValue
C#
public TValue AddOrUpdate(
   TKey key,
   Converter<TKey,TValue> fnCreate,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
fnCreate
fnUpdate

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());
Assert.AreEqual("a", data.AddOrUpdate(1, "a", (k, v) => k.ToString()));
Assert.AreEqual("1", data.AddOrUpdate(1, "a", (k, v) => k.ToString()));

Assert.AreEqual("b", data.AddOrUpdate(2, k => "b", (k, v) => k.ToString()));
Assert.AreEqual("2", data.AddOrUpdate(2, k => "b", (k, v) => k.ToString()));
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())
Assert.AreEqual("a", data.AddOrUpdate(1, "a", Function(k, v) k.ToString()))
Assert.AreEqual("1", data.AddOrUpdate(1, "a", Function(k, v) k.ToString()))

Assert.AreEqual("b", data.AddOrUpdate(2, Function(k) "b", Function(k, v) k.ToString()))
Assert.AreEqual("2", data.AddOrUpdate(2, Function(k) "b", Function(k, v) k.ToString()))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
AddOrUpdate<T>(TKey,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > AddOrUpdate Method : AddOrUpdate<T>(TKey,T) Method

key
createOrUpdateValue

Glossary Item Box

Add, update, or fetche a key/value pair from the dictionary via an implementation of the ICreateOrUpdateValue<TKey,TValue> interface.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddOrUpdate(Of T As ICreateOrUpdateValue(Of TKey,TValue))( _
   ByVal key As TKey, _
   ByRef createOrUpdateValue As T _
) As Boolean
C#
public bool AddOrUpdate<T>(
   TKey key,
   ref T createOrUpdateValue
)
where T: ICreateOrUpdateValue<TKey,TValue>

Parameters

key
createOrUpdateValue

Type Parameters

T

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Clear Method

Glossary Item Box

Removes all items from the ICollection.

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContainsKey Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : ContainsKey Method

key

Glossary Item Box

Determines whether the IDictionary contains an element with the specified key.

Syntax

Visual Basic (Declaration)
Public Function ContainsKey( _
   ByVal key As TKey _
) As Boolean
C#
public bool ContainsKey(
   TKey key
)

Parameters

key

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As KeyValuePair(Of TKey,TValue), _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   KeyValuePair<TKey,TValue>[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Dispose Method

Glossary Item Box

Defines a method to release allocated resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of KeyValuePair(Of TKey,TValue))
C#
public IEnumerator<KeyValuePair<TKey,TValue>> GetEnumerator()

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : GetOrAdd Method

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Overload List

Overload | Description
GetOrAdd(TKey,TValue) | Adds a key/value pair to the IDictionary if the key does not already exist.
GetOrAdd(TKey,Converter<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist.

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > GetOrAdd Method : GetOrAdd(TKey,TValue) Method

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As TValue
C#
public TValue GetOrAdd(
   TKey key,
   TValue value
)

Parameters

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());
Assert.AreEqual("a", data.GetOrAdd(1, "a"));
Assert.AreEqual("a", data.GetOrAdd(1, "b"));

Assert.AreEqual("b", data.GetOrAdd(2, k => "b"));
Assert.AreEqual("b", data.GetOrAdd(2, k => "c"));
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())
Assert.AreEqual("a", data.GetOrAdd(1, "a"))
Assert.AreEqual("a", data.GetOrAdd(1, "b"))

Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "b"))
Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "c"))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd(TKey,Converter<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > GetOrAdd Method : GetOrAdd(TKey,Converter<TKey,TValue>) Method

key
The key of the element to add.
fnCreate
Constructs a new value for the key.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue) _
) As TValue
C#
public TValue GetOrAdd(
   TKey key,
   Converter<TKey,TValue> fnCreate
)

Parameters

key
The key of the element to add.
fnCreate
Constructs a new value for the key.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());
Assert.AreEqual("a", data.GetOrAdd(1, "a"));
Assert.AreEqual("a", data.GetOrAdd(1, "b"));

Assert.AreEqual("b", data.GetOrAdd(2, k => "b"));
Assert.AreEqual("b", data.GetOrAdd(2, k => "c"));
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())
Assert.AreEqual("a", data.GetOrAdd(1, "a"))
Assert.AreEqual("a", data.GetOrAdd(1, "b"))

Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "b"))
Assert.AreEqual("b", data.GetOrAdd(2, Function(k) "c"))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Remove Method

key

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal key As TKey _
) As Boolean
C#
public bool Remove(
   TKey key
)

Parameters

key

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplaceStorage Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : ReplaceStorage Method

newStorage

Glossary Item Box

Locks the collection and replaces the underlying storage dictionary.

Syntax

Visual Basic (Declaration)
Public Function ReplaceStorage( _
   ByVal newStorage As IDictionary(Of TKey,TValue) _
) As IDictionary(Of TKey,TValue)
C#
public IDictionary<TKey,TValue> ReplaceStorage(
   IDictionary<TKey,TValue> newStorage
)

Parameters

newStorage

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<string, string> test = new SynchronizedDictionary<string, string>(StringComparer.Ordinal, new IgnoreLocking());
test["a"] = "b";
Assert.AreEqual(1, test.Count);
test.ReplaceStorage(new Dictionary<string, string>());
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim test As New SynchronizedDictionary(Of String, String)(StringComparer.Ordinal, New IgnoreLocking())
test("a") = "b"
Assert.AreEqual(1, test.Count)
test.ReplaceStorage(New Dictionary(Of String, String)())
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : TryAdd Method

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Overload List

Overload | Description
TryAdd(TKey,TValue) | Adds an element with the provided key and value to the IDictionary.
TryAdd(TKey,Converter<TKey,TValue>) | Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > TryAdd Method : TryAdd(TKey,TValue) Method

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
public bool TryAdd(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd(TKey,Converter<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > TryAdd Method : TryAdd(TKey,Converter<TKey,TValue>) Method

key
fnCreate

Glossary Item Box

Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryAdd( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue) _
) As Boolean
C#
public bool TryAdd(
   TKey key,
   Converter<TKey,TValue> fnCreate
)

Parameters

key
fnCreate

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : TryGetValue Method

key
value

Glossary Item Box

Gets the value associated with the specified key.

Syntax

Visual Basic (Declaration)
Public Function TryGetValue( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
public bool TryGetValue(
   TKey key,
   out TValue value
)

Parameters

key
value

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : TryRemove Method

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Overload List

Overload | Description
TryRemove(TKey,TValue) | Removes the element with the specified key from the IDictionary.
TryRemove(TKey,KeyValuePredicate<TKey,TValue>) | Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.
TryRemove<T>(TKey,T) | Conditionally removes a key/value pair from the dictionary via an implementation of the IRemoveValue<TKey,TValue> interface.

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > TryRemove Method : TryRemove(TKey,TValue) Method

key
The key of the element to remove.
value
The value that was removed.

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
public bool TryRemove(
   TKey key,
   out TValue value
)

Parameters

key
The key of the element to remove.
value
The value that was removed.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove(TKey,KeyValuePredicate<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > TryRemove Method : TryRemove(TKey,KeyValuePredicate<TKey,TValue>) Method

key
fnCondition

Glossary Item Box

Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove( _
   ByVal key As TKey, _
   ByVal fnCondition As CSharpTest.Net.Collections.KeyValuePredicate(Of TKey,TValue) _
) As Boolean
C#
public bool TryRemove(
   TKey key,
   CSharpTest.Net.Collections.KeyValuePredicate<TKey,TValue> fnCondition
)

Parameters

key
fnCondition

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List
KeyValuePredicate

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
TryRemove<T>(TKey,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > TryRemove Method : TryRemove<T>(TKey,T) Method

key
removeValue

Glossary Item Box

Conditionally removes a key/value pair from the dictionary via an implementation of the IRemoveValue<TKey,TValue> interface.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryRemove(Of T As IRemoveValue(Of TKey,TValue))( _
   ByVal key As TKey, _
   ByRef removeValue As T _
) As Boolean
C#
public bool TryRemove<T>(
   TKey key,
   ref T removeValue
)
where T: IRemoveValue<TKey,TValue>

Parameters

key
removeValue

Type Parameters

T

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : TryUpdate Method

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Overload List

Overload | Description
TryUpdate(TKey,TValue) | Updates an element with the provided key to the value if it exists.
TryUpdate(TKey,TValue,TValue) | Updates an element with the provided key to the value if it exists.
TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) | Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the tree lock. Be cautious about the behavior and performance of the code provided as it can cause a dead-lock to occur. If the method returns an instance who .Equals the original, no update is applied.

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Return Value

Returns true if the key provided was found and updated to the value.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue,TValue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,TValue,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue, _
   ByVal comparisonValue As TValue _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   TValue value,
   TValue comparisonValue
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Return Value

Returns true if the key provided was found and updated to the value.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class > TryUpdate Method : TryUpdate(TKey,KeyValueUpdate<TKey,TValue>) Method

key
fnUpdate

Glossary Item Box

Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the tree lock. Be cautious about the behavior and performance of the code provided as it can cause a dead-lock to occur. If the method returns an instance who .Equals the original, no update is applied.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As Boolean
C#
public bool TryUpdate(
   TKey key,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
fnUpdate

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SynchronizedDictionary<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SynchronizedDictionary<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see SynchronizedDictionary<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | IsReadOnly | Gets a value indicating whether the ICollection is read-only.
Public Property | Item | Gets or sets the element with the specified key.
Public Property | Keys | Gets an ICollection containing the keys of the IDictionary.
Public Property | Lock | Exposes the interal lock so that you can syncronize several calls
Public Property | Values | Gets an ICollection containing the values in the IDictionary.
Top

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Count Property

Glossary Item Box

Gets the number of elements contained in the ICollection.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReadOnly Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : IsReadOnly Property

Glossary Item Box

Gets a value indicating whether the ICollection is read-only.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReadOnly As Boolean
C#
public bool IsReadOnly {get;}

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Item Property

key

Glossary Item Box

Gets or sets the element with the specified key.

Syntax

Visual Basic (Declaration)
Public Default Property Item( _
   ByVal key As TKey _
) As TValue
C#
public TValue this[
   TKey key
]; {get; set;}

Parameters

key

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Keys Property

Glossary Item Box

Gets an ICollection containing the keys of the IDictionary.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As ICollection(Of TKey)
C#
public ICollection<TKey> Keys {get;}

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<string, string> test = new SynchronizedDictionary<string, string>(new Dictionary<string,string>(), new IgnoreLocking());
test["a"] = "b";
string all = String.Join("", new List<string>(test.Keys).ToArray());
Assert.AreEqual("a", all);
VB.NET Copy Code
Dim test As New SynchronizedDictionary(Of String, String)(New Dictionary(Of String, String)(), New IgnoreLocking())
test("a") = "b"
Dim all As String = [String].Join("", New List(Of String)(test.Keys).ToArray())
Assert.AreEqual("a", all)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Lock Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Lock Property

Glossary Item Box

Exposes the interal lock so that you can syncronize several calls

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Lock As ILockStrategy
C#
public ILockStrategy Lock {get;}

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedDictionary<int, string> test = new SynchronizedDictionary<int, string>(lck);

Assert.IsTrue(ReferenceEquals(lck, test.Lock));
test.Add(42, "42");
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

test[42] = "51";
Assert.AreEqual(2, factory.TotalWriterCount);

test.Add(1, "52");
Assert.AreEqual(3, factory.TotalWriterCount);

test.Remove(-1);
Assert.AreEqual(4, factory.TotalWriterCount);

test.Remove(1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual("51", test[42]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (KeyValuePair<int, string> i in test)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(false, test.ContainsKey(-1));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, test.Count);
Assert.AreEqual(4, factory.TotalReaderCount);

string cmp;
Assert.IsTrue(test.TryGetValue(42, out cmp) && cmp == "51");
Assert.AreEqual(5, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim test As New SynchronizedDictionary(Of Integer, String)(lck)

Assert.IsTrue(ReferenceEquals(lck, test.Lock))
test.Add(42, "42")
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

test(42) = "51"
Assert.AreEqual(2, factory.TotalWriterCount)

test.Add(1, "52")
Assert.AreEqual(3, factory.TotalWriterCount)

test.Remove(-1)
Assert.AreEqual(4, factory.TotalWriterCount)

test.Remove(1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual("51", test(42))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As KeyValuePair(Of Integer, String) In test
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(False, test.ContainsKey(-1))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, test.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Dim cmp As String
Assert.IsTrue(test.TryGetValue(42, cmp) AndAlso cmp = "51")
Assert.AreEqual(5, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members
ILockStrategy

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Values Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedDictionary<TKey,TValue> Class : Values Property

Glossary Item Box

Gets an ICollection containing the values in the IDictionary.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Values As ICollection(Of TValue)
C#
public ICollection<TValue> Values {get;}

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<string, string> test = new SynchronizedDictionary<string, string>(new Dictionary<string, string>());
test["a"] = "b";
string all = String.Join("", new List<string>(test.Values).ToArray());
Assert.AreEqual("b", all);
VB.NET Copy Code
Dim test As New SynchronizedDictionary(Of String, String)(New Dictionary(Of String, String)())
test("a") = "b"
Dim all As String = [String].Join("", New List(Of String)(test.Values).ToArray())
Assert.AreEqual("b", all)

Requirements

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

See Also

Reference

SynchronizedDictionary<TKey,TValue> Class
SynchronizedDictionary<TKey,TValue> Members

Source Code

Library/Collections/SynchronizedDictionary.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
SynchronizedList<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SynchronizedList<T> Class

Glossary Item Box

Represents a collection of objects that can be individually accessed by index.

Object Model

SynchronizedList<T> ClassT Class

Syntax

Visual Basic (Declaration)
Public Class SynchronizedList(Of T)
C#
public class SynchronizedList<T>

Type Parameters

T

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.SynchronizedList<T>

Requirements

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

See Also

Reference

SynchronizedList<T> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SynchronizedList<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SynchronizedList<T> Class

Glossary Item Box

The following tables list the members exposed by SynchronizedList<T>.

Public Constructors

 | Name | Description
Public Constructor | SynchronizedList<T> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | IsReadOnly | Gets a value indicating whether the ICollection is read-only.
Public Property | Item | Gets or sets the element at the specified index.
Public Property | Lock | Exposes the interal lock so that you can syncronize several calls
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an item to the ICollection.
Public Method | Clear | Removes all items from the ICollection.
Public Method | Contains | Determines whether the IList contains the element specified.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | Dispose | Defines a method to release allocated resources.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | IndexOf | Determines the index of a specific item in the IList.
Public Method | Insert | Inserts an item to the IList at the specified index.
Public Method | Remove | Removes the first occurrence of a specific object from the ICollection.
Public Method | RemoveAt | Removes the IList item at the specified index.
Public Method | ReplaceStorage | Locks the collection and replaces the underlying storage dictionary.
Top

See Also

Reference

SynchronizedList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedList<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : SynchronizedList<T> Constructor

Glossary Item Box

Overload List

Overload | Description
SynchronizedList<T> Constructor() | Constructs a thread-safe generic collection of key/value pairs using exclusive locking.
SynchronizedList<T> Constructor(ILockStrategy) | Constructs a thread-safe generic collection of key/value pairs using the lock provided.
SynchronizedList<T> Constructor(IList<T>) | Constructs a thread-safe generic collection of T, wrapped around the instance in storage using the default locking type for exclusive access, akin to placing lock(this) around each call. If you want to allow reader/writer locking provide one of those lock types from the Synchronization namespace.
SynchronizedList<T> Constructor(IList<T>,ILockStrategy) | Constructs a thread-safe generic collection of T, wrapped around the instance in storage

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedList<T> Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class > SynchronizedList<T> Constructor : SynchronizedList<T> Constructor()

Glossary Item Box

Constructs a thread-safe generic collection of key/value pairs using exclusive locking.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public SynchronizedList<T>()

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members
Overload List

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedList<T> Constructor(ILockStrategy)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class > SynchronizedList<T> Constructor : SynchronizedList<T> Constructor(ILockStrategy)

locking

Glossary Item Box

Constructs a thread-safe generic collection of key/value pairs using the lock provided.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal locking As ILockStrategy _
)
C#
public SynchronizedList<T>(
   ILockStrategy locking
)

Parameters

locking

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members
Overload List

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedList<T> Constructor(IList<T>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class > SynchronizedList<T> Constructor : SynchronizedList<T> Constructor(IList<T>)

storage

Glossary Item Box

Constructs a thread-safe generic collection of T, wrapped around the instance in storage using the default locking type for exclusive access, akin to placing lock(this) around each call. If you want to allow reader/writer locking provide one of those lock types from the Synchronization namespace.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal storage As IList(Of T) _
)
C#
public SynchronizedList<T>(
   IList<T> storage
)

Parameters

storage

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedList<int> list = new SynchronizedList<int>(new List<int>(new[] { 1, 2, 3 }));
Assert.AreEqual(2, list.IndexOf(3));
Assert.AreEqual(1, list.IndexOf(2));
Assert.AreEqual(0, list.IndexOf(1));
Assert.AreEqual(-1, list.IndexOf(5));
VB.NET Copy Code
Dim list As New SynchronizedList(Of Integer)(New List(Of Integer)(New () {1, 2, 3}))
Assert.AreEqual(2, list.IndexOf(3))
Assert.AreEqual(1, list.IndexOf(2))
Assert.AreEqual(0, list.IndexOf(1))
Assert.AreEqual(-1, list.IndexOf(5))

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members
Overload List

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SynchronizedList<T> Constructor(IList<T>,ILockStrategy)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class > SynchronizedList<T> Constructor : SynchronizedList<T> Constructor(IList<T>,ILockStrategy)

storage
locking

Glossary Item Box

Constructs a thread-safe generic collection of T, wrapped around the instance in storage

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal storage As IList(Of T), _
   ByVal locking As ILockStrategy _
)
C#
public SynchronizedList<T>(
   IList<T> storage,
   ILockStrategy locking
)

Parameters

storage
locking

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedList<int> list = new SynchronizedList<int>(new List<int>(), new IgnoreLocking());
list.Insert(0, 1);
Assert.AreEqual(1, list.Count);
list.ReplaceStorage(new List<int>());
Assert.AreEqual(0, list.Count);
VB.NET Copy Code
Dim list As New SynchronizedList(Of Integer)(New List(Of Integer)(), New IgnoreLocking())
list.Insert(0, 1)
Assert.AreEqual(1, list.Count)
list.ReplaceStorage(New List(Of Integer)())
Assert.AreEqual(0, list.Count)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members
Overload List

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SynchronizedList<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SynchronizedList<T> Class

Glossary Item Box

For a list of all members of this type, see SynchronizedList<T> members.

Public Methods

 | Name | Description
Public Method | Add | Adds an item to the ICollection.
Public Method | Clear | Removes all items from the ICollection.
Public Method | Contains | Determines whether the IList contains the element specified.
Public Method | CopyTo | Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.
Public Method | Dispose | Defines a method to release allocated resources.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | IndexOf | Determines the index of a specific item in the IList.
Public Method | Insert | Inserts an item to the IList at the specified index.
Public Method | Remove | Removes the first occurrence of a specific object from the ICollection.
Public Method | RemoveAt | Removes the IList item at the specified index.
Public Method | ReplaceStorage | Locks the collection and replaces the underlying storage dictionary.
Top

See Also

Reference

SynchronizedList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Add Method

item

Glossary Item Box

Adds an item to the ICollection.

Syntax

Visual Basic (Declaration)
Public Function Add( _
   ByVal item As T _
) As Integer
C#
public int Add(
   T item
)

Parameters

item

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Clear Method

Glossary Item Box

Removes all items from the ICollection.

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Contains Method

item

Glossary Item Box

Determines whether the IList contains the element specified.

Syntax

Visual Basic (Declaration)
Public Function Contains( _
   ByVal item As T _
) As Boolean
C#
public bool Contains(
   T item
)

Parameters

item

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : CopyTo Method

array
arrayIndex

Glossary Item Box

Copies the elements of the ICollection to an System.Array, starting at a particular System.Array index.

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As T, _
   ByVal arrayIndex As Integer _
)
C#
public void CopyTo(
   T[] array,
   int arrayIndex
)

Parameters

array
arrayIndex

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Dispose Method

Glossary Item Box

Defines a method to release allocated resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of T)
C#
public IEnumerator<T> GetEnumerator()

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IndexOf Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : IndexOf Method

item

Glossary Item Box

Determines the index of a specific item in the IList.

Syntax

Visual Basic (Declaration)
Public Function IndexOf( _
   ByVal item As T _
) As Integer
C#
public int IndexOf(
   T item
)

Parameters

item

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Insert Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Insert Method

index
item

Glossary Item Box

Inserts an item to the IList at the specified index.

Syntax

Visual Basic (Declaration)
Public Sub Insert( _
   ByVal index As Integer, _
   ByVal item As T _
)
C#
public void Insert(
   int index,
   T item
)

Parameters

index
item

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Remove Method

item

Glossary Item Box

Removes the first occurrence of a specific object from the ICollection.

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal item As T _
) As Boolean
C#
public bool Remove(
   T item
)

Parameters

item

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RemoveAt Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : RemoveAt Method

index

Glossary Item Box

Removes the IList item at the specified index.

Syntax

Visual Basic (Declaration)
Public Sub RemoveAt( _
   ByVal index As Integer _
)
C#
public void RemoveAt(
   int index
)

Parameters

index

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplaceStorage Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : ReplaceStorage Method

newStorage

Glossary Item Box

Locks the collection and replaces the underlying storage dictionary.

Syntax

Visual Basic (Declaration)
Public Function ReplaceStorage( _
   ByVal newStorage As IList(Of T) _
) As IList(Of T)
C#
public IList<T> ReplaceStorage(
   IList<T> newStorage
)

Parameters

newStorage

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedList<int> list = new SynchronizedList<int>(new List<int>(), new IgnoreLocking());
list.Insert(0, 1);
Assert.AreEqual(1, list.Count);
list.ReplaceStorage(new List<int>());
Assert.AreEqual(0, list.Count);
VB.NET Copy Code
Dim list As New SynchronizedList(Of Integer)(New List(Of Integer)(), New IgnoreLocking())
list.Insert(0, 1)
Assert.AreEqual(1, list.Count)
list.ReplaceStorage(New List(Of Integer)())
Assert.AreEqual(0, list.Count)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SynchronizedList<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : SynchronizedList<T> Class

Glossary Item Box

For a list of all members of this type, see SynchronizedList<T> members.

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements contained in the ICollection.
Public Property | IsReadOnly | Gets a value indicating whether the ICollection is read-only.
Public Property | Item | Gets or sets the element at the specified index.
Public Property | Lock | Exposes the interal lock so that you can syncronize several calls
Top

See Also

Reference

SynchronizedList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Count Property

Glossary Item Box

Gets the number of elements contained in the ICollection.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReadOnly Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : IsReadOnly Property

Glossary Item Box

Gets a value indicating whether the ICollection is read-only.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReadOnly As Boolean
C#
public bool IsReadOnly {get;}

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Item Property

index

Glossary Item Box

Gets or sets the element at the specified index.

Syntax

Visual Basic (Declaration)
Public Default Property Item( _
   ByVal index As Integer _
) As T
C#
public T this[
   int index
]; {get; set;}

Parameters

index

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Lock Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class : Lock Property

Glossary Item Box

Exposes the interal lock so that you can syncronize several calls

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Lock As ILockStrategy
C#
public ILockStrategy Lock {get;}

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

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

See Also

Reference

SynchronizedList<T> Class
SynchronizedList<T> Members
ILockStrategy

Source Code

Library/Collections/SynchronizedList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DuplicateHandling Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DuplicateHandling Enumeration

Glossary Item Box

Defines how duplicate keys are handled

Syntax

Visual Basic (Declaration)
Public Enum DuplicateHandling
   Inherits System.Enum
C#
public enum DuplicateHandling : System.Enum

Members

Member | Description
FirstValueWins | Remove all but the first item of duplicates
LastValueWins | Remove all but the last item of duplicates
None | Do nothing and pass-through all duplicates
RaisesException | Throw an error on duplicates

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NET Copy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.DuplicateHandling

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
DuplicateHandling BulkInsertOptions.DuplicateHandling
IEnumerable OrderedEnumeration.Merge(IComparer,DuplicateHandling,IEnumerable[])
IEnumerable OrderedEnumeration.WithDuplicateHandling(IEnumerable,IComparer,DuplicateHandling)
DuplicateHandling OrderedEnumeration.DuplicateHandling
IEnumerable> OrderedKeyValuePairs.Merge(IComparer,DuplicateHandling,IEnumerable>[])


%%PageItemTitle%%

[image]
CSharpTest.Net
LurchTableOrder Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTableOrder Enumeration

Glossary Item Box

Defines if and how items added to a LurchTable are linked together, this defines the value returned from Peek/Dequeue as the oldest entry of the specified operation.

Syntax

Visual Basic (Declaration)
Public Enum LurchTableOrder
   Inherits System.Enum
C#
public enum LurchTableOrder : System.Enum

Members

Member | Description
Access | Linked by most recently inserted, updated, or fetched
Insertion | Linked in insertion order
Modified | Linked by most recently inserted or updated
None | No linking

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var test = new LurchTableTest<int, string>(LurchTableOrder.Access);
Assert.AreEqual(LurchTableOrder.Access, test.Ordering);
var sample = GetSample();
foreach (var item in sample)
    test.Add(item.Key, item.Value);

Array.Reverse(sample);
foreach (var item in sample)
    Assert.AreEqual(item.Value, test[item.Key]);

KeyValuePair<int, string> value;
foreach (var item in sample)
{
    Assert.IsTrue(test.TryDequeue(out value));
    Assert.AreEqual(item.Key, value.Key);
    Assert.AreEqual(item.Value, value.Value);
}

Assert.IsFalse(test.Peek(out value));
Assert.IsFalse(test.TryDequeue(out value));
VB.NET Copy Code
Dim test As var = New LurchTableTest(Of Integer, String)(LurchTableOrder.Access)
Assert.AreEqual(LurchTableOrder.Access, test.Ordering)
Dim sample As var = GetSample()
For Each item As var In sample
    test.Add(item.Key, item.Value)
Next

Array.Reverse(sample)
For Each item As var In sample
    Assert.AreEqual(item.Value, test(item.Key))
Next

Dim value As KeyValuePair(Of Integer, String)
For Each item As var In sample
    Assert.IsTrue(test.TryDequeue(value))
    Assert.AreEqual(item.Key, value.Key)
    Assert.AreEqual(item.Value, value.Value)
Next

Assert.IsFalse(test.Peek(value))
Assert.IsFalse(test.TryDequeue(value))

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.LurchTableOrder

Requirements

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

See Also

Reference

CSharpTest.Net.Collections Namespace
LurchTableOrder LurchTable.Ordering


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
LurchTable.Enumerator<TKey,TValue> Structure
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.Enumerator<TKey,TValue> Structure

Glossary Item Box

Provides an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Structure LurchTable.Enumerator
    (Of TKey,TValue)
   Inherits System.ValueType
C#
public struct LurchTable.Enumerator<TKey,TValue> : System.ValueType

Type Parameters

TKey
TValue

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Collections.LurchTable`2.Enumerator<TKey,TValue>

Requirements

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

See Also

Reference

LurchTable.Enumerator<TKey,TValue> Members
CSharpTest.Net.Collections Namespace
LurchTable.Enumerator LurchTable.GetEnumerator()

Used By

LurchTable.Clear()
LurchTable.KeyCollection.CopyTo(TKey[],Int32)
Boolean LurchTable.ValueCollection.Contains(TValue)
LurchTable.ValueCollection.CopyTo(TValue[],Int32)

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LurchTable.Enumerator<TKey,TValue> Structure Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.Enumerator<TKey,TValue> Structure

Glossary Item Box

The following tables list the members exposed by LurchTable.Enumerator<TKey,TValue>.

Public Properties

 | Name | Description
Public Property | Current | Gets the element in the collection at the current position of the enumerator.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | MoveNext | Advances the enumerator to the next element of the collection.
Public Method | Reset | Sets the enumerator to its initial position, which is before the first element in the collection.
Top

See Also

Reference

LurchTable.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.Enumerator LurchTable.GetEnumerator()

Used By

LurchTable.Clear()
LurchTable.KeyCollection.CopyTo(TKey[],Int32)
Boolean LurchTable.ValueCollection.Contains(TValue)
LurchTable.ValueCollection.CopyTo(TValue[],Int32)

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LurchTable.Enumerator<TKey,TValue> Structure Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.Enumerator<TKey,TValue> Structure

Glossary Item Box

For a list of all members of this type, see LurchTable.Enumerator<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | MoveNext | Advances the enumerator to the next element of the collection.
Public Method | Reset | Sets the enumerator to its initial position, which is before the first element in the collection.
Top

See Also

Reference

LurchTable.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.Enumerator LurchTable.GetEnumerator()

Used By

LurchTable.Clear()
LurchTable.KeyCollection.CopyTo(TKey[],Int32)
Boolean LurchTable.ValueCollection.Contains(TValue)
LurchTable.ValueCollection.CopyTo(TValue[],Int32)

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.Enumerator<TKey,TValue> Structure : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

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

See Also

Reference

LurchTable.Enumerator<TKey,TValue> Structure
LurchTable.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MoveNext Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.Enumerator<TKey,TValue> Structure : MoveNext Method

Glossary Item Box

Advances the enumerator to the next element of the collection.

Syntax

Visual Basic (Declaration)
Public Function MoveNext() As Boolean
C#
public bool MoveNext()

Requirements

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

See Also

Reference

LurchTable.Enumerator<TKey,TValue> Structure
LurchTable.Enumerator<TKey,TValue> Members

Used By

LurchTable.Clear()
LurchTable.KeyCollection.CopyTo(TKey[],Int32)
Boolean LurchTable.ValueCollection.Contains(TValue)
LurchTable.ValueCollection.CopyTo(TValue[],Int32)

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Reset Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.Enumerator<TKey,TValue> Structure : Reset Method

Glossary Item Box

Sets the enumerator to its initial position, which is before the first element in the collection.

Syntax

Visual Basic (Declaration)
Public Sub Reset()
C#
public void Reset()

Requirements

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

See Also

Reference

LurchTable.Enumerator<TKey,TValue> Structure
LurchTable.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LurchTable.Enumerator<TKey,TValue> Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.Enumerator<TKey,TValue> Structure

Glossary Item Box

For a list of all members of this type, see LurchTable.Enumerator<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Current | Gets the element in the collection at the current position of the enumerator.
Top

See Also

Reference

LurchTable.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.Enumerator LurchTable.GetEnumerator()

Used By

LurchTable.Clear()
LurchTable.KeyCollection.CopyTo(TKey[],Int32)
Boolean LurchTable.ValueCollection.Contains(TValue)
LurchTable.ValueCollection.CopyTo(TValue[],Int32)

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Current Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.Enumerator<TKey,TValue> Structure : Current Property

Glossary Item Box

Gets the element in the collection at the current position of the enumerator.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Current As KeyValuePair(Of TKey,TValue)
C#
public KeyValuePair<TKey,TValue> Current {get;}

Requirements

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

See Also

Reference

LurchTable.Enumerator<TKey,TValue> Structure
LurchTable.Enumerator<TKey,TValue> Members

Used By

LurchTable.Clear()
LurchTable.KeyCollection.CopyTo(TKey[],Int32)
Boolean LurchTable.ValueCollection.Contains(TValue)
LurchTable.ValueCollection.CopyTo(TValue[],Int32)

Source Code

Library/Collections/LurchTable.cs
BPlusTree/Collections/Enumerator.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure

Glossary Item Box

Provides an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Structure LurchTable.KeyCollection.Enumerator
    (Of TKey,TValue)
   Inherits System.ValueType
C#
public struct LurchTable.KeyCollection.Enumerator<TKey,TValue> : System.ValueType

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var test = CreateSample(sample);
int ix = 0;
foreach (var key in test.Keys)
    Assert.AreEqual(sample[ix++].Value, test[key]);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim test As var = CreateSample(sample)
Dim ix As Integer = 0
For Each key As var In test.Keys
    Assert.AreEqual(sample(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)).Value, test(key))
Next

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Collections.LurchTable`2.KeyCollection.Enumerator<TKey,TValue>

Requirements

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

See Also

Reference

LurchTable.KeyCollection.Enumerator<TKey,TValue> Members
CSharpTest.Net.Collections Namespace
LurchTable.KeyCollection.Enumerator LurchTable.KeyCollection.GetEnumerator()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure

Glossary Item Box

The following tables list the members exposed by LurchTable.KeyCollection.Enumerator<TKey,TValue>.

Public Properties

 | Name | Description
Public Property | Current | Gets the element in the collection at the current position of the enumerator.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | MoveNext | Advances the enumerator to the next element of the collection.
Public Method | Reset | Sets the enumerator to its initial position, which is before the first element in the collection.
Top

See Also

Reference

LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.KeyCollection.Enumerator LurchTable.KeyCollection.GetEnumerator()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure

Glossary Item Box

For a list of all members of this type, see LurchTable.KeyCollection.Enumerator<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | MoveNext | Advances the enumerator to the next element of the collection.
Public Method | Reset | Sets the enumerator to its initial position, which is before the first element in the collection.
Top

See Also

Reference

LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.KeyCollection.Enumerator LurchTable.KeyCollection.GetEnumerator()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

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

See Also

Reference

LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure
LurchTable.KeyCollection.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MoveNext Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure : MoveNext Method

Glossary Item Box

Advances the enumerator to the next element of the collection.

Syntax

Visual Basic (Declaration)
Public Function MoveNext() As Boolean
C#
public bool MoveNext()

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var test = CreateSample(sample);
int ix = 0;
foreach (var key in test.Keys)
    Assert.AreEqual(sample[ix++].Value, test[key]);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim test As var = CreateSample(sample)
Dim ix As Integer = 0
For Each key As var In test.Keys
    Assert.AreEqual(sample(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)).Value, test(key))
Next

Requirements

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

See Also

Reference

LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure
LurchTable.KeyCollection.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Reset Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure : Reset Method

Glossary Item Box

Sets the enumerator to its initial position, which is before the first element in the collection.

Syntax

Visual Basic (Declaration)
Public Sub Reset()
C#
public void Reset()

Requirements

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

See Also

Reference

LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure
LurchTable.KeyCollection.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure

Glossary Item Box

For a list of all members of this type, see LurchTable.KeyCollection.Enumerator<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Current | Gets the element in the collection at the current position of the enumerator.
Top

See Also

Reference

LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.KeyCollection.Enumerator LurchTable.KeyCollection.GetEnumerator()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Current Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure : Current Property

Glossary Item Box

Gets the element in the collection at the current position of the enumerator.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Current As TKey
C#
public TKey Current {get;}

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var test = CreateSample(sample);
int ix = 0;
foreach (var key in test.Keys)
    Assert.AreEqual(sample[ix++].Value, test[key]);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim test As var = CreateSample(sample)
Dim ix As Integer = 0
For Each key As var In test.Keys
    Assert.AreEqual(sample(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)).Value, test(key))
Next

Requirements

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

See Also

Reference

LurchTable.KeyCollection.Enumerator<TKey,TValue> Structure
LurchTable.KeyCollection.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs
BPlusTree/Collections/Enumerator.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure

Glossary Item Box

Provides an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Structure LurchTable.ValueCollection.Enumerator
    (Of TKey,TValue)
   Inherits System.ValueType
C#
public struct LurchTable.ValueCollection.Enumerator<TKey,TValue> : System.ValueType

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var test = CreateSample(sample);
int ix = 0;
foreach (var value in test.Values)
    Assert.AreEqual(sample[ix++].Value, value);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim test As var = CreateSample(sample)
Dim ix As Integer = 0
For Each value As var In test.Values
    Assert.AreEqual(sample(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)).Value, value)
Next

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Collections.LurchTable`2.ValueCollection.Enumerator<TKey,TValue>

Requirements

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

See Also

Reference

LurchTable.ValueCollection.Enumerator<TKey,TValue> Members
CSharpTest.Net.Collections Namespace
LurchTable.ValueCollection.Enumerator LurchTable.ValueCollection.GetEnumerator()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure

Glossary Item Box

The following tables list the members exposed by LurchTable.ValueCollection.Enumerator<TKey,TValue>.

Public Properties

 | Name | Description
Public Property | Current | Gets the element in the collection at the current position of the enumerator.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | MoveNext | Advances the enumerator to the next element of the collection.
Public Method | Reset | Sets the enumerator to its initial position, which is before the first element in the collection.
Top

See Also

Reference

LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.ValueCollection.Enumerator LurchTable.ValueCollection.GetEnumerator()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure

Glossary Item Box

For a list of all members of this type, see LurchTable.ValueCollection.Enumerator<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | MoveNext | Advances the enumerator to the next element of the collection.
Public Method | Reset | Sets the enumerator to its initial position, which is before the first element in the collection.
Top

See Also

Reference

LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.ValueCollection.Enumerator LurchTable.ValueCollection.GetEnumerator()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

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

See Also

Reference

LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure
LurchTable.ValueCollection.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MoveNext Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure : MoveNext Method

Glossary Item Box

Advances the enumerator to the next element of the collection.

Syntax

Visual Basic (Declaration)
Public Function MoveNext() As Boolean
C#
public bool MoveNext()

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var test = CreateSample(sample);
int ix = 0;
foreach (var value in test.Values)
    Assert.AreEqual(sample[ix++].Value, value);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim test As var = CreateSample(sample)
Dim ix As Integer = 0
For Each value As var In test.Values
    Assert.AreEqual(sample(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)).Value, value)
Next

Requirements

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

See Also

Reference

LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure
LurchTable.ValueCollection.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Reset Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure : Reset Method

Glossary Item Box

Sets the enumerator to its initial position, which is before the first element in the collection.

Syntax

Visual Basic (Declaration)
Public Sub Reset()
C#
public void Reset()

Requirements

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

See Also

Reference

LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure
LurchTable.ValueCollection.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure

Glossary Item Box

For a list of all members of this type, see LurchTable.ValueCollection.Enumerator<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Current | Gets the element in the collection at the current position of the enumerator.
Top

See Also

Reference

LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure
CSharpTest.Net.Collections Namespace
LurchTable.ValueCollection.Enumerator LurchTable.ValueCollection.GetEnumerator()

Source Code

Library/Collections/LurchTable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Current Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure : Current Property

Glossary Item Box

Gets the element in the collection at the current position of the enumerator.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Current As TValue
C#
public TValue Current {get;}

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var sample = GetSample();
var test = CreateSample(sample);
int ix = 0;
foreach (var value in test.Values)
    Assert.AreEqual(sample[ix++].Value, value);
VB.NET Copy Code
Dim sample As var = GetSample()
Dim test As var = CreateSample(sample)
Dim ix As Integer = 0
For Each value As var In test.Values
    Assert.AreEqual(sample(System.Math.Max(System.Threading.Interlocked.Increment(ix),ix - 1)).Value, value)
Next

Requirements

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

See Also

Reference

LurchTable.ValueCollection.Enumerator<TKey,TValue> Structure
LurchTable.ValueCollection.Enumerator<TKey,TValue> Members

Source Code

Library/Collections/LurchTable.cs
BPlusTree/Collections/Enumerator.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
IConcurrentDictionary<TKey,TValue> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IConcurrentDictionary<TKey,TValue> Interface

Glossary Item Box

Extends the IDictionaryEx interface to encompass concurrent/atomic operations

Syntax

Visual Basic (Declaration)
Public Interface IConcurrentDictionary
    (Of TKey,TValue)
   Inherits IDictionaryEx(Of TKey,TValue)
C#
public interface IConcurrentDictionary<TKey,TValue> : IDictionaryEx<TKey,TValue>

Type Parameters

TKey
TValue

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IConcurrentDictionary<TKey,TValue> Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IConcurrentDictionary<TKey,TValue> Interface

Glossary Item Box

The following tables list the members exposed by IConcurrentDictionary<TKey,TValue>.

Public Methods

 | Name | Description
Method | AddOrUpdate | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
Method | GetOrAdd | Adds a key/value pair to the IDictionary if the key does not already exist.
Method | TryAdd | Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.
Method | TryRemove | Overloaded. Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.
Method | TryUpdate | Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the tree lock. Be cautious about the behavior and performance of the code provided as it can cause a dead-lock to occur. If the method returns an instance who .Equals the original, no update is applied.
Top

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IConcurrentDictionary<TKey,TValue> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IConcurrentDictionary<TKey,TValue> Interface

Glossary Item Box

For a list of all members of this type, see IConcurrentDictionary<TKey,TValue> members.

Public Methods

 | Name | Description
Method | AddOrUpdate | Overloaded. Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
Method | GetOrAdd | Adds a key/value pair to the IDictionary if the key does not already exist.
Method | TryAdd | Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.
Method | TryRemove | Overloaded. Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.
Method | TryUpdate | Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the tree lock. Be cautious about the behavior and performance of the code provided as it can cause a dead-lock to occur. If the method returns an instance who .Equals the original, no update is applied.
Top

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface : AddOrUpdate Method

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Overload List

Overload | Description
AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) | Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.
AddOrUpdate<T>(TKey,T) | Add, update, or fetche a key/value pair from the dictionary via an implementation of the ICreateOrUpdateValue<TKey,TValue> interface.

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface > AddOrUpdate Method : AddOrUpdate(TKey,TValue,KeyValueUpdate<TKey,TValue>) Method

key
addValue
fnUpdate

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Syntax

Visual Basic (Declaration)
Overloads Function AddOrUpdate( _
   ByVal key As TKey, _
   ByVal addValue As TValue, _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As TValue
C#
TValue AddOrUpdate(
   TKey key,
   TValue addValue,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
addValue
fnUpdate

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface > AddOrUpdate Method : AddOrUpdate(TKey,Converter<TKey,TValue>,KeyValueUpdate<TKey,TValue>) Method

key
fnCreate
fnUpdate

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist, or updates a key/value pair if the key already exists.

Syntax

Visual Basic (Declaration)
Overloads Function AddOrUpdate( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue), _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As TValue
C#
TValue AddOrUpdate(
   TKey key,
   Converter<TKey,TValue> fnCreate,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
fnCreate
fnUpdate

Remarks

Adds or modifies an element with the provided key and value. If the key does not exist in the collection, the factory method fnCreate will be called to produce the new value, if the key exists, the converter method fnUpdate will be called to create an updated value.

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members
Overload List
KeyValueUpdate

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
AddOrUpdate<T>(TKey,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface > AddOrUpdate Method : AddOrUpdate<T>(TKey,T) Method

key
createOrUpdateValue

Glossary Item Box

Add, update, or fetche a key/value pair from the dictionary via an implementation of the ICreateOrUpdateValue<TKey,TValue> interface.

Syntax

Visual Basic (Declaration)
Overloads Function AddOrUpdate(Of T As ICreateOrUpdateValue(Of TKey,TValue))( _
   ByVal key As TKey, _
   ByRef createOrUpdateValue As T _
) As Boolean
C#
bool AddOrUpdate<T>(
   TKey key,
   ref T createOrUpdateValue
)
where T: ICreateOrUpdateValue<TKey,TValue>

Parameters

key
createOrUpdateValue

Type Parameters

T

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface : GetOrAdd Method

key
The key of the element to add.
fnCreate
Constructs a new value for the key.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue) _
) As TValue
C#
TValue GetOrAdd(
   TKey key,
   Converter<TKey,TValue> fnCreate
)

Parameters

key
The key of the element to add.
fnCreate
Constructs a new value for the key.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface : TryAdd Method

key
fnCreate

Glossary Item Box

Adds an element with the provided key and value to the IDictionary by calling the provided factory method to construct the value if the key is not already present in the collection.

Syntax

Visual Basic (Declaration)
Function TryAdd( _
   ByVal key As TKey, _
   ByVal fnCreate As Converter(Of TKey,TValue) _
) As Boolean
C#
bool TryAdd(
   TKey key,
   Converter<TKey,TValue> fnCreate
)

Parameters

key
fnCreate

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface : TryRemove Method

Glossary Item Box

Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.

Overload List

Overload | Description
TryRemove(TKey,KeyValuePredicate<TKey,TValue>) | Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.
TryRemove<T>(TKey,T) | Conditionally removes a key/value pair from the dictionary via an implementation of the IRemoveValue<TKey,TValue> interface.

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove(TKey,KeyValuePredicate<TKey,TValue>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface > TryRemove Method : TryRemove(TKey,KeyValuePredicate<TKey,TValue>) Method

key
fnCondition

Glossary Item Box

Removes the element with the specified key from the IDictionary if the fnCondition predicate is null or returns true.

Syntax

Visual Basic (Declaration)
Overloads Function TryRemove( _
   ByVal key As TKey, _
   ByVal fnCondition As CSharpTest.Net.Collections.KeyValuePredicate(Of TKey,TValue) _
) As Boolean
C#
bool TryRemove(
   TKey key,
   CSharpTest.Net.Collections.KeyValuePredicate<TKey,TValue> fnCondition
)

Parameters

key
fnCondition

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members
Overload List
KeyValuePredicate

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
TryRemove<T>(TKey,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface > TryRemove Method : TryRemove<T>(TKey,T) Method

key
removeValue

Glossary Item Box

Conditionally removes a key/value pair from the dictionary via an implementation of the IRemoveValue<TKey,TValue> interface.

Syntax

Visual Basic (Declaration)
Overloads Function TryRemove(Of T As IRemoveValue(Of TKey,TValue))( _
   ByVal key As TKey, _
   ByRef removeValue As T _
) As Boolean
C#
bool TryRemove<T>(
   TKey key,
   ref T removeValue
)
where T: IRemoveValue<TKey,TValue>

Parameters

key
removeValue

Type Parameters

T

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members
Overload List

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IConcurrentDictionary<TKey,TValue> Interface : TryUpdate Method

key
fnUpdate

Glossary Item Box

Modify the value associated with the result of the provided update method as an atomic operation, Allows for reading/writing a single record within the tree lock. Be cautious about the behavior and performance of the code provided as it can cause a dead-lock to occur. If the method returns an instance who .Equals the original, no update is applied.

Syntax

Visual Basic (Declaration)
Function TryUpdate( _
   ByVal key As TKey, _
   ByVal fnUpdate As CSharpTest.Net.Collections.KeyValueUpdate(Of TKey,TValue) _
) As Boolean
C#
bool TryUpdate(
   TKey key,
   CSharpTest.Net.Collections.KeyValueUpdate<TKey,TValue> fnUpdate
)

Parameters

key
fnUpdate

Requirements

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

See Also

Reference

IConcurrentDictionary<TKey,TValue> Interface
IConcurrentDictionary<TKey,TValue> Members
KeyValueUpdate

Source Code

Library/Collections/IConcurrentDictionary.cs


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
ICreateOrUpdateValue<TKey,TValue> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ICreateOrUpdateValue<TKey,TValue> Interface

Glossary Item Box

An interface to provide conditional or custom creation or update logic to a concurrent dictionary.

Syntax

Visual Basic (Declaration)
Public Interface ICreateOrUpdateValue
    (Of TKey,TValue)
   Inherits ICreateValue(Of TKey,TValue), IUpdateValue(Of TKey,TValue)
C#
public interface ICreateOrUpdateValue<TKey,TValue> : ICreateValue<TKey,TValue>, IUpdateValue<TKey,TValue>

Type Parameters

TKey
TValue

Remarks

Generally implemented as a struct and passed by ref to save stack space and to retrieve the values that where inserted or updated.

Requirements

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

See Also

Reference

ICreateOrUpdateValue<TKey,TValue> Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ICreateOrUpdateValue<TKey,TValue> Interface Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ICreateOrUpdateValue<TKey,TValue> Interface

Glossary Item Box

The following tables list the members exposed by ICreateOrUpdateValue<TKey,TValue>.

See Also

Reference

ICreateOrUpdateValue<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
ICreateValue<TKey,TValue> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ICreateValue<TKey,TValue> Interface

Glossary Item Box

An interface to provide conditional or custom creation logic to a concurrent dictionary.

Syntax

Visual Basic (Declaration)
Public Interface ICreateValue
    (Of TKey,TValue)
C#
public interface ICreateValue<TKey,TValue>

Type Parameters

TKey
TValue

Requirements

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

See Also

Reference

ICreateValue<TKey,TValue> Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ICreateValue<TKey,TValue> Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ICreateValue<TKey,TValue> Interface

Glossary Item Box

The following tables list the members exposed by ICreateValue<TKey,TValue>.

Public Methods

 | Name | Description
Method | CreateValue | Called when the key was not found within the dictionary to produce a new value that can be added. Return true to continue with the insertion, or false to prevent the key/value from being inserted.
Top

See Also

Reference

ICreateValue<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ICreateValue<TKey,TValue> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : ICreateValue<TKey,TValue> Interface

Glossary Item Box

For a list of all members of this type, see ICreateValue<TKey,TValue> members.

Public Methods

 | Name | Description
Method | CreateValue | Called when the key was not found within the dictionary to produce a new value that can be added. Return true to continue with the insertion, or false to prevent the key/value from being inserted.
Top

See Also

Reference

ICreateValue<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > ICreateValue<TKey,TValue> Interface : CreateValue Method

key
value

Glossary Item Box

Called when the key was not found within the dictionary to produce a new value that can be added. Return true to continue with the insertion, or false to prevent the key/value from being inserted.

Syntax

Visual Basic (Declaration)
Function CreateValue( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
bool CreateValue(
   TKey key,
   out TValue value
)

Parameters

key
value

Requirements

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

See Also

Reference

ICreateValue<TKey,TValue> Interface
ICreateValue<TKey,TValue> Members

Used By

Boolean SynchronizedDictionary.AddOrUpdate(TKey,T)


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
IDictionaryEx<TKey,TValue> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IDictionaryEx<TKey,TValue> Interface

Glossary Item Box

Extends the IDictionary interface to encompass the TryXxxx operations

Syntax

Visual Basic (Declaration)
Public Interface IDictionaryEx
    (Of TKey,TValue)
C#
public interface IDictionaryEx<TKey,TValue>

Type Parameters

TKey
TValue

Requirements

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

See Also

Reference

IDictionaryEx<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/IDictionaryEx.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IDictionaryEx<TKey,TValue> Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IDictionaryEx<TKey,TValue> Interface

Glossary Item Box

The following tables list the members exposed by IDictionaryEx<TKey,TValue>.

Public Methods

 | Name | Description
Method | GetOrAdd | Adds a key/value pair to the IDictionary if the key does not already exist.
Method | TryAdd | Adds an element with the provided key and value to the IDictionary.
Method | TryRemove | Removes the element with the specified key from the IDictionary.
Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Top

See Also

Reference

IDictionaryEx<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/IDictionaryEx.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IDictionaryEx<TKey,TValue> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IDictionaryEx<TKey,TValue> Interface

Glossary Item Box

For a list of all members of this type, see IDictionaryEx<TKey,TValue> members.

Public Methods

 | Name | Description
Method | GetOrAdd | Adds a key/value pair to the IDictionary if the key does not already exist.
Method | TryAdd | Adds an element with the provided key and value to the IDictionary.
Method | TryRemove | Removes the element with the specified key from the IDictionary.
Method | TryUpdate | Overloaded. Updates an element with the provided key to the value if it exists.
Top

See Also

Reference

IDictionaryEx<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/IDictionaryEx.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IDictionaryEx<TKey,TValue> Interface : GetOrAdd Method

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Glossary Item Box

Adds a key/value pair to the IDictionary if the key does not already exist.

Syntax

Visual Basic (Declaration)
Function GetOrAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As TValue
C#
TValue GetOrAdd(
   TKey key,
   TValue value
)

Parameters

key
The key of the element to add.
value
The value to be added, if the key does not already exist.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Requirements

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

See Also

Reference

IDictionaryEx<TKey,TValue> Interface
IDictionaryEx<TKey,TValue> Members

Source Code

Library/Collections/IDictionaryEx.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryAdd Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IDictionaryEx<TKey,TValue> Interface : TryAdd Method

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration)
Function TryAdd( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
bool TryAdd(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to add.
value
The object to use as the value of the element to add.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Requirements

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

See Also

Reference

IDictionaryEx<TKey,TValue> Interface
IDictionaryEx<TKey,TValue> Members

Source Code

Library/Collections/IDictionaryEx.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRemove Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IDictionaryEx<TKey,TValue> Interface : TryRemove Method

key
The key of the element to remove.
value
The value that was removed.

Glossary Item Box

Removes the element with the specified key from the IDictionary.

Syntax

Visual Basic (Declaration)
Function TryRemove( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
bool TryRemove(
   TKey key,
   out TValue value
)

Parameters

key
The key of the element to remove.
value
The value that was removed.

Return Value

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Requirements

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

See Also

Reference

IDictionaryEx<TKey,TValue> Interface
IDictionaryEx<TKey,TValue> Members

Source Code

Library/Collections/IDictionaryEx.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IDictionaryEx<TKey,TValue> Interface : TryUpdate Method

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Overload List

Overload | Description
TryUpdate(TKey,TValue) | Updates an element with the provided key to the value if it exists.
TryUpdate(TKey,TValue,TValue) | Updates an element with the provided key to the value if it exists.

Requirements

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

See Also

Reference

IDictionaryEx<TKey,TValue> Interface
IDictionaryEx<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IDictionaryEx<TKey,TValue> Interface > TryUpdate Method : TryUpdate(TKey,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
bool TryUpdate(
   TKey key,
   TValue value
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.

Return Value

Returns true if the key provided was found and updated to the value.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Requirements

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

See Also

Reference

IDictionaryEx<TKey,TValue> Interface
IDictionaryEx<TKey,TValue> Members
Overload List

Source Code

Library/Collections/IDictionaryEx.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryUpdate(TKey,TValue,TValue) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IDictionaryEx<TKey,TValue> Interface > TryUpdate Method : TryUpdate(TKey,TValue,TValue) Method

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Glossary Item Box

Updates an element with the provided key to the value if it exists.

Syntax

Visual Basic (Declaration)
Overloads Function TryUpdate( _
   ByVal key As TKey, _
   ByVal value As TValue, _
   ByVal comparisonValue As TValue _
) As Boolean
C#
bool TryUpdate(
   TKey key,
   TValue value,
   TValue comparisonValue
)

Parameters

key
The object to use as the key of the element to update.
value
The new value for the key if found.
comparisonValue
The value that is compared to the value of the element with key.

Return Value

Returns true if the key provided was found and updated to the value.

Exceptions

Exception | Description
System.NotSupportedException | The IDictionary is read-only.

Requirements

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

See Also

Reference

IDictionaryEx<TKey,TValue> Interface
IDictionaryEx<TKey,TValue> Members
Overload List

Source Code

Library/Collections/IDictionaryEx.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
IReadOnlyCollection<T> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IReadOnlyCollection<T> Interface

Glossary Item Box

Provides common interface members for the implementation of a Set

Syntax

Visual Basic (Declaration)
Public Interface IReadOnlyCollection(Of T)
C#
public interface IReadOnlyCollection<T>

Type Parameters

T

Requirements

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

See Also

Reference

IReadOnlyCollection<T> Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IReadOnlyCollection<T> Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IReadOnlyCollection<T> Interface

Glossary Item Box

The following tables list the members exposed by IReadOnlyCollection<T>.

Public Properties

 | Name | Description
Property | Item | Access an item by it's ordinal offset in the list
Top

Public Methods

 | Name | Description
Method | Contains | Returns true if the item is already in the collection
Method | IndexOf | Returns the zero-based index of the item or -1
Method | ToArray | Returns this collection as an array
Top

See Also

Reference

IReadOnlyCollection<T> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IReadOnlyCollection<T> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IReadOnlyCollection<T> Interface

Glossary Item Box

For a list of all members of this type, see IReadOnlyCollection<T> members.

Public Methods

 | Name | Description
Method | Contains | Returns true if the item is already in the collection
Method | IndexOf | Returns the zero-based index of the item or -1
Method | ToArray | Returns this collection as an array
Top

See Also

Reference

IReadOnlyCollection<T> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IReadOnlyCollection<T> Interface : Contains Method

item

Glossary Item Box

Returns true if the item is already in the collection

Syntax

Visual Basic (Declaration)
Function Contains( _
   ByVal item As T _
) As Boolean
C#
bool Contains(
   T item
)

Parameters

item

Requirements

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

See Also

Reference

IReadOnlyCollection<T> Interface
IReadOnlyCollection<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
IndexOf Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IReadOnlyCollection<T> Interface : IndexOf Method

item

Glossary Item Box

Returns the zero-based index of the item or -1

Syntax

Visual Basic (Declaration)
Function IndexOf( _
   ByVal item As T _
) As Integer
C#
int IndexOf(
   T item
)

Parameters

item

Requirements

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

See Also

Reference

IReadOnlyCollection<T> Interface
IReadOnlyCollection<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IReadOnlyCollection<T> Interface : ToArray Method

Glossary Item Box

Returns this collection as an array

Syntax

Visual Basic (Declaration)
Function ToArray() As T()
C#
T[] ToArray()

Requirements

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

See Also

Reference

IReadOnlyCollection<T> Interface
IReadOnlyCollection<T> Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IReadOnlyCollection<T> Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IReadOnlyCollection<T> Interface

Glossary Item Box

For a list of all members of this type, see IReadOnlyCollection<T> members.

Public Properties

 | Name | Description
Property | Item | Access an item by it's ordinal offset in the list
Top

See Also

Reference

IReadOnlyCollection<T> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IReadOnlyCollection<T> Interface : Item Property

index

Glossary Item Box

Access an item by it's ordinal offset in the list

Syntax

Visual Basic (Declaration)
ReadOnly Default Property Item( _
   ByVal index As Integer _
) As T
C#
T this[
   int index
]; {get;}

Parameters

index

Requirements

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

See Also

Reference

IReadOnlyCollection<T> Interface
IReadOnlyCollection<T> Members


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
IRemoveValue<TKey,TValue> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IRemoveValue<TKey,TValue> Interface

Glossary Item Box

An interface to provide conditional removal of an item from a concurrent dictionary.

Syntax

Visual Basic (Declaration)
Public Interface IRemoveValue
    (Of TKey,TValue)
C#
public interface IRemoveValue<TKey,TValue>

Type Parameters

TKey
TValue

Remarks

Generally implemented as a struct and passed by ref to save stack space and to retrieve the values that where inserted or updated.

Requirements

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

See Also

Reference

IRemoveValue<TKey,TValue> Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IRemoveValue<TKey,TValue> Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IRemoveValue<TKey,TValue> Interface

Glossary Item Box

The following tables list the members exposed by IRemoveValue<TKey,TValue>.

Public Methods

 | Name | Description
Method | RemoveValue | Called when the dictionary is about to remove the key/value pair provided, return true to allow it's removal, or false to prevent it from being removed.
Top

See Also

Reference

IRemoveValue<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IRemoveValue<TKey,TValue> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IRemoveValue<TKey,TValue> Interface

Glossary Item Box

For a list of all members of this type, see IRemoveValue<TKey,TValue> members.

Public Methods

 | Name | Description
Method | RemoveValue | Called when the dictionary is about to remove the key/value pair provided, return true to allow it's removal, or false to prevent it from being removed.
Top

See Also

Reference

IRemoveValue<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
RemoveValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IRemoveValue<TKey,TValue> Interface : RemoveValue Method

key
value

Glossary Item Box

Called when the dictionary is about to remove the key/value pair provided, return true to allow it's removal, or false to prevent it from being removed.

Syntax

Visual Basic (Declaration)
Function RemoveValue( _
   ByVal key As TKey, _
   ByVal value As TValue _
) As Boolean
C#
bool RemoveValue(
   TKey key,
   TValue value
)

Parameters

key
value

Requirements

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

See Also

Reference

IRemoveValue<TKey,TValue> Interface
IRemoveValue<TKey,TValue> Members

Used By

Boolean SynchronizedDictionary.TryRemove(TKey,T)


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
IUpdateValue<TKey,TValue> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IUpdateValue<TKey,TValue> Interface

Glossary Item Box

An interface to provide conditional or custom update logic to a concurrent dictionary.

Syntax

Visual Basic (Declaration)
Public Interface IUpdateValue
    (Of TKey,TValue)
C#
public interface IUpdateValue<TKey,TValue>

Type Parameters

TKey
TValue

Requirements

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

See Also

Reference

IUpdateValue<TKey,TValue> Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IUpdateValue<TKey,TValue> Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IUpdateValue<TKey,TValue> Interface

Glossary Item Box

The following tables list the members exposed by IUpdateValue<TKey,TValue>.

Public Methods

 | Name | Description
Method | UpdateValue | Called when the key was found within the dictionary to produce a modified value to update the item to. Return true to continue with the update, or false to prevent the key/value from being updated.
Top

See Also

Reference

IUpdateValue<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IUpdateValue<TKey,TValue> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : IUpdateValue<TKey,TValue> Interface

Glossary Item Box

For a list of all members of this type, see IUpdateValue<TKey,TValue> members.

Public Methods

 | Name | Description
Method | UpdateValue | Called when the key was found within the dictionary to produce a modified value to update the item to. Return true to continue with the update, or false to prevent the key/value from being updated.
Top

See Also

Reference

IUpdateValue<TKey,TValue> Interface
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
UpdateValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > IUpdateValue<TKey,TValue> Interface : UpdateValue Method

key
value

Glossary Item Box

Called when the key was found within the dictionary to produce a modified value to update the item to. Return true to continue with the update, or false to prevent the key/value from being updated.

Syntax

Visual Basic (Declaration)
Function UpdateValue( _
   ByVal key As TKey, _
   ByRef value As TValue _
) As Boolean
C#
bool UpdateValue(
   TKey key,
   ref TValue value
)

Parameters

key
value

Requirements

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

See Also

Reference

IUpdateValue<TKey,TValue> Interface
IUpdateValue<TKey,TValue> Members

Used By

Boolean SynchronizedDictionary.AddOrUpdate(TKey,T)


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
KeyValuePredicate<TKey,TValue> Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : KeyValuePredicate<TKey,TValue> Delegate

key
original

Glossary Item Box

Provides a delegate that performs a test on key/value pair

Syntax

Visual Basic (Declaration)
Public Delegate Function KeyValuePredicate
    (Of TKey,TValue)( _
   ByVal key As TKey, _
   ByVal original As TValue _
) As Boolean
C#
public delegate bool KeyValuePredicate<TKey,TValue>(
   TKey key,
   TValue original
)

Parameters

key
original

Type Parameters

TKey
TValue

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
const int CountPerThread = 100;

BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());
options.CalcBTreeOrder(32, 300);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;

using (BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using (WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, CountPerThread).Run);

    for (int i = 0; i < CountPerThread; i++)
    {
        if(i%2 == 0)
        {
            try {
                dictionary.TryAdd(new KeyInfo(Guid.NewGuid(), i), k => { throw new ExpectedException(); });
            } catch { }
        }
        else
        {
            try
            {
                dictionary.TryRemove(dictionary.First().Key, (k, v) => { throw new ExpectedException(); });
            }
            catch { }
        }
    }

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Const  CountPerThread As Integer = 100

        Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())
        options.CalcBTreeOrder(32, 300)
        options.FileName = TempFile.TempPath
        options.CreateFile = CreatePolicy.Always

        Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
            Using work As New WorkQueue(Environment.ProcessorCount)
                Dim lastError As Exception = Nothing
                work.OnError += Function(o As Object, e As ErrorEventArgs) Do
                    lastError = e.GetException()
                End Function

                Dim i As Integer = 0
                While i < Environment.ProcessorCount
                    work.Enqueue(New ThreadedTest(dictionary, CountPerThread).Run)
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While

                Dim i As Integer = 0
                While i < CountPerThread
                    If i Mod 2 = 0 Then
                        Try
                            dictionary.TryAdd(New KeyInfo(Guid.NewGuid(), i), Function(k)
                            Throw New ExpectedException()

End Function)
                        Catch
                        End Try
                    Else
                        Try
                            dictionary.TryRemove(dictionary.First().Key, Function(k, v)
                            Throw New ExpectedException()

End Function)
                        Catch
                        End Try
                    End If
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While

                Assert.IsTrue(work.Complete(True, 60000))
                Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
            End Using
        End Using

Requirements

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

See Also

Reference

KeyValuePredicate<TKey,TValue> Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
KeyValueUpdate<TKey,TValue> Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : KeyValueUpdate<TKey,TValue> Delegate

key
original

Glossary Item Box

Provides a delegate that performs an atomic update of a key/value pair

Syntax

Visual Basic (Declaration)
Public Delegate Function KeyValueUpdate
    (Of TKey,TValue)( _
   ByVal key As TKey, _
   ByVal original As TValue _
) As TValue
C#
public delegate TValue KeyValueUpdate<TKey,TValue>(
   TKey key,
   TValue original
)

Parameters

key
original

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedDictionary<int, string> data =
    new SynchronizedDictionary<int, string>(new Dictionary<int, string>());

Assert.IsTrue(data.TryAdd(1, "a"));
Assert.IsFalse(data.TryAdd(1, "a"));

Assert.IsTrue(data.TryUpdate(1, "a"));
Assert.IsTrue(data.TryUpdate(1, "c"));
Assert.IsTrue(data.TryUpdate(1, "d", "c"));
Assert.IsFalse(data.TryUpdate(1, "f", "c"));
Assert.AreEqual("d", data[1]);
Assert.IsTrue(data.TryUpdate(1, "a", data[1]));
Assert.AreEqual("a", data[1]);
Assert.IsFalse(data.TryUpdate(2, "b"));

string val;
Assert.IsTrue(data.TryRemove(1, out val) && val == "a");
Assert.IsFalse(data.TryRemove(2, out val));
Assert.AreNotEqual(val, "a");

Assert.IsFalse(data.TryUpdate(1, (k, x) => x.ToUpper()));
data[1] = "a";
data[1] = "b";
Assert.IsTrue(data.TryUpdate(1, (k, x) => x.ToUpper()));
Assert.AreEqual("B", data[1]);
VB.NET Copy Code
Dim data As New SynchronizedDictionary(Of Integer, String)(New Dictionary(Of Integer, String)())

Assert.IsTrue(data.TryAdd(1, "a"))
Assert.IsFalse(data.TryAdd(1, "a"))

Assert.IsTrue(data.TryUpdate(1, "a"))
Assert.IsTrue(data.TryUpdate(1, "c"))
Assert.IsTrue(data.TryUpdate(1, "d", "c"))
Assert.IsFalse(data.TryUpdate(1, "f", "c"))
Assert.AreEqual("d", data(1))
Assert.IsTrue(data.TryUpdate(1, "a", data(1)))
Assert.AreEqual("a", data(1))
Assert.IsFalse(data.TryUpdate(2, "b"))

Dim val As String
Assert.IsTrue(data.TryRemove(1, val) AndAlso val = "a")
Assert.IsFalse(data.TryRemove(2, val))
Assert.AreNotEqual(val, "a")

Assert.IsFalse(data.TryUpdate(1, Function(k, x) x.ToUpper()))
data(1) = "a"
data(1) = "b"
Assert.IsTrue(data.TryUpdate(1, Function(k, x) x.ToUpper()))
Assert.AreEqual("B", data(1))

Requirements

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

See Also

Reference

KeyValueUpdate<TKey,TValue> Members
CSharpTest.Net.Collections Namespace


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
LurchTable.ItemUpdatedMethod<TKey,TValue> Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ItemUpdatedMethod<TKey,TValue> Delegate

previous
next

Glossary Item Box

Method signature for the ItemUpdated event

Syntax

Visual Basic (Declaration)
Public Delegate Sub LurchTable.ItemUpdatedMethod
    (Of TKey,TValue)( _
   ByVal previous As KeyValuePair(Of TKey,TValue), _
   ByVal next As KeyValuePair(Of TKey,TValue) _
)
C#
public delegate void LurchTable.ItemUpdatedMethod<TKey,TValue>(
   KeyValuePair<TKey,TValue> previous,
   KeyValuePair<TKey,TValue> next
)

Parameters

previous
next

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestLurchTable.cs

C# Copy Code
var recorder = new RecordEvents<int, string>();
var test = new LurchTable<int, string>(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer<int>.Default);
test.ItemAdded += recorder.ItemAdded;
test.ItemUpdated += recorder.ItemUpdated;
test.ItemRemoved += recorder.ItemRemoved;
test[1] = "a";
Assert.AreEqual("a", recorder.LastAdded.Value);
test[2] = "b";
Assert.AreEqual("b", recorder.LastAdded.Value);
test[3] = "c";
Assert.AreEqual("c", recorder.LastAdded.Value);
Assert.AreEqual(3, test.Count);
Assert.AreEqual("b", test[2]); //access moves to front..
test[4] = "d";
Assert.AreEqual("d", recorder.LastAdded.Value);
Assert.AreEqual("a", recorder.LastRemove.Value);
test[5] = "e";
Assert.AreEqual("e", recorder.LastAdded.Value);
Assert.AreEqual("c", recorder.LastRemove.Value);
test[2] = "B";
Assert.AreEqual("B", recorder.LastUpdate.Value);
test[6] = "f";
Assert.AreEqual("f", recorder.LastAdded.Value);
Assert.AreEqual("d", recorder.LastRemove.Value);

Assert.AreEqual(3, test.Count); // still 3 items
string value;
Assert.IsTrue(test.TryRemove(5, out value));
Assert.AreEqual("e", value);
Assert.AreEqual("e", recorder.LastRemove.Value);

Assert.AreEqual("B", test.Dequeue().Value);
Assert.AreEqual("f", test.Dequeue().Value);
Assert.AreEqual(0, test.Count);
VB.NET Copy Code
Dim recorder As var = New RecordEvents(Of Integer, String)()
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer(Of Integer).[Default])
test.ItemAdded += recorder.ItemAdded
test.ItemUpdated += recorder.ItemUpdated
test.ItemRemoved += recorder.ItemRemoved
test(1) = "a"
Assert.AreEqual("a", recorder.LastAdded.Value)
test(2) = "b"
Assert.AreEqual("b", recorder.LastAdded.Value)
test(3) = "c"
Assert.AreEqual("c", recorder.LastAdded.Value)
Assert.AreEqual(3, test.Count)
Assert.AreEqual("b", test(2))
'access moves to front..
test(4) = "d"
Assert.AreEqual("d", recorder.LastAdded.Value)
Assert.AreEqual("a", recorder.LastRemove.Value)
test(5) = "e"
Assert.AreEqual("e", recorder.LastAdded.Value)
Assert.AreEqual("c", recorder.LastRemove.Value)
test(2) = "B"
Assert.AreEqual("B", recorder.LastUpdate.Value)
test(6) = "f"
Assert.AreEqual("f", recorder.LastAdded.Value)
Assert.AreEqual("d", recorder.LastRemove.Value)

Assert.AreEqual(3, test.Count)
' still 3 items
Dim value As String
Assert.IsTrue(test.TryRemove(5, value))
Assert.AreEqual("e", value)
Assert.AreEqual("e", recorder.LastRemove.Value)

Assert.AreEqual("B", test.Dequeue().Value)
Assert.AreEqual("f", test.Dequeue().Value)
Assert.AreEqual(0, test.Count)

Requirements

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

See Also

Reference

LurchTable.ItemUpdatedMethod<TKey,TValue> Members
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LurchTable.cs


%%ItemTitle%%

CSharpTest.Net.Commands Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Commands Namespace

Glossary Item Box

Classes

 | Class | Description
Class | AliasNameAttribute | Defines an alias name for a command
Class | AllArgumentsAttribute | Defines that the string[] argument accepts all arguments provided to the command, useage: void MyCommand([AllArguments] string[] arguments) or void MyCommand([AllArguments] string[] arguments, ICommandInterpreter ci)
Class | ArgumentAttribute | Provides all the properties available for an argument.
Class | CommandAttribute | Provides all the properties available for a command.
Class | CommandFilterAttribute | Provides all the properties available for a command 'filter' that is called for every command invoked enabling custom processing of arguments and pre/post processing. The attribute is optional, the format of the the method prototype is not and must be: void (ICommandInterpreter interpreter, ICommandChain chain, string[] arguments);
Class | CommandInterpreter | The primary class involved in providing a command-line interpreter.
Class | DisplayInfoAndValueAttribute | Contains display info and a default value
Class | DisplayInfoAttribute | Provides all the display properties.
Class | HttpHeaderBindingAttribute | Specifies that an argument should be fill in from an HTTP header.
Class | HttpIgnoreAttribute | Specifies that an argument should be ignored for HTTP requests.
Class | HttpRequestFileAttribute | Indicates that the argument is a filename that should be uploaded from the client
Class | HttpResponseFileAttribute | Indicates that the argument is an output filename of the command
Class | HttpResponseTypeAttribute | Sets the response type to a fixed mime-type on a command
Class | IgnoreMemberAttribute | Instructs the CommandInterpreter to ignore a specific method/property
Class | InterpreterException | Base exception for assertions and errors encountered while processing commands
Class | OptionAttribute | Provides all the properties available for an argument.
Class | ServiceCommands | Provide this type to the CommandInterpreter to enable running as a service.
Class | ServiceCommands.Installation | Provide this type to the CommandInterpreter to enable installing any command as a service.

Interfaces

 | Interface | Description
Interface | IArgument | Represents a static or instance method that will be invoked as a command
Interface | ICommand | Represents a static or instance method that will be invoked as a command
Interface | ICommandChain | Defines an interface that allows a command filter to call to next filter in the chain
Interface | ICommandFilter | Represents a static or instance method that is used to filter or pre/post process commands
Interface | ICommandInterpreter | Defines the interface for the command interpreter. If you use this as a parameter it will be provided auto-magically to your command. To avoid conflicts with ordinal argument matching, make this your last argument.
Interface | IDisplayInfo | A base interface that provides name and display information
Interface | IOption | Defines an Option that can be configued/set independantly of the commands. Used with the set/get commands defined by the interpreter.

Delegates

 | Delegate | Description
Delegate | ReadNextCharacter | Used for obtaining input directly from user rather than from the std:in stream

Enumerations

 | Enumeration | Description
Enumeration | DefaultCommands | A list of built-in commands that can be added to the interpreter

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
AliasNameAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : AliasNameAttribute Class

Glossary Item Box

Defines an alias name for a command

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class AliasNameAttribute
   Inherits System.Attribute
C#
[SerializableAttribute()]
public class AliasNameAttribute : System.Attribute

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.AliasNameAttribute

Requirements

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

See Also

Reference

AliasNameAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AliasNameAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : AliasNameAttribute Class

Glossary Item Box

The following tables list the members exposed by AliasNameAttribute.

Public Constructors

 | Name | Description
Public Constructor | AliasNameAttribute Constructor | Constructs an AliasNameAttribute
Top

Public Properties

 | Name | Description
Public Property | Name | Returns the name of the alias
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

AliasNameAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AliasNameAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > AliasNameAttribute Class : AliasNameAttribute Constructor

commandAlias

Glossary Item Box

Constructs an AliasNameAttribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal commandAlias As String _
)
C#
public AliasNameAttribute(
   string commandAlias
)

Parameters

commandAlias

Requirements

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

See Also

Reference

AliasNameAttribute Class
AliasNameAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
AliasNameAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : AliasNameAttribute Class

Glossary Item Box

For a list of all members of this type, see AliasNameAttribute members.

Public Properties

 | Name | Description
Public Property | Name | Returns the name of the alias
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

AliasNameAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > AliasNameAttribute Class : Name Property

Glossary Item Box

Returns the name of the alias

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Name As String
C#
public string Name {get;}

Requirements

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

See Also

Reference

AliasNameAttribute Class
AliasNameAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AllArgumentsAttribute Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : AllArgumentsAttribute Class

Glossary Item Box

Defines that the string[] argument accepts all arguments provided to the command, useage: void MyCommand([AllArguments] string[] arguments) or void MyCommand([AllArguments] string[] arguments, ICommandInterpreter ci)

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class AllArgumentsAttribute
   Inherits System.Attribute
C#
[SerializableAttribute()]
public class AllArgumentsAttribute : System.Attribute

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.AllArgumentsAttribute

Requirements

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

See Also

Reference

AllArgumentsAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AllArgumentsAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : AllArgumentsAttribute Class

Glossary Item Box

The following tables list the members exposed by AllArgumentsAttribute.

Public Constructors

 | Name | Description
Public Constructor | AllArgumentsAttribute Constructor | Constructs an AllArgumentsAttribute
Top

Public Properties

 | Name | Description
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

AllArgumentsAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AllArgumentsAttribute Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > AllArgumentsAttribute Class : AllArgumentsAttribute Constructor

Glossary Item Box

Constructs an AllArgumentsAttribute

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public AllArgumentsAttribute()

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

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

See Also

Reference

AllArgumentsAttribute Class
AllArgumentsAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ArgumentAttribute Class

Glossary Item Box

Provides all the properties available for an argument.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class ArgumentAttribute
   Inherits DisplayInfoAndValueAttribute
   Implements IDisplayInfo
C#
[SerializableAttribute()]
public class ArgumentAttribute : DisplayInfoAndValueAttribute, IDisplayInfo

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.DisplayInfoAttribute
CSharpTest.Net.Commands.DisplayInfoAndValueAttribute
CSharpTest.Net.Commands.ArgumentAttribute

Requirements

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

See Also

Reference

ArgumentAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ArgumentAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ArgumentAttribute Class

Glossary Item Box

The following tables list the members exposed by ArgumentAttribute.

Public Constructors

 | Name | Description
Public Constructor | ArgumentAttribute Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DefaultValue | Gets/sets the default value for the option (Inherited from CSharpTest.Net.Commands.DisplayInfoAndValueAttribute)
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

ArgumentAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ArgumentAttribute Class : ArgumentAttribute Constructor

Glossary Item Box

Overload List

Overload | Description
ArgumentAttribute Constructor() | Constructs the attribute
ArgumentAttribute Constructor(String) | Constructs the attribute
ArgumentAttribute Constructor(String,String[]) | Constructs the attribute

Requirements

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

See Also

Reference

ArgumentAttribute Class
ArgumentAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentAttribute Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ArgumentAttribute Class > ArgumentAttribute Constructor : ArgumentAttribute Constructor()

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public ArgumentAttribute()

Requirements

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

See Also

Reference

ArgumentAttribute Class
ArgumentAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentAttribute Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ArgumentAttribute Class > ArgumentAttribute Constructor : ArgumentAttribute Constructor(String)

displayName

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal displayName As String _
)
C#
public ArgumentAttribute(
   string displayName
)

Parameters

displayName

Requirements

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

See Also

Reference

ArgumentAttribute Class
ArgumentAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentAttribute Constructor(String,String[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ArgumentAttribute Class > ArgumentAttribute Constructor : ArgumentAttribute Constructor(String,String[])

displayName
aliasNames

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal displayName As String, _
   ByVal ParamArray aliasNames() As String _
)
C#
public ArgumentAttribute(
   string displayName,
   params string[] aliasNames
)

Parameters

displayName
aliasNames

Requirements

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

See Also

Reference

ArgumentAttribute Class
ArgumentAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandAttribute Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandAttribute Class

Glossary Item Box

Provides all the properties available for a command.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class CommandAttribute
   Inherits DisplayInfoAttribute
   Implements IDisplayInfo
C#
[SerializableAttribute()]
public class CommandAttribute : DisplayInfoAttribute, IDisplayInfo

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.DisplayInfoAttribute
CSharpTest.Net.Commands.CommandAttribute

Requirements

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

See Also

Reference

CommandAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
CommandAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandAttribute Class

Glossary Item Box

The following tables list the members exposed by CommandAttribute.

Public Constructors

 | Name | Description
Public Constructor | CommandAttribute Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

CommandAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandAttribute Class : CommandAttribute Constructor

Glossary Item Box

Overload List

Overload | Description
CommandAttribute Constructor() | Constructs the attribute
CommandAttribute Constructor(String) | Constructs the attribute
CommandAttribute Constructor(String,String[]) | Constructs the attribute

Requirements

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

See Also

Reference

CommandAttribute Class
CommandAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandAttribute Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandAttribute Class > CommandAttribute Constructor : CommandAttribute Constructor()

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public CommandAttribute()

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

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

See Also

Reference

CommandAttribute Class
CommandAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandAttribute Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandAttribute Class > CommandAttribute Constructor : CommandAttribute Constructor(String)

displayName

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal displayName As String _
)
C#
public CommandAttribute(
   string displayName
)

Parameters

displayName

Requirements

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

See Also

Reference

CommandAttribute Class
CommandAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandAttribute Constructor(String,String[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandAttribute Class > CommandAttribute Constructor : CommandAttribute Constructor(String,String[])

displayName
aliasNames

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal displayName As String, _
   ByVal ParamArray aliasNames() As String _
)
C#
public CommandAttribute(
   string displayName,
   params string[] aliasNames
)

Parameters

displayName
aliasNames

Requirements

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

See Also

Reference

CommandAttribute Class
CommandAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandFilterAttribute Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandFilterAttribute Class

Glossary Item Box

Provides all the properties available for a command 'filter' that is called for every command invoked enabling custom processing of arguments and pre/post processing. The attribute is optional, the format of the the method prototype is not and must be: void (ICommandInterpreter interpreter, ICommandChain chain, string[] arguments);

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class CommandFilterAttribute
   Inherits DisplayInfoAttribute
   Implements IDisplayInfo
C#
[SerializableAttribute()]
public class CommandFilterAttribute : DisplayInfoAttribute, IDisplayInfo

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.DisplayInfoAttribute
CSharpTest.Net.Commands.CommandFilterAttribute

Requirements

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

See Also

Reference

CommandFilterAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
CommandFilterAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandFilterAttribute Class

Glossary Item Box

The following tables list the members exposed by CommandFilterAttribute.

Public Constructors

 | Name | Description
Public Constructor | CommandFilterAttribute Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Keys | Returns the keys associated with this filter
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

CommandFilterAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandFilterAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandFilterAttribute Class : CommandFilterAttribute Constructor

Glossary Item Box

Overload List

Overload | Description
CommandFilterAttribute Constructor(Char) | Constructs the attribute
CommandFilterAttribute Constructor(Char[]) | Constructs the attribute

Requirements

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

See Also

Reference

CommandFilterAttribute Class
CommandFilterAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandFilterAttribute Constructor(Char)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandFilterAttribute Class > CommandFilterAttribute Constructor : CommandFilterAttribute Constructor(Char)

key

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal key As Char _
)
C#
public CommandFilterAttribute(
   char key
)

Parameters

key

Requirements

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

See Also

Reference

CommandFilterAttribute Class
CommandFilterAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandFilterAttribute Constructor(Char[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandFilterAttribute Class > CommandFilterAttribute Constructor : CommandFilterAttribute Constructor(Char[])

keys

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray keys() As Char _
)
C#
public CommandFilterAttribute(
   params char[] keys
)

Parameters

keys

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

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

See Also

Reference

CommandFilterAttribute Class
CommandFilterAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
CommandFilterAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandFilterAttribute Class

Glossary Item Box

For a list of all members of this type, see CommandFilterAttribute members.

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Keys | Returns the keys associated with this filter
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

CommandFilterAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandFilterAttribute Class : Keys Property

Glossary Item Box

Returns the keys associated with this filter

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As Char()
C#
public char[] Keys {get;}

Requirements

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

See Also

Reference

CommandFilterAttribute Class
CommandFilterAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandInterpreter Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandInterpreter Class

Glossary Item Box

The primary class involved in providing a command-line interpreter.

Object Model

CommandInterpreter ClassICommand InterfaceICommandFilter InterfaceIOption Interface

Syntax

Visual Basic (Declaration)
Public Class CommandInterpreter
   Implements ICommandInterpreter
C#
public class CommandInterpreter : ICommandInterpreter

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Inheritance Hierarchy

System.Object
CSharpTest.Net.Commands.CommandInterpreter

Requirements

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

See Also

Reference

CommandInterpreter Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
CommandInterpreter Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandInterpreter Class

Glossary Item Box

The following tables list the members exposed by CommandInterpreter.

Public Constructors

 | Name | Description
Public Constructor | CommandInterpreter Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Commands | Lists all the commands that have been added to the interpreter
Public Property | ErrorLevel | Gets/sets the exit code of the operation/process
Public Property | FilterPrecedence | Defines the filter precedence by appearance order of key character
Public Property | Filters | Lists all the filters that have been added to the interpreter
Public Property | Options | Lists all the options that have been added to the interpreter, use the set/get commands to modify their values.
Public Property | Prompt | Gets/sets the prompt, use "$(OptionName)" to reference options
Public Property | ReadNextCharacter | Reads a keystroke, not from the std:in stream, rather from the console or ui.
Top

Public Methods

 | Name | Description
Public Method | AddCommand | Manually adds a command
Public Method | AddFilter | Adds a command 'filter' that is called for every command invoked enabling custom processing of arguments and pre/post processing.
Public Method | AddGlobalArgumentAttribute | Adds the specified attribute to every command argument by the given name.
Public Method | AddHandler | Overloaded. Adds the static methods to the command list, and static properties to the list of global options (used with commands set/get)
Public Method | AddOption | Manually adds an option
Public Method | ExpandOptions | Expands '$(OptionName)' within the input string to the named option's value.
Public Method | Get | Command to get an option value
Public Method | GetHtmlHelp | Returns the Help as HTML text
static (Shared in Visual Basic) | GetHttpPrefixes | Returns the list of HTTP prefixes that will be used for servicing the hosthttp command.
Public Method | Help | Overloaded. Display the Help text to Console.Out
Public Method | HostHttp | Starts a HttpListener for hosting the commands available on this instance over http/REST
Public Method | RemoveCommand | Manually remove a command
Public Method | Run | Overloaded. Run the command whos name is the first argument with the remaining arguments provided to the command as needed.
Public Method | Set | Overloaded. Command to set the value of an option
Public Method | TryGetCommand | Returns true if the command was found and cmd output parameter is set.
Public Method | TryGetOption | Returns true if the command was found and cmd output parameter is set.
Top

Protected Methods

 | Name | Description
Protected Method | OnError | called to handle error events durring processing
Top

See Also

Reference

CommandInterpreter Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandInterpreter Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : CommandInterpreter Constructor

Glossary Item Box

Overload List

Overload | Description
CommandInterpreter Constructor(Object[]) | Constructs a command-line interpreter from the objects and/or System.Types provided.
CommandInterpreter Constructor(DefaultCommands,Object[]) | Constructs a command-line interpreter from the objects and/or System.Types provided.

Requirements

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

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandInterpreter Constructor(Object[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > CommandInterpreter Constructor : CommandInterpreter Constructor(Object[])

handlers

Glossary Item Box

Constructs a command-line interpreter from the objects and/or System.Types provided.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray handlers() As Object _
)
C#
public CommandInterpreter(
   params object[] handlers
)

Parameters

handlers

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

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

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommandInterpreter Constructor(DefaultCommands,Object[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > CommandInterpreter Constructor : CommandInterpreter Constructor(DefaultCommands,Object[])

defaultCmds
handlers

Glossary Item Box

Constructs a command-line interpreter from the objects and/or System.Types provided.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal defaultCmds As DefaultCommands, _
   ByVal ParamArray handlers() As Object _
)
C#
public CommandInterpreter(
   DefaultCommands defaultCmds,
   params object[] handlers
)

Parameters

defaultCmds
handlers

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string tempPath = Path.GetTempFileName();
string tempPath2 = Path.GetTempFileName();
try
{
    string result;
    CommandInterpreter ci = new CommandInterpreter(
        DefaultCommands.Find | DefaultCommands.PipeCommands | DefaultCommands.IORedirect,
        new TestCommands());

    //Redirect output:
    result = Capture(ci, "Count 100 > " + tempPath);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual(100, File.ReadAllLines(tempPath).Length);

    result = Capture(ci, "Find \"1\" -f:" + tempPath + " |Find \"0\" > " + tempPath2);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual("10\r\n100", File.ReadAllText(tempPath2).Trim());

    //Redirect input:
    result = Capture(ci, "Find \"1\" |Find \"0\" <" + tempPath + " >" + tempPath2);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual("10\r\n100", File.ReadAllText(tempPath2).Trim());

    //Change precedence and watch it fail:
    Assert.IsTrue(ci.FilterPrecedence.StartsWith("<") || ci.FilterPrecedence.StartsWith(">"));
    ci.FilterPrecedence = ci.FilterPrecedence.TrimStart('<', '>');

    result = Capture(ci, "Find \"1\" |Find \"0\" <" + tempPath + " >" + tempPath2);
    Assert.AreEqual(String.Empty, result);
    result = File.ReadAllText(tempPath2).Trim();
    Assert.AreEqual("10\r\n20\r\n30\r\n40\r\n50\r\n60\r\n70\r\n80\r\n90\r\n100", result);
}
finally
{
    File.Delete(tempPath);
    File.Delete(tempPath2);
}
VB.NET Copy Code
Dim tempPath As String = Path.GetTempFileName()
Dim tempPath2 As String = Path.GetTempFileName()
Try
    Dim result As String
    Dim ci As New CommandInterpreter(DefaultCommands.Find Or DefaultCommands.PipeCommands Or DefaultCommands.IORedirect, New TestCommands())

    'Redirect output:
    result = Capture(ci, "Count 100 > " + tempPath)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual(100, File.ReadAllLines(tempPath).Length)

    result = Capture(ci, "Find ""1"" -f:" + tempPath + " |Find ""0"" > " + tempPath2)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual("10" & vbCr & vbLf & "100", File.ReadAllText(tempPath2).Trim())

    'Redirect input:
    result = Capture(ci, "Find ""1"" |Find ""0"" <" + tempPath + " >" + tempPath2)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual("10" & vbCr & vbLf & "100", File.ReadAllText(tempPath2).Trim())

    'Change precedence and watch it fail:
    Assert.IsTrue(ci.FilterPrecedence.StartsWith("<") OrElse ci.FilterPrecedence.StartsWith(">"))
    ci.FilterPrecedence = ci.FilterPrecedence.TrimStart("<"C, ">"C)

    result = Capture(ci, "Find ""1"" |Find ""0"" <" + tempPath + " >" + tempPath2)
    Assert.AreEqual([String].Empty, result)
    result = File.ReadAllText(tempPath2).Trim()
    Assert.AreEqual("10" & vbCr & vbLf & "20" & vbCr & vbLf & "30" & vbCr & vbLf & "40" & vbCr & vbLf & "50" & vbCr & vbLf & "60" & vbCr & vbLf & "70" & vbCr & vbLf & "80" & vbCr & vbLf & "90" & vbCr & vbLf & "100", result)
Finally
    File.Delete(tempPath)
    File.Delete(tempPath2)
End Try

Requirements

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

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
CommandInterpreter Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandInterpreter Class

Glossary Item Box

For a list of all members of this type, see CommandInterpreter members.

Public Methods

 | Name | Description
Public Method | AddCommand | Manually adds a command
Public Method | AddFilter | Adds a command 'filter' that is called for every command invoked enabling custom processing of arguments and pre/post processing.
Public Method | AddGlobalArgumentAttribute | Adds the specified attribute to every command argument by the given name.
Public Method | AddHandler | Overloaded. Adds the static methods to the command list, and static properties to the list of global options (used with commands set/get)
Public Method | AddOption | Manually adds an option
Public Method | ExpandOptions | Expands '$(OptionName)' within the input string to the named option's value.
Public Method | Get | Command to get an option value
Public Method | GetHtmlHelp | Returns the Help as HTML text
static (Shared in Visual Basic) | GetHttpPrefixes | Returns the list of HTTP prefixes that will be used for servicing the hosthttp command.
Public Method | Help | Overloaded. Display the Help text to Console.Out
Public Method | HostHttp | Starts a HttpListener for hosting the commands available on this instance over http/REST
Public Method | RemoveCommand | Manually remove a command
Public Method | Run | Overloaded. Run the command whos name is the first argument with the remaining arguments provided to the command as needed.
Public Method | Set | Overloaded. Command to set the value of an option
Public Method | TryGetCommand | Returns true if the command was found and cmd output parameter is set.
Public Method | TryGetOption | Returns true if the command was found and cmd output parameter is set.
Top

Protected Methods

 | Name | Description
Protected Method | OnError | called to handle error events durring processing
Top

See Also

Reference

CommandInterpreter Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddCommand Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : AddCommand Method

command

Glossary Item Box

Manually adds a command

Syntax

Visual Basic (Declaration)
Public Sub AddCommand( _
   ByVal command As ICommand _
)
C#
public void AddCommand(
   ICommand command
)

Parameters

command

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string result;
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.None, new TestCommands(), typeof(StaticTestFilter));
Assert.AreEqual(1, ci.Filters.Length);
Assert.AreEqual("AddLineNumbers", ci.Filters[0].DisplayName);

result = Capture(ci, "Count 2 /linenumbers");
Assert.AreEqual("1: 1\r\n2: 2", result);

int cmds = ci.Commands.Length;
ci.AddCommand(ci.Filters[0]);
Assert.AreEqual(cmds + 1, ci.Commands.Length);

result = Capture(ci, "AddLineNumbers");
Assert.AreEqual("2", result);
VB.NET Copy Code
Dim result As String
Dim ci As New CommandInterpreter(DefaultCommands.None, New TestCommands(), GetType(StaticTestFilter))
Assert.AreEqual(1, ci.Filters.Length)
Assert.AreEqual("AddLineNumbers", ci.Filters(0).DisplayName)

result = Capture(ci, "Count 2 /linenumbers")
Assert.AreEqual("1: 1" & vbCr & vbLf & "2: 2", result)

Dim cmds As Integer = ci.Commands.Length
ci.AddCommand(ci.Filters(0))
Assert.AreEqual(cmds + 1, ci.Commands.Length)

result = Capture(ci, "AddLineNumbers")
Assert.AreEqual("2", result)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
ICommand

Used By

CommandInterpreter.AddHandler(T)
CommandInterpreter.Run(TextReader)

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddFilter Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : AddFilter Method

filter

Glossary Item Box

Adds a command 'filter' that is called for every command invoked enabling custom processing of arguments and pre/post processing.

Syntax

Visual Basic (Declaration)
Public Sub AddFilter( _
   ByVal filter As ICommandFilter _
)
C#
public void AddFilter(
   ICommandFilter filter
)

Parameters

filter

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
ICommandFilter

Used By

CommandInterpreter.AddHandler(T)

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddGlobalArgumentAttribute Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : AddGlobalArgumentAttribute Method

argumentName
attribute

Glossary Item Box

Adds the specified attribute to every command argument by the given name.

Syntax

Visual Basic (Declaration)
Public Sub AddGlobalArgumentAttribute( _
   ByVal argumentName As String, _
   ByVal attribute As Attribute _
)
C#
public void AddGlobalArgumentAttribute(
   string argumentName,
   Attribute attribute
)

Parameters

argumentName
attribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddHandler Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : AddHandler Method

Glossary Item Box

Adds the static methods to the command list, and static properties to the list of global options (used with commands set/get)

Overload List

Overload | Description
AddHandler(Type) | Adds the static methods to the command list, and static properties to the list of global options (used with commands set/get)
AddHandler<T>(T) | Adds the instance methods to the command list, and instance properties to the list of global options (used with commands set/get)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddHandler(Type) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > AddHandler Method : AddHandler(Type) Method

targetObject

Glossary Item Box

Adds the static methods to the command list, and static properties to the list of global options (used with commands set/get)

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddHandler( _
   ByVal targetObject As Type _
)
C#
public void AddHandler(
   Type targetObject
)

Parameters

targetObject

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.None, new TestCommands());
Assert.AreEqual(2, ci.Options.Length);
Assert.AreEqual("Other", ci.Options[0].DisplayName);
Assert.AreEqual("SomeData", ci.Options[1].DisplayName);

Assert.AreEqual(4, ci.Commands.Length);
Assert.AreEqual("BlowUp", ci.Commands[0].DisplayName);
Assert.AreEqual("Count", ci.Commands[1].DisplayName); // <= alpha-sorted
Assert.AreEqual("ForXtoYbyZ", ci.Commands[2].DisplayName);
Assert.AreEqual("Hidden", ci.Commands[3].DisplayName);

foreach (ICommand c in ci.Commands)
    ci.RemoveCommand(c);
Assert.AreEqual(0, ci.Commands.Length);

ci = new CommandInterpreter(DefaultCommands.None);
Assert.AreEqual(0, ci.Options.Length);
Assert.AreEqual(0, ci.Commands.Length);

ci.AddHandler(typeof(StaticTestFilter));
Assert.AreEqual(0, ci.Options.Length); // the type StaticTestFilter contains filters and no commands/options
Assert.AreEqual(0, ci.Commands.Length);

ci.AddHandler(new TestCommands());
Assert.AreEqual(2, ci.Options.Length);
Assert.AreEqual(4, ci.Commands.Length);
VB.NET Copy Code
Dim ci As New CommandInterpreter(DefaultCommands.None, New TestCommands())
Assert.AreEqual(2, ci.Options.Length)
Assert.AreEqual("Other", ci.Options(0).DisplayName)
Assert.AreEqual("SomeData", ci.Options(1).DisplayName)

Assert.AreEqual(4, ci.Commands.Length)
Assert.AreEqual("BlowUp", ci.Commands(0).DisplayName)
Assert.AreEqual("Count", ci.Commands(1).DisplayName)
' <= alpha-sorted
Assert.AreEqual("ForXtoYbyZ", ci.Commands(2).DisplayName)
Assert.AreEqual("Hidden", ci.Commands(3).DisplayName)

For Each c As ICommand In ci.Commands
    ci.RemoveCommand(c)
Next
Assert.AreEqual(0, ci.Commands.Length)

ci = New CommandInterpreter(DefaultCommands.None)
Assert.AreEqual(0, ci.Options.Length)
Assert.AreEqual(0, ci.Commands.Length)

ci.[AddHandler](GetType(StaticTestFilter))
Assert.AreEqual(0, ci.Options.Length)
' the type StaticTestFilter contains filters and no commands/options
Assert.AreEqual(0, ci.Commands.Length)

ci.[AddHandler](New TestCommands())
Assert.AreEqual(2, ci.Options.Length)
Assert.AreEqual(4, ci.Commands.Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
AddHandler<T>(T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > AddHandler Method : AddHandler<T>(T) Method

targetObject

Glossary Item Box

Adds the instance methods to the command list, and instance properties to the list of global options (used with commands set/get)

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddHandler(Of T As Class)( _
   ByVal targetObject As T _
)
C#
public void AddHandler<T>(
   T targetObject
)
where T: class

Parameters

targetObject

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddOption Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : AddOption Method

option

Glossary Item Box

Manually adds an option

Syntax

Visual Basic (Declaration)
Public Sub AddOption( _
   ByVal option As IOption _
)
C#
public void AddOption(
   IOption option
)

Parameters

option

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
IOption

Used By

CommandInterpreter.AddHandler(T)

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExpandOptions Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : ExpandOptions Method

input

Glossary Item Box

Expands '$(OptionName)' within the input string to the named option's value.

Syntax

Visual Basic (Declaration)
Public Function ExpandOptions( _
   ByVal input As String _
) As String
C#
public string ExpandOptions(
   string input
)

Parameters

input

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Used By

CommandInterpreter.Run(TextReader)

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Get Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Get Method

property

Glossary Item Box

Command to get an option value

Syntax

Visual Basic (Declaration)
Public Function Get( _
   ByVal property As String _
) As Object
C#
public object Get(
   string property
)

Parameters

property

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
Assert.AreEqual(DefaultCommands.Get | DefaultCommands.Set | DefaultCommands.Help, DefaultCommands.Default);
//defaults the DefaultCommands to Get/Set/Help via the enum value of DefaultCommands.Default
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

Assert.AreEqual(2, ci.Options.Length);
Assert.AreEqual("Other", ci.Options[0].DisplayName);
Assert.AreEqual(typeof(int), ci.Options[0].Type);
Assert.AreEqual("SomeData", ci.Options[1].DisplayName);
Assert.AreEqual(typeof(String), ci.Options[1].Type);

TextWriter stdout = Console.Out;
try
{
    Console.SetOut(new StringWriter());// <= Get will also write to console

    Assert.AreEqual(-1, ci.Get("other"));//default was applied
    ci.Set("other", 1);
    Assert.AreEqual(1, ci.Get("other"));

    Assert.AreNotEqual("abc", ci.Get("somedata"));
    ci.Set("somedata", "abc");
    Assert.AreEqual("abc", ci.Get("somedata"));
}
finally
{ Console.SetOut(stdout); }

string result;
result = Capture(ci, "GET Somedata");
Assert.AreEqual("abc", result);
//Set without args lists options
result = Capture(ci, "SET");
Assert.IsTrue(result.ToUpper().Contains("somedata".ToUpper()));
//Set without value returns the current value
result = Capture(ci, "SET somedata");
Assert.AreEqual("abc", result);
result = Capture(ci, "SET somedata 123");
Assert.AreEqual("", result);
result = Capture(ci, "GET somedata");
Assert.AreEqual("123", result);
VB.NET Copy Code
Assert.AreEqual(DefaultCommands.[Get] Or DefaultCommands.[Set] Or DefaultCommands.Help, DefaultCommands.[Default])
'defaults the DefaultCommands to Get/Set/Help via the enum value of DefaultCommands.Default
Dim ci As New CommandInterpreter(New TestCommands())

Assert.AreEqual(2, ci.Options.Length)
Assert.AreEqual("Other", ci.Options(0).DisplayName)
Assert.AreEqual(GetType(Integer), ci.Options(0).Type)
Assert.AreEqual("SomeData", ci.Options(1).DisplayName)
Assert.AreEqual(GetType([String]), ci.Options(1).Type)

Dim stdout As TextWriter = Console.Out
Try
    Console.SetOut(New StringWriter())
    ' <= Get will also write to console
    Assert.AreEqual(-1, ci.[Get]("other"))
    'default was applied
    ci.[Set]("other", 1)
    Assert.AreEqual(1, ci.[Get]("other"))

    Assert.AreNotEqual("abc", ci.[Get]("somedata"))
    ci.[Set]("somedata", "abc")
    Assert.AreEqual("abc", ci.[Get]("somedata"))
Finally
    Console.SetOut(stdout)
End Try

Dim result As String
result = Capture(ci, "GET Somedata")
Assert.AreEqual("abc", result)
'Set without args lists options
result = Capture(ci, "SET")
Assert.IsTrue(result.ToUpper().Contains("somedata".ToUpper()))
'Set without value returns the current value
result = Capture(ci, "SET somedata")
Assert.AreEqual("abc", result)
result = Capture(ci, "SET somedata 123")
Assert.AreEqual("", result)
result = Capture(ci, "GET somedata")
Assert.AreEqual("123", result)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Source Code

Library/Commands/CommandInterpreter.cs

Used By

CommandInterpreter.Set(String,Object,Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHtmlHelp Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : GetHtmlHelp Method

name

Glossary Item Box

Returns the Help as HTML text

Syntax

Visual Basic (Declaration)
Public Function GetHtmlHelp( _
   ByVal name As String _
) As String
C#
public string GetHtmlHelp(
   string name
)

Parameters

name

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.Help, new TestCommands());
string helptext = ci.GetHtmlHelp(null);
Assert.IsTrue(0 == helptext.IndexOf("<html>"));
Assert.IsTrue(helptext.Contains("COMMAND"));
Assert.IsTrue(helptext.IndexOf("SOMEDATA",StringComparison.OrdinalIgnoreCase) >= 0);
VB.NET Copy Code
Dim ci As New CommandInterpreter(DefaultCommands.Help, New TestCommands())
Dim helptext As String = ci.GetHtmlHelp(Nothing)
Assert.IsTrue(0 = helptext.IndexOf("<html>"))
Assert.IsTrue(helptext.Contains("COMMAND"))
Assert.IsTrue(helptext.IndexOf("SOMEDATA", StringComparison.OrdinalIgnoreCase) >= 0)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Source Code

Library/Commands/HelpDisplay.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHttpPrefixes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : GetHttpPrefixes Method

allowRemote
port
rootFolder

Glossary Item Box

Returns the list of HTTP prefixes that will be used for servicing the hosthttp command.

Syntax

Visual Basic (Declaration)
Public Shared Function GetHttpPrefixes( _
   ByVal allowRemote As Boolean, _
   ByVal port As Integer, _
   ByVal rootFolder As String _
) As String()
C#
public static string[] GetHttpPrefixes(
   bool allowRemote,
   int port,
   string rootFolder
)

Parameters

allowRemote
port
rootFolder

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Source Code

Library/Commands/HttpCommands.cs

Used By

CommandInterpreter.HostHttp(Int32,String,Boolean,Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Help Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Help Method

Glossary Item Box

Display the Help text to Console.Out

Overload List

Overload | Description
Help(String) | Display the Help text to Console.Out
Help(String,Boolean) | Display the Help text to Console.Out

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Help(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Help Method : Help(String) Method

name

Glossary Item Box

Display the Help text to Console.Out

Syntax

Visual Basic (Declaration)
Public Overloads Sub Help( _
   ByVal name As String _
)
C#
public void Help(
   string name
)

Parameters

name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/HelpDisplay.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Help(String,Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Help Method : Help(String,Boolean) Method

name
viewAsHtml

Glossary Item Box

Display the Help text to Console.Out

Syntax

Visual Basic (Declaration)
Public Overloads Sub Help( _
   ByVal name As String, _
   ByVal viewAsHtml As Boolean _
)
C#
public void Help(
   string name,
   bool viewAsHtml
)

Parameters

name
viewAsHtml

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Used By

CommandInterpreter.Help(String)

Source Code

Library/Commands/HelpDisplay.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HostHttp Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : HostHttp Method

port
rootFolder
allowRemote
startBrowser

Glossary Item Box

Starts a HttpListener for hosting the commands available on this instance over http/REST

Syntax

Visual Basic (Declaration)
Public Sub HostHttp( _
   ByVal port As Integer, _
   ByVal rootFolder As String, _
   ByVal allowRemote As Boolean, _
   ByVal startBrowser As Boolean _
)
C#
public void HostHttp(
   int port,
   string rootFolder,
   bool allowRemote,
   bool startBrowser
)

Parameters

port
rootFolder
allowRemote
startBrowser

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnError Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : OnError Method

error

Glossary Item Box

called to handle error events durring processing

Syntax

Visual Basic (Declaration)
Protected Overridable Sub OnError( _
   ByVal error As Exception _
)
C#
protected virtual void OnError(
   Exception error
)

Parameters

error

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Used By

CommandInterpreter.Run(String[])
CommandInterpreter.Run(TextReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
RemoveCommand Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : RemoveCommand Method

command

Glossary Item Box

Manually remove a command

Syntax

Visual Basic (Declaration)
Public Sub RemoveCommand( _
   ByVal command As ICommand _
)
C#
public void RemoveCommand(
   ICommand command
)

Parameters

command

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.None, new TestCommands());
Assert.AreEqual(2, ci.Options.Length);
Assert.AreEqual("Other", ci.Options[0].DisplayName);
Assert.AreEqual("SomeData", ci.Options[1].DisplayName);

Assert.AreEqual(4, ci.Commands.Length);
Assert.AreEqual("BlowUp", ci.Commands[0].DisplayName);
Assert.AreEqual("Count", ci.Commands[1].DisplayName); // <= alpha-sorted
Assert.AreEqual("ForXtoYbyZ", ci.Commands[2].DisplayName);
Assert.AreEqual("Hidden", ci.Commands[3].DisplayName);

foreach (ICommand c in ci.Commands)
    ci.RemoveCommand(c);
Assert.AreEqual(0, ci.Commands.Length);

ci = new CommandInterpreter(DefaultCommands.None);
Assert.AreEqual(0, ci.Options.Length);
Assert.AreEqual(0, ci.Commands.Length);

ci.AddHandler(typeof(StaticTestFilter));
Assert.AreEqual(0, ci.Options.Length); // the type StaticTestFilter contains filters and no commands/options
Assert.AreEqual(0, ci.Commands.Length);

ci.AddHandler(new TestCommands());
Assert.AreEqual(2, ci.Options.Length);
Assert.AreEqual(4, ci.Commands.Length);
VB.NET Copy Code
Dim ci As New CommandInterpreter(DefaultCommands.None, New TestCommands())
Assert.AreEqual(2, ci.Options.Length)
Assert.AreEqual("Other", ci.Options(0).DisplayName)
Assert.AreEqual("SomeData", ci.Options(1).DisplayName)

Assert.AreEqual(4, ci.Commands.Length)
Assert.AreEqual("BlowUp", ci.Commands(0).DisplayName)
Assert.AreEqual("Count", ci.Commands(1).DisplayName)
' <= alpha-sorted
Assert.AreEqual("ForXtoYbyZ", ci.Commands(2).DisplayName)
Assert.AreEqual("Hidden", ci.Commands(3).DisplayName)

For Each c As ICommand In ci.Commands
    ci.RemoveCommand(c)
Next
Assert.AreEqual(0, ci.Commands.Length)

ci = New CommandInterpreter(DefaultCommands.None)
Assert.AreEqual(0, ci.Options.Length)
Assert.AreEqual(0, ci.Commands.Length)

ci.[AddHandler](GetType(StaticTestFilter))
Assert.AreEqual(0, ci.Options.Length)
' the type StaticTestFilter contains filters and no commands/options
Assert.AreEqual(0, ci.Commands.Length)

ci.[AddHandler](New TestCommands())
Assert.AreEqual(2, ci.Options.Length)
Assert.AreEqual(4, ci.Commands.Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
ICommand

Source Code

Library/Commands/CommandInterpreter.cs

Used By

CommandInterpreter.Run(TextReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
Run Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Run Method

Glossary Item Box

Run the command whos name is the first argument with the remaining arguments provided to the command as needed.

Overload List

Overload | Description
Run(String[]) | Run the command whos name is the first argument with the remaining arguments provided to the command as needed.
Run(String[],TextWriter,TextWriter,TextReader) | Run the command whos name is the first argument with the remaining arguments provided to the command as needed.
Run(TextReader) | Runs each line from the reader until EOF, can be used with Console.In

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Run Method : Run(String[]) Method

arguments

Glossary Item Box

Run the command whos name is the first argument with the remaining arguments provided to the command as needed.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Run( _
   ByVal ParamArray arguments() As String _
)
C#
public void Run(
   params string[] arguments
)

Parameters

arguments

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
Assert.AreEqual(DefaultCommands.Get | DefaultCommands.Set | DefaultCommands.Help, DefaultCommands.Default);
TestCommands cmds = new TestCommands();
CommandInterpreter ci = new CommandInterpreter(cmds);
cmds.OtherData = 42;
Assert.AreEqual("42", Capture(ci, "GET Other"));
cmds.SomeData = "one-two-three";
Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"));

string options = Capture(ci, "SET");
cmds.OtherData = 0;
cmds.SomeData = String.Empty;
Assert.AreEqual("0", Capture(ci, "GET Other"));
Assert.AreEqual(String.Empty, Capture(ci, "GET SomeData"));

TextReader input = Console.In;
try
{
    Console.SetIn(new StringReader(options));//feed the output of SET back to SET
    ci.Run("SET", "/readInput");
}
finally { Console.SetIn(input); }

//should now be restored
Assert.AreEqual("42", Capture(ci, "GET Other"));
Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"));
VB.NET Copy Code
Assert.AreEqual(DefaultCommands.[Get] Or DefaultCommands.[Set] Or DefaultCommands.Help, DefaultCommands.[Default])
Dim cmds As New TestCommands()
Dim ci As New CommandInterpreter(cmds)
cmds.OtherData = 42
Assert.AreEqual("42", Capture(ci, "GET Other"))
cmds.SomeData = "one-two-three"
Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"))

Dim options As String = Capture(ci, "SET")
cmds.OtherData = 0
cmds.SomeData = [String].Empty
Assert.AreEqual("0", Capture(ci, "GET Other"))
Assert.AreEqual([String].Empty, Capture(ci, "GET SomeData"))

Dim input As TextReader = Console.[In]
Try
    Console.SetIn(New StringReader(options))
    'feed the output of SET back to SET
    ci.Run("SET", "/readInput")
Finally
    Console.SetIn(input)
End Try

'should now be restored
Assert.AreEqual("42", Capture(ci, "GET Other"))
Assert.AreEqual("one-two-three", Capture(ci, "GET SomeData"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/CommandInterpreter.cs

Used By

CommandInterpreter.Run(TextReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(String[],TextWriter,TextWriter,TextReader) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Run Method : Run(String[],TextWriter,TextWriter,TextReader) Method

arguments
mapstdout
mapstderr
mapstdin

Glossary Item Box

Run the command whos name is the first argument with the remaining arguments provided to the command as needed.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Run( _
   ByVal arguments() As String, _
   ByVal mapstdout As TextWriter, _
   ByVal mapstderr As TextWriter, _
   ByVal mapstdin As TextReader _
)
C#
public void Run(
   string[] arguments,
   TextWriter mapstdout,
   TextWriter mapstderr,
   TextReader mapstdin
)

Parameters

arguments
mapstdout
mapstderr
mapstdin

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(TextReader) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Run Method : Run(TextReader) Method

input

Glossary Item Box

Runs each line from the reader until EOF, can be used with Console.In

Syntax

Visual Basic (Declaration)
Public Overloads Sub Run( _
   ByVal input As TextReader _
)
C#
public void Run(
   TextReader input
)

Parameters

input

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
TextWriter stdout = Console.Out, stderr = Console.Error;
try
{
    StringWriter sw = new StringWriter();
    Console.SetError(sw);
    Console.SetOut(sw);

    string result;
    CommandInterpreter ci = new CommandInterpreter(new TestCommands());

    ci.Prompt = "$(MissingProperty)";
    ci.Run(new StringReader("EXIT"));
    result = sw.ToString();
    Assert.IsTrue(result.StartsWith("Unknown option specified: MissingProperty"));
    ci.Prompt = String.Empty;

    sw.GetStringBuilder().Length = 0;//clear
    ci.Run(new ErrorReader());

    result = sw.ToString();
    Assert.IsTrue(result.StartsWith(typeof(NotImplementedException).FullName));
}
finally
{
    Console.SetOut(stdout);
    Console.SetError(stderr);
}
VB.NET Copy Code
Dim stdout As TextWriter = Console.Out, stderr As TextWriter = Console.[Error]
Try
    Dim sw As New StringWriter()
    Console.SetError(sw)
    Console.SetOut(sw)

    Dim result As String
    Dim ci As New CommandInterpreter(New TestCommands())

    ci.Prompt = "$(MissingProperty)"
    ci.Run(New StringReader("EXIT"))
    result = sw.ToString()
    Assert.IsTrue(result.StartsWith("Unknown option specified: MissingProperty"))
    ci.Prompt = [String].Empty

    sw.GetStringBuilder().Length = 0
    'clear
    ci.Run(New ErrorReader())

    result = sw.ToString()
    Assert.IsTrue(result.StartsWith(GetType(NotImplementedException).FullName))
Finally
    Console.SetOut(stdout)
    Console.SetError(stderr)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Set Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Set Method

Glossary Item Box

Command to set the value of an option

Overload List

Overload | Description
Set(String,Object) | Command to set the value of an option
Set(String,Object,Boolean) | Command to set the value of an option

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Set(String,Object) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Set Method : Set(String,Object) Method

property
value

Glossary Item Box

Command to set the value of an option

Syntax

Visual Basic (Declaration)
Public Overloads Sub Set( _
   ByVal property As String, _
   ByVal value As Object _
)
C#
public void Set(
   string property,
   object value
)

Parameters

property
value

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string result;
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.Echo | DefaultCommands.Prompt, new TestCommands());

ci.Set("SomeData", "TEST_Data");
result = Capture(ci, "ECHO $(SOMEDATA)");
Assert.AreEqual("TEST_Data", result);

ci.Set("SomeData", "TEST Data");
result = Capture(ci, "ECHO $(SOMEDATA)");
Assert.AreEqual("\"TEST Data\"", result); // <= Echo will quote & escape while-space and quotes "

result = Capture(ci, "ECHO $(MissingProperty)");
Assert.AreEqual("Unknown option specified: MissingProperty", result);

result = Capture(ci, "ECHO (MissingProperty) (xx xy  abc"); // <= escape '$' with ''
Assert.AreEqual("$(MissingProperty) $(xx x$y $ abc", result)
' <= extra '$' was removed.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Set(String,Object,Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Set Method : Set(String,Object,Boolean) Method

property
value
readInput

Glossary Item Box

Command to set the value of an option

Syntax

Visual Basic (Declaration)
Public Overloads Sub Set( _
   ByVal property As String, _
   ByVal value As Object, _
   ByVal readInput As Boolean _
)
C#
public void Set(
   string property,
   object value,
   bool readInput
)

Parameters

property
value
readInput

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
Overload List

Used By

CommandInterpreter.Set(String,Object)
CommandInterpreter.Set(String,Object,Boolean)

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetCommand Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : TryGetCommand Method

name
cmd

Glossary Item Box

Returns true if the command was found and cmd output parameter is set.

Syntax

Visual Basic (Declaration)
Public Function TryGetCommand( _
   ByVal name As String, _
   ByRef cmd As ICommand _
) As Boolean
C#
public bool TryGetCommand(
   string name,
   out ICommand cmd
)

Parameters

name
cmd

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
ICommand

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetOption Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : TryGetOption Method

name
cmd

Glossary Item Box

Returns true if the command was found and cmd output parameter is set.

Syntax

Visual Basic (Declaration)
Public Function TryGetOption( _
   ByVal name As String, _
   ByRef cmd As IOption _
) As Boolean
C#
public bool TryGetOption(
   string name,
   out IOption cmd
)

Parameters

name
cmd

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
IOption

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
CommandInterpreter Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandInterpreter Class

Glossary Item Box

For a list of all members of this type, see CommandInterpreter members.

Public Properties

 | Name | Description
Public Property | Commands | Lists all the commands that have been added to the interpreter
Public Property | ErrorLevel | Gets/sets the exit code of the operation/process
Public Property | FilterPrecedence | Defines the filter precedence by appearance order of key character
Public Property | Filters | Lists all the filters that have been added to the interpreter
Public Property | Options | Lists all the options that have been added to the interpreter, use the set/get commands to modify their values.
Public Property | Prompt | Gets/sets the prompt, use "$(OptionName)" to reference options
Public Property | ReadNextCharacter | Reads a keystroke, not from the std:in stream, rather from the console or ui.
Top

See Also

Reference

CommandInterpreter Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Commands Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Commands Property

Glossary Item Box

Lists all the commands that have been added to the interpreter

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Commands As ICommand()
C#
public ICommand[] Commands {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string result;
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.None, new TestCommands(), typeof(StaticTestFilter));
Assert.AreEqual(1, ci.Filters.Length);
Assert.AreEqual("AddLineNumbers", ci.Filters[0].DisplayName);

result = Capture(ci, "Count 2 /linenumbers");
Assert.AreEqual("1: 1\r\n2: 2", result);

int cmds = ci.Commands.Length;
ci.AddCommand(ci.Filters[0]);
Assert.AreEqual(cmds + 1, ci.Commands.Length);

result = Capture(ci, "AddLineNumbers");
Assert.AreEqual("2", result);
VB.NET Copy Code
Dim result As String
Dim ci As New CommandInterpreter(DefaultCommands.None, New TestCommands(), GetType(StaticTestFilter))
Assert.AreEqual(1, ci.Filters.Length)
Assert.AreEqual("AddLineNumbers", ci.Filters(0).DisplayName)

result = Capture(ci, "Count 2 /linenumbers")
Assert.AreEqual("1: 1" & vbCr & vbLf & "2: 2", result)

Dim cmds As Integer = ci.Commands.Length
ci.AddCommand(ci.Filters(0))
Assert.AreEqual(cmds + 1, ci.Commands.Length)

result = Capture(ci, "AddLineNumbers")
Assert.AreEqual("2", result)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
ICommand

Used By

String CommandInterpreter.GetHtmlHelp(String)
CommandInterpreter.Help(String,Boolean)

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ErrorLevel Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : ErrorLevel Property

Glossary Item Box

Gets/sets the exit code of the operation/process

Syntax

Visual Basic (Declaration)
Public Property ErrorLevel As Integer
C#
public int ErrorLevel {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string result;
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.Get | DefaultCommands.Set, new TestCommands());

result = Capture(ci, "Count 2");
Assert.AreEqual("1\r\n2", result);

result = Capture(ci, "Count /backwards 2");
Assert.AreEqual("2\r\n1", result);
result = Capture(ci, "Count 2 /backwards");
Assert.AreEqual("2\r\n1", result);
result = Capture(ci, "Count -n:2 /backwards:true");
Assert.AreEqual("2\r\n1", result);

result = Capture(ci, "Count 2 /t:a /t:b");
Assert.AreEqual("1 a\r\n2 b", result);

//Argument not found:
result = Capture(ci, "Count");
Assert.AreEqual("The value for number is required.", result);

//Non-ApplicationExcpetion dumps stack:
ci.ErrorLevel = 0;
result = Capture(ci, "BlowUp false");
Assert.AreNotEqual(0, ci.ErrorLevel);
Assert.IsTrue(result.Contains("System.Exception: BlowUp"), "Expected \"System.Exception: BlowUp\" in {0}", result);

//ApplicationExcpetion dumps message only:
ci.ErrorLevel = 0;
result = Capture(ci, "BlowUp true");
Assert.AreNotEqual(0, ci.ErrorLevel);
Assert.AreEqual("BlowUp", result);
VB.NET Copy Code
Dim result As String
Dim ci As New CommandInterpreter(DefaultCommands.[Get] Or DefaultCommands.[Set], New TestCommands())

result = Capture(ci, "Count 2")
Assert.AreEqual("1" & vbCr & vbLf & "2", result)

result = Capture(ci, "Count /backwards 2")
Assert.AreEqual("2" & vbCr & vbLf & "1", result)
result = Capture(ci, "Count 2 /backwards")
Assert.AreEqual("2" & vbCr & vbLf & "1", result)
result = Capture(ci, "Count -n:2 /backwards:true")
Assert.AreEqual("2" & vbCr & vbLf & "1", result)

result = Capture(ci, "Count 2 /t:a /t:b")
Assert.AreEqual("1 a" & vbCr & vbLf & "2 b", result)

'Argument not found:
result = Capture(ci, "Count")
Assert.AreEqual("The value for number is required.", result)

'Non-ApplicationExcpetion dumps stack:
ci.ErrorLevel = 0
result = Capture(ci, "BlowUp false")
Assert.AreNotEqual(0, ci.ErrorLevel)
Assert.IsTrue(result.Contains("System.Exception: BlowUp"), "Expected ""System.Exception: BlowUp"" in {0}", result)

'ApplicationExcpetion dumps message only:
ci.ErrorLevel = 0
result = Capture(ci, "BlowUp true")
Assert.AreNotEqual(0, ci.ErrorLevel)
Assert.AreEqual("BlowUp", result)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FilterPrecedence Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : FilterPrecedence Property

Glossary Item Box

Defines the filter precedence by appearance order of key character

Syntax

Visual Basic (Declaration)
Public Property FilterPrecedence As String
C#
public string FilterPrecedence {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string tempPath = Path.GetTempFileName();
string tempPath2 = Path.GetTempFileName();
try
{
    string result;
    CommandInterpreter ci = new CommandInterpreter(
        DefaultCommands.Find | DefaultCommands.PipeCommands | DefaultCommands.IORedirect,
        new TestCommands());

    //Redirect output:
    result = Capture(ci, "Count 100 > " + tempPath);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual(100, File.ReadAllLines(tempPath).Length);

    result = Capture(ci, "Find \"1\" -f:" + tempPath + " |Find \"0\" > " + tempPath2);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual("10\r\n100", File.ReadAllText(tempPath2).Trim());

    //Redirect input:
    result = Capture(ci, "Find \"1\" |Find \"0\" <" + tempPath + " >" + tempPath2);
    Assert.AreEqual(String.Empty, result);
    Assert.AreEqual("10\r\n100", File.ReadAllText(tempPath2).Trim());

    //Change precedence and watch it fail:
    Assert.IsTrue(ci.FilterPrecedence.StartsWith("<") || ci.FilterPrecedence.StartsWith(">"));
    ci.FilterPrecedence = ci.FilterPrecedence.TrimStart('<', '>');

    result = Capture(ci, "Find \"1\" |Find \"0\" <" + tempPath + " >" + tempPath2);
    Assert.AreEqual(String.Empty, result);
    result = File.ReadAllText(tempPath2).Trim();
    Assert.AreEqual("10\r\n20\r\n30\r\n40\r\n50\r\n60\r\n70\r\n80\r\n90\r\n100", result);
}
finally
{
    File.Delete(tempPath);
    File.Delete(tempPath2);
}
VB.NET Copy Code
Dim tempPath As String = Path.GetTempFileName()
Dim tempPath2 As String = Path.GetTempFileName()
Try
    Dim result As String
    Dim ci As New CommandInterpreter(DefaultCommands.Find Or DefaultCommands.PipeCommands Or DefaultCommands.IORedirect, New TestCommands())

    'Redirect output:
    result = Capture(ci, "Count 100 > " + tempPath)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual(100, File.ReadAllLines(tempPath).Length)

    result = Capture(ci, "Find ""1"" -f:" + tempPath + " |Find ""0"" > " + tempPath2)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual("10" & vbCr & vbLf & "100", File.ReadAllText(tempPath2).Trim())

    'Redirect input:
    result = Capture(ci, "Find ""1"" |Find ""0"" <" + tempPath + " >" + tempPath2)
    Assert.AreEqual([String].Empty, result)
    Assert.AreEqual("10" & vbCr & vbLf & "100", File.ReadAllText(tempPath2).Trim())

    'Change precedence and watch it fail:
    Assert.IsTrue(ci.FilterPrecedence.StartsWith("<") OrElse ci.FilterPrecedence.StartsWith(">"))
    ci.FilterPrecedence = ci.FilterPrecedence.TrimStart("<"C, ">"C)

    result = Capture(ci, "Find ""1"" |Find ""0"" <" + tempPath + " >" + tempPath2)
    Assert.AreEqual([String].Empty, result)
    result = File.ReadAllText(tempPath2).Trim()
    Assert.AreEqual("10" & vbCr & vbLf & "20" & vbCr & vbLf & "30" & vbCr & vbLf & "40" & vbCr & vbLf & "50" & vbCr & vbLf & "60" & vbCr & vbLf & "70" & vbCr & vbLf & "80" & vbCr & vbLf & "90" & vbCr & vbLf & "100", result)
Finally
    File.Delete(tempPath)
    File.Delete(tempPath2)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Filters Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Filters Property

Glossary Item Box

Lists all the filters that have been added to the interpreter

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Filters As ICommandFilter()
C#
public ICommandFilter[] Filters {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string result;
CommandInterpreter ci = new CommandInterpreter(DefaultCommands.None, new TestCommands(), typeof(StaticTestFilter));
Assert.AreEqual(1, ci.Filters.Length);
Assert.AreEqual("AddLineNumbers", ci.Filters[0].DisplayName);

result = Capture(ci, "Count 2 /linenumbers");
Assert.AreEqual("1: 1\r\n2: 2", result);

int cmds = ci.Commands.Length;
ci.AddCommand(ci.Filters[0]);
Assert.AreEqual(cmds + 1, ci.Commands.Length);

result = Capture(ci, "AddLineNumbers");
Assert.AreEqual("2", result);
VB.NET Copy Code
Dim result As String
Dim ci As New CommandInterpreter(DefaultCommands.None, New TestCommands(), GetType(StaticTestFilter))
Assert.AreEqual(1, ci.Filters.Length)
Assert.AreEqual("AddLineNumbers", ci.Filters(0).DisplayName)

result = Capture(ci, "Count 2 /linenumbers")
Assert.AreEqual("1: 1" & vbCr & vbLf & "2: 2", result)

Dim cmds As Integer = ci.Commands.Length
ci.AddCommand(ci.Filters(0))
Assert.AreEqual(cmds + 1, ci.Commands.Length)

result = Capture(ci, "AddLineNumbers")
Assert.AreEqual("2", result)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
ICommandFilter

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Options Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Options Property

Glossary Item Box

Lists all the options that have been added to the interpreter, use the set/get commands to modify their values.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Options As IOption()
C#
public IOption[] Options {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
IOption

Used By

CommandInterpreter.Set(String,Object,Boolean)
String CommandInterpreter.GetHtmlHelp(String)
CommandInterpreter.Help(String,Boolean)

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Prompt Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Prompt Property

Glossary Item Box

Gets/sets the prompt, use "$(OptionName)" to reference options

Syntax

Visual Basic (Declaration)
Public Property Prompt As String
C#
public string Prompt {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
TextWriter stdout = Console.Out, stderr = Console.Error;
try
{
    StringWriter sw = new StringWriter();
    Console.SetError(sw);
    Console.SetOut(sw);

    string result;
    CommandInterpreter ci = new CommandInterpreter(new TestCommands());

    ci.Prompt = "$(MissingProperty)";
    ci.Run(new StringReader("EXIT"));
    result = sw.ToString();
    Assert.IsTrue(result.StartsWith("Unknown option specified: MissingProperty"));
    ci.Prompt = String.Empty;

    sw.GetStringBuilder().Length = 0;//clear
    ci.Run(new ErrorReader());

    result = sw.ToString();
    Assert.IsTrue(result.StartsWith(typeof(NotImplementedException).FullName));
}
finally
{
    Console.SetOut(stdout);
    Console.SetError(stderr);
}
VB.NET Copy Code
Dim stdout As TextWriter = Console.Out, stderr As TextWriter = Console.[Error]
Try
    Dim sw As New StringWriter()
    Console.SetError(sw)
    Console.SetOut(sw)

    Dim result As String
    Dim ci As New CommandInterpreter(New TestCommands())

    ci.Prompt = "$(MissingProperty)"
    ci.Run(New StringReader("EXIT"))
    result = sw.ToString()
    Assert.IsTrue(result.StartsWith("Unknown option specified: MissingProperty"))
    ci.Prompt = [String].Empty

    sw.GetStringBuilder().Length = 0
    'clear
    ci.Run(New ErrorReader())

    result = sw.ToString()
    Assert.IsTrue(result.StartsWith(GetType(NotImplementedException).FullName))
Finally
    Console.SetOut(stdout)
    Console.SetError(stderr)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members

Used By

CommandInterpreter.Run(TextReader)

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadNextCharacter Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : ReadNextCharacter Property

Glossary Item Box

Reads a keystroke, not from the std:in stream, rather from the console or ui.

Syntax

Visual Basic (Declaration)
Public Property ReadNextCharacter As ReadNextCharacter
C#
public ReadNextCharacter ReadNextCharacter {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string result;
CommandInterpreter ci = new CommandInterpreter(
    DefaultCommands.More | DefaultCommands.PipeCommands,
    new TestCommands());

//replace the keystroke wait
ci.ReadNextCharacter = GetSpace;

string input = String.Format("Count {0} | MORE", (int)(WindowHeight * 1.5));

result = Capture(ci, input);

StringReader sr = new StringReader(result);
int moreFound = 0;
int index = 0;
string line;
while( null != (line = sr.ReadLine()))
{
    if( line == "-- More --" )
        moreFound++;
    else
        Assert.AreEqual((++index).ToString(), line);
}

Assert.AreEqual(1, moreFound);
VB.NET Copy Code
Dim result As String
Dim ci As New CommandInterpreter(DefaultCommands.More Or DefaultCommands.PipeCommands, New TestCommands())

'replace the keystroke wait
ci.ReadNextCharacter = GetSpace

Dim input As String = [String].Format("Count {0} | MORE", DirectCast((WindowHeight * 1.5), Integer))

result = Capture(ci, input)

Dim sr As New StringReader(result)
Dim moreFound As Integer = 0
Dim index As Integer = 0
Dim line As String
While Nothing <> (line = sr.ReadLine())
    If line = "-- More --" Then
        System.Math.Max(System.Threading.Interlocked.Increment(moreFound),moreFound - 1)
    Else
        Assert.AreEqual((System.Threading.Interlocked.Increment(index)).ToString(), line)
    End If
End While

Assert.AreEqual(1, moreFound)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CommandInterpreter Class
CommandInterpreter Members
ReadNextCharacter

Source Code

Library/Commands/CommandInterpreter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisplayInfoAndValueAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DisplayInfoAndValueAttribute Class

Glossary Item Box

Contains display info and a default value

Syntax

Visual Basic (Declaration)
Public MustInherit Class DisplayInfoAndValueAttribute
   Inherits DisplayInfoAttribute
   Implements IDisplayInfo
C#
public abstract class DisplayInfoAndValueAttribute : DisplayInfoAttribute, IDisplayInfo

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.DisplayInfoAttribute
CSharpTest.Net.Commands.DisplayInfoAndValueAttribute
CSharpTest.Net.Commands.ArgumentAttribute
CSharpTest.Net.Commands.OptionAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAndValueAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DisplayInfoAndValueAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DisplayInfoAndValueAttribute Class

Glossary Item Box

The following tables list the members exposed by DisplayInfoAndValueAttribute.

Protected Constructors

 | Name | Description
Protected Constructor | DisplayInfoAndValueAttribute Constructor | Constructs the attribute
Top

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DefaultValue | Gets/sets the default value for the option
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

DisplayInfoAndValueAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisplayInfoAndValueAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAndValueAttribute Class : DisplayInfoAndValueAttribute Constructor

displayName
aliasNames

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal displayName As String, _
   ByVal ParamArray aliasNames() As String _
)
C#
protected DisplayInfoAndValueAttribute(
   string displayName,
   params string[] aliasNames
)

Parameters

displayName
aliasNames

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAndValueAttribute Class
DisplayInfoAndValueAttribute Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DisplayInfoAndValueAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DisplayInfoAndValueAttribute Class

Glossary Item Box

For a list of all members of this type, see DisplayInfoAndValueAttribute members.

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DefaultValue | Gets/sets the default value for the option
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Top

See Also

Reference

DisplayInfoAndValueAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultValue Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAndValueAttribute Class : DefaultValue Property

Glossary Item Box

Gets/sets the default value for the option

Syntax

Visual Basic (Declaration)
Public Property DefaultValue As Object
C#
public object DefaultValue {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAndValueAttribute Class
DisplayInfoAndValueAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisplayInfoAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DisplayInfoAttribute Class

Glossary Item Box

Provides all the display properties.

Syntax

Visual Basic (Declaration)
Public MustInherit Class DisplayInfoAttribute
   Inherits System.Attribute
   Implements IDisplayInfo
C#
public abstract class DisplayInfoAttribute : System.Attribute, IDisplayInfo

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.DisplayInfoAttribute
CSharpTest.Net.Commands.CommandAttribute
CSharpTest.Net.Commands.CommandFilterAttribute
CSharpTest.Net.Commands.DisplayInfoAndValueAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DisplayInfoAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DisplayInfoAttribute Class

Glossary Item Box

The following tables list the members exposed by DisplayInfoAttribute.

Protected Constructors

 | Name | Description
Protected Constructor | DisplayInfoAttribute Constructor | Constructs the attribute
Top

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names
Public Property | AllNames | Returns the name list
Public Property | Category | Returns the Category
Public Property | Description | Returns the Description
Public Property | DisplayName | Returns the DisplayName
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

DisplayInfoAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisplayInfoAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAttribute Class : DisplayInfoAttribute Constructor

displayName
aliasNames

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal displayName As String, _
   ByVal ParamArray aliasNames() As String _
)
C#
protected DisplayInfoAttribute(
   string displayName,
   params string[] aliasNames
)

Parameters

displayName
aliasNames

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAttribute Class
DisplayInfoAttribute Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DisplayInfoAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DisplayInfoAttribute Class

Glossary Item Box

For a list of all members of this type, see DisplayInfoAttribute members.

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names
Public Property | AllNames | Returns the name list
Public Property | Category | Returns the Category
Public Property | Description | Returns the Description
Public Property | DisplayName | Returns the DisplayName
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command
Top

See Also

Reference

DisplayInfoAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AliasNames Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAttribute Class : AliasNames Property

Glossary Item Box

Just the alias names

Syntax

Visual Basic (Declaration)
Public Property AliasNames As String()
C#
public string[] AliasNames {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAttribute Class
DisplayInfoAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AllNames Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAttribute Class : AllNames Property

Glossary Item Box

Returns the name list

Syntax

Visual Basic (Declaration)
Public ReadOnly Property AllNames As String()
C#
public string[] AllNames {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAttribute Class
DisplayInfoAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Category Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAttribute Class : Category Property

Glossary Item Box

Returns the Category

Syntax

Visual Basic (Declaration)
Public Property Category As String
C#
public string Category {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAttribute Class
DisplayInfoAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Description Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAttribute Class : Description Property

Glossary Item Box

Returns the Description

Syntax

Visual Basic (Declaration)
Public Property Description As String
C#
public string Description {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAttribute Class
DisplayInfoAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisplayName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAttribute Class : DisplayName Property

Glossary Item Box

Returns the DisplayName

Syntax

Visual Basic (Declaration)
Public Property DisplayName As String
C#
public string DisplayName {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAttribute Class
DisplayInfoAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Visible Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > DisplayInfoAttribute Class : Visible Property

Glossary Item Box

Returns the visibility of the command

Syntax

Visual Basic (Declaration)
Public Overridable Property Visible As Boolean
C#
public virtual bool Visible {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisplayInfoAttribute Class
DisplayInfoAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpHeaderBindingAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpHeaderBindingAttribute Class

Glossary Item Box

Specifies that an argument should be fill in from an HTTP header.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class HttpHeaderBindingAttribute
   Inherits System.Attribute
C#
[SerializableAttribute()]
public class HttpHeaderBindingAttribute : System.Attribute

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.HttpHeaderBindingAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpHeaderBindingAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HttpHeaderBindingAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpHeaderBindingAttribute Class

Glossary Item Box

The following tables list the members exposed by HttpHeaderBindingAttribute.

Public Constructors

 | Name | Description
Public Constructor | HttpHeaderBindingAttribute Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Header | The HTTP header to bind the attribute to, i.e. "Accept"
Public Property | RegexMatch | One or More regular expressions that match a specific pattern in the HTTP header, i.e. "^(?<=text/|application/)xml"
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpHeaderBindingAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpHeaderBindingAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpHeaderBindingAttribute Class : HttpHeaderBindingAttribute Constructor

Glossary Item Box

Overload List

Overload | Description
HttpHeaderBindingAttribute Constructor(String) | Constructs the attribute
HttpHeaderBindingAttribute Constructor(String,String[]) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpHeaderBindingAttribute Class
HttpHeaderBindingAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpHeaderBindingAttribute Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpHeaderBindingAttribute Class > HttpHeaderBindingAttribute Constructor : HttpHeaderBindingAttribute Constructor(String)

header

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal header As String _
)
C#
public HttpHeaderBindingAttribute(
   string header
)

Parameters

header

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpHeaderBindingAttribute Class
HttpHeaderBindingAttribute Members
Overload List

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpHeaderBindingAttribute Constructor(String,String[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpHeaderBindingAttribute Class > HttpHeaderBindingAttribute Constructor : HttpHeaderBindingAttribute Constructor(String,String[])

header
The HTTP header to bind the attribute to, i.e. "Accept"
regexMatch
One or More regular expressions that match a specific pattern in the HTTP header, i.e. "^(?<=text/|application/)xml"

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal header As String, _
   ByVal ParamArray regexMatch() As String _
)
C#
public HttpHeaderBindingAttribute(
   string header,
   params string[] regexMatch
)

Parameters

header
The HTTP header to bind the attribute to, i.e. "Accept"
regexMatch
One or More regular expressions that match a specific pattern in the HTTP header, i.e. "^(?<=text/|application/)xml"

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpHeaderBindingAttribute Class
HttpHeaderBindingAttribute Members
Overload List

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HttpHeaderBindingAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpHeaderBindingAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpHeaderBindingAttribute members.

Public Properties

 | Name | Description
Public Property | Header | The HTTP header to bind the attribute to, i.e. "Accept"
Public Property | RegexMatch | One or More regular expressions that match a specific pattern in the HTTP header, i.e. "^(?<=text/|application/)xml"
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

HttpHeaderBindingAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Header Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpHeaderBindingAttribute Class : Header Property

Glossary Item Box

The HTTP header to bind the attribute to, i.e. "Accept"

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Header As String
C#
public string Header {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpHeaderBindingAttribute Class
HttpHeaderBindingAttribute Members

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegexMatch Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpHeaderBindingAttribute Class : RegexMatch Property

Glossary Item Box

One or More regular expressions that match a specific pattern in the HTTP header, i.e. "^(?<=text/|application/)xml"

Syntax

Visual Basic (Declaration)
Public ReadOnly Property RegexMatch As String()
C#
public string[] RegexMatch {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpHeaderBindingAttribute Class
HttpHeaderBindingAttribute Members

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpIgnoreAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpIgnoreAttribute Class

Glossary Item Box

Specifies that an argument should be ignored for HTTP requests.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class HttpIgnoreAttribute
   Inherits System.Attribute
C#
[SerializableAttribute()]
public class HttpIgnoreAttribute : System.Attribute

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.HttpIgnoreAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpIgnoreAttribute Members
CSharpTest.Net.Commands Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HttpIgnoreAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpIgnoreAttribute Class

Glossary Item Box

The following tables list the members exposed by HttpIgnoreAttribute.

Public Constructors

 | Name | Description
Public Constructor | HttpIgnoreAttribute Constructor |
Top

Public Properties

 | Name | Description
Public Property | HttpDefaultValue | A default value that applies to an argument when invoked from the http service
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpIgnoreAttribute Class
CSharpTest.Net.Commands Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpIgnoreAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpIgnoreAttribute Class : HttpIgnoreAttribute Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public HttpIgnoreAttribute()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpIgnoreAttribute Class
HttpIgnoreAttribute Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HttpIgnoreAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpIgnoreAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpIgnoreAttribute members.

Public Properties

 | Name | Description
Public Property | HttpDefaultValue | A default value that applies to an argument when invoked from the http service
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

HttpIgnoreAttribute Class
CSharpTest.Net.Commands Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpDefaultValue Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpIgnoreAttribute Class : HttpDefaultValue Property

Glossary Item Box

A default value that applies to an argument when invoked from the http service

Syntax

Visual Basic (Declaration)
Public Property HttpDefaultValue As Object
C#
public object HttpDefaultValue {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpIgnoreAttribute Class
HttpIgnoreAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpRequestFileAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpRequestFileAttribute Class

Glossary Item Box

Indicates that the argument is a filename that should be uploaded from the client

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class HttpRequestFileAttribute
   Inherits System.Attribute
C#
[SerializableAttribute()]
public class HttpRequestFileAttribute : System.Attribute

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.HttpRequestFileAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpRequestFileAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HttpRequestFileAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpRequestFileAttribute Class

Glossary Item Box

The following tables list the members exposed by HttpRequestFileAttribute.

Public Constructors

 | Name | Description
Public Constructor | HttpRequestFileAttribute Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | AllowMultiple | True to allow multiple files to be uploaded, callee will recieve directory path if more than one file is uploaded.
Public Property | MimeType | Returns the mime type given, or null
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpRequestFileAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpRequestFileAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpRequestFileAttribute Class : HttpRequestFileAttribute Constructor

Glossary Item Box

Overload List

Overload | Description
HttpRequestFileAttribute Constructor() | Constructs the attribute
HttpRequestFileAttribute Constructor(String) | Constructs the attribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpRequestFileAttribute Class
HttpRequestFileAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpRequestFileAttribute Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpRequestFileAttribute Class > HttpRequestFileAttribute Constructor : HttpRequestFileAttribute Constructor()

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public HttpRequestFileAttribute()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpRequestFileAttribute Class
HttpRequestFileAttribute Members
Overload List

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpRequestFileAttribute Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpRequestFileAttribute Class > HttpRequestFileAttribute Constructor : HttpRequestFileAttribute Constructor(String)

mimeType

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal mimeType As String _
)
C#
public HttpRequestFileAttribute(
   string mimeType
)

Parameters

mimeType

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpRequestFileAttribute Class
HttpRequestFileAttribute Members
Overload List

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HttpRequestFileAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpRequestFileAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpRequestFileAttribute members.

Public Properties

 | Name | Description
Public Property | AllowMultiple | True to allow multiple files to be uploaded, callee will recieve directory path if more than one file is uploaded.
Public Property | MimeType | Returns the mime type given, or null
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

HttpRequestFileAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AllowMultiple Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpRequestFileAttribute Class : AllowMultiple Property

Glossary Item Box

True to allow multiple files to be uploaded, callee will recieve directory path if more than one file is uploaded.

Syntax

Visual Basic (Declaration)
Public Property AllowMultiple As Boolean
C#
public bool AllowMultiple {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpRequestFileAttribute Class
HttpRequestFileAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
MimeType Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpRequestFileAttribute Class : MimeType Property

Glossary Item Box

Returns the mime type given, or null

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MimeType As String
C#
public string MimeType {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpRequestFileAttribute Class
HttpRequestFileAttribute Members

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpResponseFileAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpResponseFileAttribute Class

Glossary Item Box

Indicates that the argument is an output filename of the command

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class HttpResponseFileAttribute
   Inherits System.Attribute
C#
[SerializableAttribute()]
public class HttpResponseFileAttribute : System.Attribute

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.HttpResponseFileAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseFileAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HttpResponseFileAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpResponseFileAttribute Class

Glossary Item Box

The following tables list the members exposed by HttpResponseFileAttribute.

Public Constructors

 | Name | Description
Public Constructor | HttpResponseFileAttribute Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Extension | Returns the mime type given, or null
Public Property | MimeType | Returns the mime type given, or null
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpResponseFileAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpResponseFileAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpResponseFileAttribute Class : HttpResponseFileAttribute Constructor

Glossary Item Box

Overload List

Overload | Description
HttpResponseFileAttribute Constructor(String) | Constructs the attribute
HttpResponseFileAttribute Constructor(String,String) | Constructs the attribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseFileAttribute Class
HttpResponseFileAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpResponseFileAttribute Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpResponseFileAttribute Class > HttpResponseFileAttribute Constructor : HttpResponseFileAttribute Constructor(String)

extension

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal extension As String _
)
C#
public HttpResponseFileAttribute(
   string extension
)

Parameters

extension

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseFileAttribute Class
HttpResponseFileAttribute Members
Overload List

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpResponseFileAttribute Constructor(String,String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpResponseFileAttribute Class > HttpResponseFileAttribute Constructor : HttpResponseFileAttribute Constructor(String,String)

extension
mimeType

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal extension As String, _
   ByVal mimeType As String _
)
C#
public HttpResponseFileAttribute(
   string extension,
   string mimeType
)

Parameters

extension
mimeType

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseFileAttribute Class
HttpResponseFileAttribute Members
Overload List

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HttpResponseFileAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpResponseFileAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpResponseFileAttribute members.

Public Properties

 | Name | Description
Public Property | Extension | Returns the mime type given, or null
Public Property | MimeType | Returns the mime type given, or null
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

HttpResponseFileAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Extension Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpResponseFileAttribute Class : Extension Property

Glossary Item Box

Returns the mime type given, or null

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Extension As String
C#
public string Extension {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseFileAttribute Class
HttpResponseFileAttribute Members

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MimeType Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpResponseFileAttribute Class : MimeType Property

Glossary Item Box

Returns the mime type given, or null

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MimeType As String
C#
public string MimeType {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseFileAttribute Class
HttpResponseFileAttribute Members

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpResponseTypeAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpResponseTypeAttribute Class

Glossary Item Box

Sets the response type to a fixed mime-type on a command

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class HttpResponseTypeAttribute
   Inherits System.Attribute
C#
[SerializableAttribute()]
public class HttpResponseTypeAttribute : System.Attribute

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.HttpResponseTypeAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseTypeAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HttpResponseTypeAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpResponseTypeAttribute Class

Glossary Item Box

The following tables list the members exposed by HttpResponseTypeAttribute.

Public Constructors

 | Name | Description
Public Constructor | HttpResponseTypeAttribute Constructor | Constructs the attribute
Top

Public Properties

 | Name | Description
Public Property | MimeType | Returns the mime type given
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpResponseTypeAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpResponseTypeAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpResponseTypeAttribute Class : HttpResponseTypeAttribute Constructor

mimeType

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal mimeType As String _
)
C#
public HttpResponseTypeAttribute(
   string mimeType
)

Parameters

mimeType

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseTypeAttribute Class
HttpResponseTypeAttribute Members

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HttpResponseTypeAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpResponseTypeAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpResponseTypeAttribute members.

Public Properties

 | Name | Description
Public Property | MimeType | Returns the mime type given
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

HttpResponseTypeAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MimeType Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > HttpResponseTypeAttribute Class : MimeType Property

Glossary Item Box

Returns the mime type given

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MimeType As String
C#
public string MimeType {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpResponseTypeAttribute Class
HttpResponseTypeAttribute Members

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnoreMemberAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IgnoreMemberAttribute Class

Glossary Item Box

Instructs the CommandInterpreter to ignore a specific method/property

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class IgnoreMemberAttribute
   Inherits System.Attribute
C#
[SerializableAttribute()]
public class IgnoreMemberAttribute : System.Attribute

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.IgnoreMemberAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreMemberAttribute Members
CSharpTest.Net.Commands Namespace

Used By

CommandInterpreter.AddHandler(T)

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IgnoreMemberAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IgnoreMemberAttribute Class

Glossary Item Box

The following tables list the members exposed by IgnoreMemberAttribute.

Public Constructors

 | Name | Description
Public Constructor | IgnoreMemberAttribute Constructor | Constructs an IgnoreMemberAttribute
Top

Public Properties

 | Name | Description
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

IgnoreMemberAttribute Class
CSharpTest.Net.Commands Namespace

Used By

CommandInterpreter.AddHandler(T)

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnoreMemberAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IgnoreMemberAttribute Class : IgnoreMemberAttribute Constructor

Glossary Item Box

Constructs an IgnoreMemberAttribute

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public IgnoreMemberAttribute()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreMemberAttribute Class
IgnoreMemberAttribute Members

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InterpreterException Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : InterpreterException Class

Glossary Item Box

Base exception for assertions and errors encountered while processing commands

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class InterpreterException
   Inherits System.ApplicationException
C#
[SerializableAttribute()]
public class InterpreterException : System.ApplicationException

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
InterpreterException ex = null;
try { throw new InterpreterException("TEST"); }
catch (InterpreterException e) { ex = e; }

Assert.IsNotNull(ex);
BinaryFormatter bf = new BinaryFormatter();

using( MemoryStream ms = new MemoryStream() )
{
    bf.Serialize(ms, ex);

    ms.Position = 0;
    ex = (InterpreterException)bf.Deserialize(ms);
    Assert.AreEqual("TEST", ex.Message);
}
VB.NET Copy Code
Dim ex As InterpreterException = Nothing
Try
    Throw New InterpreterException("TEST")
Catch e As InterpreterException
    ex = e
End Try

Assert.IsNotNull(ex)
Dim bf As New BinaryFormatter()

Using ms As New MemoryStream()
    bf.Serialize(ms, ex)

    ms.Position = 0
    ex = DirectCast(bf.Deserialize(ms), InterpreterException)
    Assert.AreEqual("TEST", ex.Message)
End Using

Inheritance Hierarchy

System.Object
System.Exception
System.ApplicationException
CSharpTest.Net.Commands.InterpreterException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

InterpreterException Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Exceptions.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
InterpreterException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : InterpreterException Class

Glossary Item Box

The following tables list the members exposed by InterpreterException.

Public Constructors

 | Name | Description
Public Constructor | InterpreterException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

InterpreterException Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Exceptions.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InterpreterException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > InterpreterException Class : InterpreterException Constructor

Glossary Item Box

Overload List

Overload | Description
InterpreterException Constructor(String,Object[]) | Constructs an exception
InterpreterException Constructor(String,Exception) | Constructs an exception
InterpreterException Constructor(SerializationInfo,StreamingContext) | Constructs an exception durring deserialization

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

InterpreterException Class
InterpreterException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
InterpreterException Constructor(String,Object[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > InterpreterException Class > InterpreterException Constructor : InterpreterException Constructor(String,Object[])

text
format

Glossary Item Box

Constructs an exception

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal text As String, _
   ByVal ParamArray format() As Object _
)
C#
public InterpreterException(
   string text,
   params object[] format
)

Parameters

text
format

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
InterpreterException ex = null;
try { throw new InterpreterException("TEST"); }
catch (InterpreterException e) { ex = e; }

Assert.IsNotNull(ex);
BinaryFormatter bf = new BinaryFormatter();

using( MemoryStream ms = new MemoryStream() )
{
    bf.Serialize(ms, ex);

    ms.Position = 0;
    ex = (InterpreterException)bf.Deserialize(ms);
    Assert.AreEqual("TEST", ex.Message);
}
VB.NET Copy Code
Dim ex As InterpreterException = Nothing
Try
    Throw New InterpreterException("TEST")
Catch e As InterpreterException
    ex = e
End Try

Assert.IsNotNull(ex)
Dim bf As New BinaryFormatter()

Using ms As New MemoryStream()
    bf.Serialize(ms, ex)

    ms.Position = 0
    ex = DirectCast(bf.Deserialize(ms), InterpreterException)
    Assert.AreEqual("TEST", ex.Message)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

InterpreterException Class
InterpreterException Members
Overload List

Source Code

Library/Commands/Exceptions.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InterpreterException Constructor(String,Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > InterpreterException Class > InterpreterException Constructor : InterpreterException Constructor(String,Exception)

text
innerException

Glossary Item Box

Constructs an exception

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal text As String, _
   ByVal innerException As Exception _
)
C#
public InterpreterException(
   string text,
   Exception innerException
)

Parameters

text
innerException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

InterpreterException Class
InterpreterException Members
Overload List

Source Code

Library/Commands/Exceptions.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InterpreterException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > InterpreterException Class > InterpreterException Constructor : InterpreterException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Constructs an exception durring deserialization

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected InterpreterException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

InterpreterException Class
InterpreterException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
OptionAttribute Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : OptionAttribute Class

Glossary Item Box

Provides all the properties available for an argument.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class OptionAttribute
   Inherits DisplayInfoAndValueAttribute
   Implements IDisplayInfo
C#
[SerializableAttribute()]
public class OptionAttribute : DisplayInfoAndValueAttribute, IDisplayInfo

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Commands.DisplayInfoAttribute
CSharpTest.Net.Commands.DisplayInfoAndValueAttribute
CSharpTest.Net.Commands.OptionAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

OptionAttribute Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
OptionAttribute Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : OptionAttribute Class

Glossary Item Box

The following tables list the members exposed by OptionAttribute.

Public Constructors

 | Name | Description
Public Constructor | OptionAttribute Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DefaultValue | Gets/sets the default value for the option (Inherited from CSharpTest.Net.Commands.DisplayInfoAndValueAttribute)
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

OptionAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OptionAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > OptionAttribute Class : OptionAttribute Constructor

Glossary Item Box

Overload List

Overload | Description
OptionAttribute Constructor() | Constructs the attribute
OptionAttribute Constructor(String) | Constructs the attribute
OptionAttribute Constructor(String,String[]) | Constructs the attribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

OptionAttribute Class
OptionAttribute Members


%%PageItemTitle%%

[image]
CSharpTest.Net
OptionAttribute Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > OptionAttribute Class > OptionAttribute Constructor : OptionAttribute Constructor()

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public OptionAttribute()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

OptionAttribute Class
OptionAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OptionAttribute Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > OptionAttribute Class > OptionAttribute Constructor : OptionAttribute Constructor(String)

displayName

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal displayName As String _
)
C#
public OptionAttribute(
   string displayName
)

Parameters

displayName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

OptionAttribute Class
OptionAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OptionAttribute Constructor(String,String[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > OptionAttribute Class > OptionAttribute Constructor : OptionAttribute Constructor(String,String[])

displayName
aliasNames

Glossary Item Box

Constructs the attribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal displayName As String, _
   ByVal ParamArray aliasNames() As String _
)
C#
public OptionAttribute(
   string displayName,
   params string[] aliasNames
)

Parameters

displayName
aliasNames

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

OptionAttribute Class
OptionAttribute Members
Overload List

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ServiceCommands Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ServiceCommands Class

Glossary Item Box

Provide this type to the CommandInterpreter to enable running as a service.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class ServiceCommands
C#
public static class ServiceCommands

Inheritance Hierarchy

System.Object
CSharpTest.Net.Commands.ServiceCommands

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceCommands Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ServiceCommands Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ServiceCommands Class

Glossary Item Box

The following tables list the members exposed by ServiceCommands.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | RunAsService | Used to host a command-interpreter's command as a Win32 service. Use ServiceCommands.Installation.InstallService to install the service.
Top

See Also

Reference

ServiceCommands Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ServiceCommands Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ServiceCommands Class

Glossary Item Box

For a list of all members of this type, see ServiceCommands members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | RunAsService | Used to host a command-interpreter's command as a Win32 service. Use ServiceCommands.Installation.InstallService to install the service.
Top

See Also

Reference

ServiceCommands Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RunAsService Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ServiceCommands Class : RunAsService Method

ci
name
rawArgs

Glossary Item Box

Used to host a command-interpreter's command as a Win32 service. Use ServiceCommands.Installation.InstallService to install the service.

Syntax

Visual Basic (Declaration)
Public Shared Sub RunAsService( _
   ByVal ci As ICommandInterpreter, _
   ByVal name As String, _
   ByVal rawArgs() As String _
)
C#
public static void RunAsService(
   ICommandInterpreter ci,
   string name,
   string[] rawArgs
)

Parameters

ci
name
rawArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceCommands Class
ServiceCommands Members
ICommandInterpreter

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ServiceCommands.Installation Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ServiceCommands.Installation Class

Glossary Item Box

Provide this type to the CommandInterpreter to enable installing any command as a service.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class ServiceCommands.Installation
C#
public static class ServiceCommands.Installation

Inheritance Hierarchy

System.Object
CSharpTest.Net.Commands.ServiceCommands.Installation

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceCommands.Installation Members
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ServiceCommands.Installation Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ServiceCommands.Installation Class

Glossary Item Box

The following tables list the members exposed by ServiceCommands.Installation.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | InstallService | Installs a Win32 service that runs a single command on this executable when started. While typically used for the HostHTTP command, it will operate for any command. Commands hosted as a service may use the Console.ReadLine() to wait for the service-stop command.
static (Shared in Visual Basic) | UninstallService | Removes a Win32 Service that was previously installed.
Top

See Also

Reference

ServiceCommands.Installation Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ServiceCommands.Installation Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ServiceCommands.Installation Class

Glossary Item Box

For a list of all members of this type, see ServiceCommands.Installation members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | InstallService | Installs a Win32 service that runs a single command on this executable when started. While typically used for the HostHTTP command, it will operate for any command. Commands hosted as a service may use the Console.ReadLine() to wait for the service-stop command.
static (Shared in Visual Basic) | UninstallService | Removes a Win32 Service that was previously installed.
Top

See Also

Reference

ServiceCommands.Installation Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InstallService Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ServiceCommands.Installation Class : InstallService Method

svcName
The name of the Win32 Service to install.
displayName
The description of the Win32 Service.
startupType
The service startup type: Automatic, Manual, or Disabled.
serviceAccount
The service account: LocalService, NetworkService, or LocalSystem.
commandName
The command to run as a service.
arguments
The arguments required to run the command.
ci
The current command interpreter, used to verify the command 'RunAsService' and the commandName provided.
executable
Optional, The path to the executable that is running.

Glossary Item Box

Installs a Win32 service that runs a single command on this executable when started. While typically used for the HostHTTP command, it will operate for any command. Commands hosted as a service may use the Console.ReadLine() to wait for the service-stop command.

Syntax

Visual Basic (Declaration)
Public Shared Sub InstallService( _
   ByVal svcName As String, _
   ByVal displayName As String, _
   ByVal startupType As ServiceStartMode, _
   ByVal serviceAccount As ServiceAccount, _
   ByVal commandName As String, _
   ByVal arguments() As String, _
   ByVal ci As ICommandInterpreter, _
   ByVal executable As String _
)
C#
public static void InstallService(
   string svcName,
   string displayName,
   ServiceStartMode startupType,
   ServiceAccount serviceAccount,
   string commandName,
   string[] arguments,
   ICommandInterpreter ci,
   string executable
)

Parameters

svcName
The name of the Win32 Service to install.
displayName
The description of the Win32 Service.
startupType
The service startup type: Automatic, Manual, or Disabled.
serviceAccount
The service account: LocalService, NetworkService, or LocalSystem.
commandName
The command to run as a service.
arguments
The arguments required to run the command.
ci
The current command interpreter, used to verify the command 'RunAsService' and the commandName provided.
executable
Optional, The path to the executable that is running.

Exceptions

Exception | Description
System.ApplicationException | The exception that is thrown when a non-fatal application error occurs.
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceCommands.Installation Class
ServiceCommands.Installation Members
ICommandInterpreter

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UninstallService Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ServiceCommands.Installation Class : UninstallService Method

svcName
The name of the service to remove.

Glossary Item Box

Removes a Win32 Service that was previously installed.

Syntax

Visual Basic (Declaration)
Public Shared Sub UninstallService( _
   ByVal svcName As String _
)
C#
public static void UninstallService(
   string svcName
)

Parameters

svcName
The name of the service to remove.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceCommands.Installation Class
ServiceCommands.Installation Members

Source Code

Library/Commands/CommandService.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultCommands Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DefaultCommands Enumeration

Glossary Item Box

A list of built-in commands that can be added to the interpreter

Syntax

Visual Basic (Declaration)
Public Enum DefaultCommands
   Inherits System.Enum
C#
public enum DefaultCommands : System.Enum

Members

Member | Description
All | Not a command, indicates to use all default commands
Default | Not a command, indicates the default commands added if not specified
Echo | A command to echo back to std::out the arguments provided.
ErrorLevel | An option to set and get the environment error-level
Find | A command to search for a text string in a file or the standard input stream.
Get | A command to get the value of an option
Help | A command to display help about the commands and their options
HostHTTP | A command that allows the console application to be hosted as a restful HTTP server.
IORedirect | A command filter that allows redirect of std in/out to files.
More | A command to read the input stream and show one screen at a time to standard output.
None | Not a command, indicates no default commands
PipeCommands | A command filter that allows piping the output of one command into the input of another.
Prompt | An option that provides customization of the command prompt for interactive mode
Set | A command to set the value of an option

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
Assert.AreEqual(DefaultCommands.Get | DefaultCommands.Set | DefaultCommands.Help, DefaultCommands.Default);
//defaults the DefaultCommands to Get/Set/Help via the enum value of DefaultCommands.Default
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

Assert.AreEqual(2, ci.Options.Length);
Assert.AreEqual("Other", ci.Options[0].DisplayName);
Assert.AreEqual(typeof(int), ci.Options[0].Type);
Assert.AreEqual("SomeData", ci.Options[1].DisplayName);
Assert.AreEqual(typeof(String), ci.Options[1].Type);

TextWriter stdout = Console.Out;
try
{
    Console.SetOut(new StringWriter());// <= Get will also write to console

    Assert.AreEqual(-1, ci.Get("other"));//default was applied
    ci.Set("other", 1);
    Assert.AreEqual(1, ci.Get("other"));

    Assert.AreNotEqual("abc", ci.Get("somedata"));
    ci.Set("somedata", "abc");
    Assert.AreEqual("abc", ci.Get("somedata"));
}
finally
{ Console.SetOut(stdout); }

string result;
result = Capture(ci, "GET Somedata");
Assert.AreEqual("abc", result);
//Set without args lists options
result = Capture(ci, "SET");
Assert.IsTrue(result.ToUpper().Contains("somedata".ToUpper()));
//Set without value returns the current value
result = Capture(ci, "SET somedata");
Assert.AreEqual("abc", result);
result = Capture(ci, "SET somedata 123");
Assert.AreEqual("", result);
result = Capture(ci, "GET somedata");
Assert.AreEqual("123", result);
VB.NET Copy Code
Assert.AreEqual(DefaultCommands.[Get] Or DefaultCommands.[Set] Or DefaultCommands.Help, DefaultCommands.[Default])
'defaults the DefaultCommands to Get/Set/Help via the enum value of DefaultCommands.Default
Dim ci As New CommandInterpreter(New TestCommands())

Assert.AreEqual(2, ci.Options.Length)
Assert.AreEqual("Other", ci.Options(0).DisplayName)
Assert.AreEqual(GetType(Integer), ci.Options(0).Type)
Assert.AreEqual("SomeData", ci.Options(1).DisplayName)
Assert.AreEqual(GetType([String]), ci.Options(1).Type)

Dim stdout As TextWriter = Console.Out
Try
    Console.SetOut(New StringWriter())
    ' <= Get will also write to console
    Assert.AreEqual(-1, ci.[Get]("other"))
    'default was applied
    ci.[Set]("other", 1)
    Assert.AreEqual(1, ci.[Get]("other"))

    Assert.AreNotEqual("abc", ci.[Get]("somedata"))
    ci.[Set]("somedata", "abc")
    Assert.AreEqual("abc", ci.[Get]("somedata"))
Finally
    Console.SetOut(stdout)
End Try

Dim result As String
result = Capture(ci, "GET Somedata")
Assert.AreEqual("abc", result)
'Set without args lists options
result = Capture(ci, "SET")
Assert.IsTrue(result.ToUpper().Contains("somedata".ToUpper()))
'Set without value returns the current value
result = Capture(ci, "SET somedata")
Assert.AreEqual("abc", result)
result = Capture(ci, "SET somedata 123")
Assert.AreEqual("", result)
result = Capture(ci, "GET somedata")
Assert.AreEqual("123", result)

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Commands.DefaultCommands

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/DefaultCommands.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IArgument Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IArgument Interface

Glossary Item Box

Represents a static or instance method that will be invoked as a command

Syntax

Visual Basic (Declaration)
Public Interface IArgument
   Inherits IDisplayInfo
C#
public interface IArgument : IDisplayInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IArgument Members
CSharpTest.Net.Commands Namespace
IArgument[] ICommand.Arguments


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IArgument Interface Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IArgument Interface

Glossary Item Box

The following tables list the members exposed by IArgument.

Public Properties

 | Name | Description
Property | DefaultValue | Returns the default value if Required == false
Property | Required | Returns true if the argument is required
Property | Type | Returns the type of the argument
Top

See Also

Reference

IArgument Interface
CSharpTest.Net.Commands Namespace
IArgument[] ICommand.Arguments


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IArgument Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IArgument Interface

Glossary Item Box

For a list of all members of this type, see IArgument members.

Public Properties

 | Name | Description
Property | DefaultValue | Returns the default value if Required == false
Property | Required | Returns true if the argument is required
Property | Type | Returns the type of the argument
Top

See Also

Reference

IArgument Interface
CSharpTest.Net.Commands Namespace
IArgument[] ICommand.Arguments


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultValue Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IArgument Interface : DefaultValue Property

Glossary Item Box

Returns the default value if Required == false

Syntax

Visual Basic (Declaration)
ReadOnly Property DefaultValue As Object
C#
object DefaultValue {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IArgument Interface
IArgument Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Required Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IArgument Interface : Required Property

Glossary Item Box

Returns true if the argument is required

Syntax

Visual Basic (Declaration)
ReadOnly Property Required As Boolean
C#
bool Required {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IArgument Interface
IArgument Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Type Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IArgument Interface : Type Property

Glossary Item Box

Returns the type of the argument

Syntax

Visual Basic (Declaration)
ReadOnly Property Type As Type
C#
Type Type {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IArgument Interface
IArgument Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ICommand Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommand Interface

Glossary Item Box

Represents a static or instance method that will be invoked as a command

Syntax

Visual Basic (Declaration)
Public Interface ICommand
   Inherits IDisplayInfo
C#
public interface ICommand : IDisplayInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommand Members
CSharpTest.Net.Commands Namespace
Boolean ICommandInterpreter.TryGetCommand(String,ICommand)
ICommand[] ICommandInterpreter.Commands
CommandInterpreter.AddCommand(ICommand)
CommandInterpreter.RemoveCommand(ICommand)
Boolean CommandInterpreter.TryGetCommand(String,ICommand)
ICommand[] CommandInterpreter.Commands


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ICommand Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommand Interface

Glossary Item Box

The following tables list the members exposed by ICommand.

Public Properties

 | Name | Description
Property | Arguments | Returns the arguments defined on this command.
Top

Public Methods

 | Name | Description
Method | Run | Runs this command with the supplied arguments
Top

See Also

Reference

ICommand Interface
CSharpTest.Net.Commands Namespace
Boolean ICommandInterpreter.TryGetCommand(String,ICommand)
ICommand[] ICommandInterpreter.Commands
CommandInterpreter.AddCommand(ICommand)
CommandInterpreter.RemoveCommand(ICommand)
Boolean CommandInterpreter.TryGetCommand(String,ICommand)
ICommand[] CommandInterpreter.Commands


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ICommand Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommand Interface

Glossary Item Box

For a list of all members of this type, see ICommand members.

Public Methods

 | Name | Description
Method | Run | Runs this command with the supplied arguments
Top

See Also

Reference

ICommand Interface
CSharpTest.Net.Commands Namespace
Boolean ICommandInterpreter.TryGetCommand(String,ICommand)
ICommand[] ICommandInterpreter.Commands
CommandInterpreter.AddCommand(ICommand)
CommandInterpreter.RemoveCommand(ICommand)
Boolean CommandInterpreter.TryGetCommand(String,ICommand)
ICommand[] CommandInterpreter.Commands


%%PageItemTitle%%

[image]
CSharpTest.Net
Run Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommand Interface : Run Method

interpreter
arguments

Glossary Item Box

Runs this command with the supplied arguments

Syntax

Visual Basic (Declaration)
Sub Run( _
   ByVal interpreter As ICommandInterpreter, _
   ByVal arguments() As String _
)
C#
void Run(
   ICommandInterpreter interpreter,
   string[] arguments
)

Parameters

interpreter
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommand Interface
ICommand Members
ICommandInterpreter


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ICommand Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommand Interface

Glossary Item Box

For a list of all members of this type, see ICommand members.

Public Properties

 | Name | Description
Property | Arguments | Returns the arguments defined on this command.
Top

See Also

Reference

ICommand Interface
CSharpTest.Net.Commands Namespace
Boolean ICommandInterpreter.TryGetCommand(String,ICommand)
ICommand[] ICommandInterpreter.Commands
CommandInterpreter.AddCommand(ICommand)
CommandInterpreter.RemoveCommand(ICommand)
Boolean CommandInterpreter.TryGetCommand(String,ICommand)
ICommand[] CommandInterpreter.Commands


%%PageItemTitle%%

[image]
CSharpTest.Net
Arguments Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommand Interface : Arguments Property

Glossary Item Box

Returns the arguments defined on this command.

Syntax

Visual Basic (Declaration)
ReadOnly Property Arguments As IArgument()
C#
IArgument[] Arguments {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommand Interface
ICommand Members
IArgument

Used By

CommandInterpreter.AddGlobalArgumentAttribute(String,Attribute)


%%PageItemTitle%%

[image]
CSharpTest.Net
ICommandChain Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandChain Interface

Glossary Item Box

Defines an interface that allows a command filter to call to next filter in the chain

Syntax

Visual Basic (Declaration)
Public Interface ICommandChain
C#
public interface ICommandChain

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandChain Members
CSharpTest.Net.Commands Namespace
ICommandFilter.Run(ICommandInterpreter,ICommandChain,String[])


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ICommandChain Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandChain Interface

Glossary Item Box

The following tables list the members exposed by ICommandChain.

Public Methods

 | Name | Description
Method | Next | Calls the next command filter in the chain, eventually processing the command
Top

See Also

Reference

ICommandChain Interface
CSharpTest.Net.Commands Namespace
ICommandFilter.Run(ICommandInterpreter,ICommandChain,String[])


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ICommandChain Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandChain Interface

Glossary Item Box

For a list of all members of this type, see ICommandChain members.

Public Methods

 | Name | Description
Method | Next | Calls the next command filter in the chain, eventually processing the command
Top

See Also

Reference

ICommandChain Interface
CSharpTest.Net.Commands Namespace
ICommandFilter.Run(ICommandInterpreter,ICommandChain,String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
Next Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandChain Interface : Next Method

arguments

Glossary Item Box

Calls the next command filter in the chain, eventually processing the command

Syntax

Visual Basic (Declaration)
Sub Next( _
   ByVal arguments() As String _
)
C#
void Next(
   string[] arguments
)

Parameters

arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandChain Interface
ICommandChain Members

Used By

CommandInterpreter.Run(String[])
CommandInterpreter.Run(String[],TextWriter,TextWriter,TextReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
ICommandFilter Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandFilter Interface

Glossary Item Box

Represents a static or instance method that is used to filter or pre/post process commands

Syntax

Visual Basic (Declaration)
Public Interface ICommandFilter
   Inherits ICommand, IDisplayInfo
C#
public interface ICommandFilter : ICommand, IDisplayInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandFilter Members
CSharpTest.Net.Commands Namespace
CommandInterpreter.AddFilter(ICommandFilter)
ICommandFilter[] CommandInterpreter.Filters

Used By

CommandInterpreter.AddHandler(T)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ICommandFilter Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandFilter Interface

Glossary Item Box

The following tables list the members exposed by ICommandFilter.

Public Properties

 | Name | Description
Property | Keys | Returns the possible character keys for this filter when setting the precedence
Top

Public Methods

 | Name | Description
Method | Run | Used to run a command through a set of filters, call chain.Next() to continue processing
Top

See Also

Reference

ICommandFilter Interface
CSharpTest.Net.Commands Namespace
CommandInterpreter.AddFilter(ICommandFilter)
ICommandFilter[] CommandInterpreter.Filters

Used By

CommandInterpreter.AddHandler(T)


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ICommandFilter Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandFilter Interface

Glossary Item Box

For a list of all members of this type, see ICommandFilter members.

Public Methods

 | Name | Description
Method | Run | Used to run a command through a set of filters, call chain.Next() to continue processing
Top

See Also

Reference

ICommandFilter Interface
CSharpTest.Net.Commands Namespace
CommandInterpreter.AddFilter(ICommandFilter)
ICommandFilter[] CommandInterpreter.Filters

Used By

CommandInterpreter.AddHandler(T)


%%PageItemTitle%%

[image]
CSharpTest.Net
Run Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandFilter Interface : Run Method

interpreter
The command interpreter running the command
chain
The next link in the chain of filters
arguments
The input arguments to the command-line

Glossary Item Box

Used to run a command through a set of filters, call chain.Next() to continue processing

Syntax

Visual Basic (Declaration)
Sub Run( _
   ByVal interpreter As ICommandInterpreter, _
   ByVal chain As ICommandChain, _
   ByVal arguments() As String _
)
C#
void Run(
   ICommandInterpreter interpreter,
   ICommandChain chain,
   string[] arguments
)

Parameters

interpreter
The command interpreter running the command
chain
The next link in the chain of filters
arguments
The input arguments to the command-line

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandFilter Interface
ICommandFilter Members
ICommandInterpreter
ICommandChain


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ICommandFilter Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandFilter Interface

Glossary Item Box

For a list of all members of this type, see ICommandFilter members.

Public Properties

 | Name | Description
Property | Keys | Returns the possible character keys for this filter when setting the precedence
Top

See Also

Reference

ICommandFilter Interface
CSharpTest.Net.Commands Namespace
CommandInterpreter.AddFilter(ICommandFilter)
ICommandFilter[] CommandInterpreter.Filters

Used By

CommandInterpreter.AddHandler(T)


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandFilter Interface : Keys Property

Glossary Item Box

Returns the possible character keys for this filter when setting the precedence

Syntax

Visual Basic (Declaration)
ReadOnly Property Keys As Char()
C#
char[] Keys {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandFilter Interface
ICommandFilter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ICommandInterpreter Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandInterpreter Interface

Glossary Item Box

Defines the interface for the command interpreter. If you use this as a parameter it will be provided auto-magically to your command. To avoid conflicts with ordinal argument matching, make this your last argument.

Syntax

Visual Basic (Declaration)
Public Interface ICommandInterpreter
C#
public interface ICommandInterpreter

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Members
CSharpTest.Net.Commands Namespace
ServiceCommands.RunAsService(ICommandInterpreter,String,String[])
ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)
ICommand.Run(ICommandInterpreter,String[])
ICommandFilter.Run(ICommandInterpreter,ICommandChain,String[])


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ICommandInterpreter Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandInterpreter Interface

Glossary Item Box

The following tables list the members exposed by ICommandInterpreter.

Public Properties

 | Name | Description
Property | Commands | Lists all the commands that have been added to the interpreter
Property | ErrorLevel | Gets/sets the exit code of the operation/process
Property | Options | Lists all the options that have been added to the interpreter, use the set/get commands to modify their values.
Property | Prompt | Gets/sets the prompt, use "$(OptionName)" to reference options
Property | ReadNextCharacter | Reads a keystroke, not from the std:in stream, rather from the console or ui.
Top

Public Methods

 | Name | Description
Method | ExpandOptions | Expands '$(OptionName)' within the input string to the named option's value.
Method | Get | Command to get an option value by name
Method | GetHtmlHelp | Returns an HTML document for help on all items (when item == null) or a specific item.
Method | Run | Overloaded. Run the command whos name is the first argument with the remaining arguments provided to the command as needed.
Method | Set | Command to set the value of an option value by name
Method | TryGetCommand | Returns true if the command was found and cmd output parameter is set.
Method | TryGetOption | Returns true if the command was found and cmd output parameter is set.
Top

See Also

Reference

ICommandInterpreter Interface
CSharpTest.Net.Commands Namespace
ServiceCommands.RunAsService(ICommandInterpreter,String,String[])
ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)
ICommand.Run(ICommandInterpreter,String[])
ICommandFilter.Run(ICommandInterpreter,ICommandChain,String[])


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ICommandInterpreter Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandInterpreter Interface

Glossary Item Box

For a list of all members of this type, see ICommandInterpreter members.

Public Methods

 | Name | Description
Method | ExpandOptions | Expands '$(OptionName)' within the input string to the named option's value.
Method | Get | Command to get an option value by name
Method | GetHtmlHelp | Returns an HTML document for help on all items (when item == null) or a specific item.
Method | Run | Overloaded. Run the command whos name is the first argument with the remaining arguments provided to the command as needed.
Method | Set | Command to set the value of an option value by name
Method | TryGetCommand | Returns true if the command was found and cmd output parameter is set.
Method | TryGetOption | Returns true if the command was found and cmd output parameter is set.
Top

See Also

Reference

ICommandInterpreter Interface
CSharpTest.Net.Commands Namespace
ServiceCommands.RunAsService(ICommandInterpreter,String,String[])
ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)
ICommand.Run(ICommandInterpreter,String[])
ICommandFilter.Run(ICommandInterpreter,ICommandChain,String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
ExpandOptions Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : ExpandOptions Method

input

Glossary Item Box

Expands '$(OptionName)' within the input string to the named option's value.

Syntax

Visual Basic (Declaration)
Function ExpandOptions( _
   ByVal input As String _
) As String
C#
string ExpandOptions(
   string input
)

Parameters

input

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Get Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : Get Method

property

Glossary Item Box

Command to get an option value by name

Syntax

Visual Basic (Declaration)
Function Get( _
   ByVal property As String _
) As Object
C#
object Get(
   string property
)

Parameters

property

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHtmlHelp Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : GetHtmlHelp Method

item

Glossary Item Box

Returns an HTML document for help on all items (when item == null) or a specific item.

Syntax

Visual Basic (Declaration)
Function GetHtmlHelp( _
   ByVal item As String _
) As String
C#
string GetHtmlHelp(
   string item
)

Parameters

item

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Run Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : Run Method

Glossary Item Box

Run the command whos name is the first argument with the remaining arguments provided to the command as needed.

Overload List

Overload | Description
Run(String[]) | Run the command whos name is the first argument with the remaining arguments provided to the command as needed.
Run(String[],TextWriter,TextWriter,TextReader) | Run the command whos name is the first argument with the remaining arguments provided to the command as needed.
Run(TextReader) | Runs each line from the reader until EOF, can be used with Console.In

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface > Run Method : Run(String[]) Method

arguments

Glossary Item Box

Run the command whos name is the first argument with the remaining arguments provided to the command as needed.

Syntax

Visual Basic (Declaration)
Overloads Sub Run( _
   ByVal ParamArray arguments() As String _
)
C#
void Run(
   params string[] arguments
)

Parameters

arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(String[],TextWriter,TextWriter,TextReader) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface > Run Method : Run(String[],TextWriter,TextWriter,TextReader) Method

arguments
mapstdout
mapstderr
mapstdin

Glossary Item Box

Run the command whos name is the first argument with the remaining arguments provided to the command as needed.

Syntax

Visual Basic (Declaration)
Overloads Sub Run( _
   ByVal arguments() As String, _
   ByVal mapstdout As TextWriter, _
   ByVal mapstderr As TextWriter, _
   ByVal mapstdin As TextReader _
)
C#
void Run(
   string[] arguments,
   TextWriter mapstdout,
   TextWriter mapstderr,
   TextReader mapstdin
)

Parameters

arguments
mapstdout
mapstderr
mapstdin

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(TextReader) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface > Run Method : Run(TextReader) Method

input

Glossary Item Box

Runs each line from the reader until EOF, can be used with Console.In

Syntax

Visual Basic (Declaration)
Overloads Sub Run( _
   ByVal input As TextReader _
)
C#
void Run(
   TextReader input
)

Parameters

input

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
Set Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : Set Method

property
value

Glossary Item Box

Command to set the value of an option value by name

Syntax

Visual Basic (Declaration)
Sub Set( _
   ByVal property As String, _
   ByVal value As Object _
)
C#
void Set(
   string property,
   object value
)

Parameters

property
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetCommand Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : TryGetCommand Method

name
cmd

Glossary Item Box

Returns true if the command was found and cmd output parameter is set.

Syntax

Visual Basic (Declaration)
Function TryGetCommand( _
   ByVal name As String, _
   ByRef cmd As ICommand _
) As Boolean
C#
bool TryGetCommand(
   string name,
   out ICommand cmd
)

Parameters

name
cmd

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members
ICommand

Used By

ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetOption Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : TryGetOption Method

name
cmd

Glossary Item Box

Returns true if the command was found and cmd output parameter is set.

Syntax

Visual Basic (Declaration)
Function TryGetOption( _
   ByVal name As String, _
   ByRef cmd As IOption _
) As Boolean
C#
bool TryGetOption(
   string name,
   out IOption cmd
)

Parameters

name
cmd

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members
IOption


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ICommandInterpreter Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ICommandInterpreter Interface

Glossary Item Box

For a list of all members of this type, see ICommandInterpreter members.

Public Properties

 | Name | Description
Property | Commands | Lists all the commands that have been added to the interpreter
Property | ErrorLevel | Gets/sets the exit code of the operation/process
Property | Options | Lists all the options that have been added to the interpreter, use the set/get commands to modify their values.
Property | Prompt | Gets/sets the prompt, use "$(OptionName)" to reference options
Property | ReadNextCharacter | Reads a keystroke, not from the std:in stream, rather from the console or ui.
Top

See Also

Reference

ICommandInterpreter Interface
CSharpTest.Net.Commands Namespace
ServiceCommands.RunAsService(ICommandInterpreter,String,String[])
ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)
ICommand.Run(ICommandInterpreter,String[])
ICommandFilter.Run(ICommandInterpreter,ICommandChain,String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
Commands Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : Commands Property

Glossary Item Box

Lists all the commands that have been added to the interpreter

Syntax

Visual Basic (Declaration)
ReadOnly Property Commands As ICommand()
C#
ICommand[] Commands {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members
ICommand


%%PageItemTitle%%

[image]
CSharpTest.Net
ErrorLevel Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : ErrorLevel Property

Glossary Item Box

Gets/sets the exit code of the operation/process

Syntax

Visual Basic (Declaration)
Property ErrorLevel As Integer
C#
int ErrorLevel {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Options Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : Options Property

Glossary Item Box

Lists all the options that have been added to the interpreter, use the set/get commands to modify their values.

Syntax

Visual Basic (Declaration)
ReadOnly Property Options As IOption()
C#
IOption[] Options {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members
IOption


%%PageItemTitle%%

[image]
CSharpTest.Net
Prompt Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : Prompt Property

Glossary Item Box

Gets/sets the prompt, use "$(OptionName)" to reference options

Syntax

Visual Basic (Declaration)
Property Prompt As String
C#
string Prompt {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadNextCharacter Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > ICommandInterpreter Interface : ReadNextCharacter Property

Glossary Item Box

Reads a keystroke, not from the std:in stream, rather from the console or ui.

Syntax

Visual Basic (Declaration)
ReadOnly Property ReadNextCharacter As ReadNextCharacter
C#
ReadNextCharacter ReadNextCharacter {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICommandInterpreter Interface
ICommandInterpreter Members
ReadNextCharacter


%%PageItemTitle%%

[image]
CSharpTest.Net
IDisplayInfo Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IDisplayInfo Interface

Glossary Item Box

A base interface that provides name and display information

Syntax

Visual Basic (Declaration)
Public Interface IDisplayInfo
C#
public interface IDisplayInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Members
CSharpTest.Net.Commands Namespace

Used By

String CommandInterpreter.GetHtmlHelp(String)
CommandInterpreter.Help(String,Boolean)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IDisplayInfo Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IDisplayInfo Interface

Glossary Item Box

The following tables list the members exposed by IDisplayInfo.

Public Properties

 | Name | Description
Property | AllNames | Returns the name of the item
Property | Category | Returns the category if defined, or the type name if not
Property | Description | Returns the description of the item
Property | DisplayName | Returns the display name of the item
Property | ReflectedType | Returns the type this was reflected from, or null if created without reflection
Property | Visible | Returns true if the items should be displayed.
Top

Public Methods

 | Name | Description
Method | AddAttribute<T> | Dynamically adds an attribute to the item.
Method | Help | Renders the help information to Console.Out
Method | TryGetAttribute<T> | Returns true if the attribute was found
Top

See Also

Reference

IDisplayInfo Interface
CSharpTest.Net.Commands Namespace

Used By

String CommandInterpreter.GetHtmlHelp(String)
CommandInterpreter.Help(String,Boolean)


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IDisplayInfo Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IDisplayInfo Interface

Glossary Item Box

For a list of all members of this type, see IDisplayInfo members.

Public Methods

 | Name | Description
Method | AddAttribute<T> | Dynamically adds an attribute to the item.
Method | Help | Renders the help information to Console.Out
Method | TryGetAttribute<T> | Returns true if the attribute was found
Top

See Also

Reference

IDisplayInfo Interface
CSharpTest.Net.Commands Namespace

Used By

String CommandInterpreter.GetHtmlHelp(String)
CommandInterpreter.Help(String,Boolean)


%%PageItemTitle%%

T
[image]
CSharpTest.Net
AddAttribute<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : AddAttribute<T> Method

attribute

Glossary Item Box

Dynamically adds an attribute to the item.

Syntax

Visual Basic (Declaration)
Sub AddAttribute(Of T As Attribute)( _
   ByVal attribute As T _
)
C#
void AddAttribute<T>(
   T attribute
)
where T: Attribute

Parameters

attribute

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Help Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : Help Method

Glossary Item Box

Renders the help information to Console.Out

Syntax

Visual Basic (Declaration)
Sub Help()
C#
void Help()

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members


%%PageItemTitle%%

T
[image]
CSharpTest.Net
TryGetAttribute<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : TryGetAttribute<T> Method

found

Glossary Item Box

Returns true if the attribute was found

Syntax

Visual Basic (Declaration)
Function TryGetAttribute(Of T As Attribute)( _
   ByRef found As T _
) As Boolean
C#
bool TryGetAttribute<T>(
   out T found
)
where T: Attribute

Parameters

found

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IDisplayInfo Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IDisplayInfo Interface

Glossary Item Box

For a list of all members of this type, see IDisplayInfo members.

Public Properties

 | Name | Description
Property | AllNames | Returns the name of the item
Property | Category | Returns the category if defined, or the type name if not
Property | Description | Returns the description of the item
Property | DisplayName | Returns the display name of the item
Property | ReflectedType | Returns the type this was reflected from, or null if created without reflection
Property | Visible | Returns true if the items should be displayed.
Top

See Also

Reference

IDisplayInfo Interface
CSharpTest.Net.Commands Namespace

Used By

String CommandInterpreter.GetHtmlHelp(String)
CommandInterpreter.Help(String,Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
AllNames Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : AllNames Property

Glossary Item Box

Returns the name of the item

Syntax

Visual Basic (Declaration)
ReadOnly Property AllNames As String()
C#
string[] AllNames {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members

Used By

CommandInterpreter.AddCommand(ICommand)
CommandInterpreter.RemoveCommand(ICommand)
CommandInterpreter.AddOption(IOption)


%%PageItemTitle%%

[image]
CSharpTest.Net
Category Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : Category Property

Glossary Item Box

Returns the category if defined, or the type name if not

Syntax

Visual Basic (Declaration)
ReadOnly Property Category As String
C#
string Category {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Description Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : Description Property

Glossary Item Box

Returns the description of the item

Syntax

Visual Basic (Declaration)
ReadOnly Property Description As String
C#
string Description {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DisplayName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : DisplayName Property

Glossary Item Box

Returns the display name of the item

Syntax

Visual Basic (Declaration)
ReadOnly Property DisplayName As String
C#
string DisplayName {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members

Used By

CommandInterpreter.Set(String,Object,Boolean)
CommandInterpreter.AddGlobalArgumentAttribute(String,Attribute)


%%PageItemTitle%%

[image]
CSharpTest.Net
ReflectedType Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : ReflectedType Property

Glossary Item Box

Returns the type this was reflected from, or null if created without reflection

Syntax

Visual Basic (Declaration)
ReadOnly Property ReflectedType As Type
C#
Type ReflectedType {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Visible Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IDisplayInfo Interface : Visible Property

Glossary Item Box

Returns true if the items should be displayed.

Syntax

Visual Basic (Declaration)
Property Visible As Boolean
C#
bool Visible {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IDisplayInfo Interface
IDisplayInfo Members


%%PageItemTitle%%

[image]
CSharpTest.Net
IOption Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IOption Interface

Glossary Item Box

Defines an Option that can be configued/set independantly of the commands. Used with the set/get commands defined by the interpreter.

Syntax

Visual Basic (Declaration)
Public Interface IOption
   Inherits IDisplayInfo
C#
public interface IOption : IDisplayInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOption Members
CSharpTest.Net.Commands Namespace
Boolean ICommandInterpreter.TryGetOption(String,IOption)
IOption[] ICommandInterpreter.Options
CommandInterpreter.AddOption(IOption)
Boolean CommandInterpreter.TryGetOption(String,IOption)
IOption[] CommandInterpreter.Options


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IOption Interface Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IOption Interface

Glossary Item Box

The following tables list the members exposed by IOption.

Public Properties

 | Name | Description
Property | Type | Returns the type of the option value
Property | Value | Gets/sets the value of the option
Top

See Also

Reference

IOption Interface
CSharpTest.Net.Commands Namespace
Boolean ICommandInterpreter.TryGetOption(String,IOption)
IOption[] ICommandInterpreter.Options
CommandInterpreter.AddOption(IOption)
Boolean CommandInterpreter.TryGetOption(String,IOption)
IOption[] CommandInterpreter.Options


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IOption Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IOption Interface

Glossary Item Box

For a list of all members of this type, see IOption members.

Public Properties

 | Name | Description
Property | Type | Returns the type of the option value
Property | Value | Gets/sets the value of the option
Top

See Also

Reference

IOption Interface
CSharpTest.Net.Commands Namespace
Boolean ICommandInterpreter.TryGetOption(String,IOption)
IOption[] ICommandInterpreter.Options
CommandInterpreter.AddOption(IOption)
Boolean CommandInterpreter.TryGetOption(String,IOption)
IOption[] CommandInterpreter.Options


%%PageItemTitle%%

[image]
CSharpTest.Net
Type Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IOption Interface : Type Property

Glossary Item Box

Returns the type of the option value

Syntax

Visual Basic (Declaration)
ReadOnly Property Type As Type
C#
Type Type {get;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOption Interface
IOption Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > IOption Interface : Value Property

Glossary Item Box

Gets/sets the value of the option

Syntax

Visual Basic (Declaration)
Property Value As Object
C#
object Value {get; set;}

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
CommandInterpreter ci = new CommandInterpreter(new TestCommands());

IOption option = ci.Options[0];

//[Option("Other")]
Assert.AreEqual("Other", option.DisplayName);
Assert.AreEqual(typeof(int), option.Type);
//[AliasName("alias")]
//[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, option.AllNames.Length);
Assert.IsTrue(new List<string>(option.AllNames).Contains("Other"));
Assert.IsTrue(new List<string>(option.AllNames).Contains("alias"));
//[System.ComponentModel.Description("description")]
Assert.AreEqual("description", option.Description);
//[System.ComponentModel.Category("category")]
Assert.AreEqual("category", option.Category);
//[System.ComponentModel.Browsable(false)]
Assert.AreEqual(false, option.Visible);
//[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, option.Value);

{
    CommandFilterAttribute a = new CommandFilterAttribute();
    Assert.IsFalse(a.Visible);
    a.Visible = true;
    Assert.IsFalse(a.Visible);
}
{
    CommandAttribute a = new CommandAttribute();
    a.DisplayName = "test";
    a.AliasNames = new string[] { "alias" };
    Assert.AreEqual("test,alias", String.Join(",", a.AllNames));
    IDisplayInfo di = a;
    di.Help();//no-op
}
{
    AllArgumentsAttribute a = new AllArgumentsAttribute();
    Assert.AreEqual(typeof(AllArgumentsAttribute), a.GetType());
}
VB.NET Copy Code
Dim ci As New CommandInterpreter(New TestCommands())

Dim [option] As IOption = ci.Options(0)

'[Option("Other")]
Assert.AreEqual("Other", [option].DisplayName)
Assert.AreEqual(GetType(Integer), [option].Type)
'[AliasName("alias")]
'[System.ComponentModel.DisplayName("ingored-due-to-OptionAttribute")]
Assert.AreEqual(2, [option].AllNames.Length)
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("Other"))
Assert.IsTrue(New List(Of String)([option].AllNames).Contains("alias"))
'[System.ComponentModel.Description("description")]
Assert.AreEqual("description", [option].Description)
'[System.ComponentModel.Category("category")]
Assert.AreEqual("category", [option].Category)
'[System.ComponentModel.Browsable(false)]
Assert.AreEqual(False, [option].Visible)
'[System.ComponentModel.DefaultValue(-1)]
Assert.AreEqual(-1, [option].Value)

If True Then
    Dim a As New CommandFilterAttribute()
    Assert.IsFalse(a.Visible)
    a.Visible = True
    Assert.IsFalse(a.Visible)
End If
If True Then
    Dim a As New CommandAttribute()
    a.DisplayName = "test"
    a.AliasNames = New String() {"alias"}
    Assert.AreEqual("test,alias", [String].Join(",", a.AllNames))
    Dim di As IDisplayInfo = a
    di.Help()
    'no-op
End If
If True Then
    Dim a As New AllArgumentsAttribute()
    Assert.AreEqual(GetType(AllArgumentsAttribute), a.[GetType]())
End If

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOption Interface
IOption Members

Used By

Object CommandInterpreter.Get(String)
CommandInterpreter.Set(String,Object,Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadNextCharacter Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ReadNextCharacter Delegate

Glossary Item Box

Used for obtaining input directly from user rather than from the std:in stream

Syntax

Visual Basic (Declaration)
Public Delegate Function ReadNextCharacter() As Char
C#
public delegate char ReadNextCharacter()

Example

Library/Library.Test/TestCmdInterpreter.cs

C# Copy Code
string result;
CommandInterpreter ci = new CommandInterpreter(
    DefaultCommands.More | DefaultCommands.PipeCommands,
    new TestCommands());

//replace the keystroke wait
ci.ReadNextCharacter = GetSpace;

string input = String.Format("Count {0} | MORE", (int)(WindowHeight * 1.5));

result = Capture(ci, input);

StringReader sr = new StringReader(result);
int moreFound = 0;
int index = 0;
string line;
while( null != (line = sr.ReadLine()))
{
    if( line == "-- More --" )
        moreFound++;
    else
        Assert.AreEqual((++index).ToString(), line);
}

Assert.AreEqual(1, moreFound);
VB.NET Copy Code
Dim result As String
Dim ci As New CommandInterpreter(DefaultCommands.More Or DefaultCommands.PipeCommands, New TestCommands())

'replace the keystroke wait
ci.ReadNextCharacter = GetSpace

Dim input As String = [String].Format("Count {0} | MORE", DirectCast((WindowHeight * 1.5), Integer))

result = Capture(ci, input)

Dim sr As New StringReader(result)
Dim moreFound As Integer = 0
Dim index As Integer = 0
Dim line As String
While Nothing <> (line = sr.ReadLine())
    If line = "-- More --" Then
        System.Math.Max(System.Threading.Interlocked.Increment(moreFound),moreFound - 1)
    Else
        Assert.AreEqual((System.Threading.Interlocked.Increment(index)).ToString(), line)
    End If
End While

Assert.AreEqual(1, moreFound)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReadNextCharacter Members
CSharpTest.Net.Commands Namespace
ReadNextCharacter ICommandInterpreter.ReadNextCharacter
ReadNextCharacter CommandInterpreter.ReadNextCharacter


%%ItemTitle%%

CSharpTest.Net.Crypto Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Crypto Namespace

Glossary Item Box

Classes

Class | Description
Class | AESCryptoKey | Provides AES-256 bit encryption using a global IV (Init vector) based on the current process' entry assembly.
Class | AsciiEncoder | This class has been moved to CSharpTest.Net.Formatting.Safe64Encoding
Class | AsymmetricKey | Provides the ability to encrypt and decrypt block-transform data
Class | BinaryComparer | Dictionary comparer for comparing arrays of bytes by value equality
Class | CryptoKey | Base class for encryption/decryption classes
Class | Encryption | Maintains backwards compatibility for access to the encryption api
Class | Hash | Represents a comparable, sortable, hash code
Class | HashDerivedBytes<THash> | Provided an implementation very similiar to that of the Rfc2898DeriveBytes with the following excpetions: 1) any hash size can be used, 2) original key bytes are always hashed, 3) bytes generated are always rounded to hash size, thus GetBytes(4) + GetBytes(4) != GetBytes(8)
Class | HashStream | Represents a writtable stream for computing the hash value without retaining the data
Class | LocalHostKey | Provides access to local machine and local user encryption via the ProtectedData class
Class | ModifiedRijndael | This class is provided to essentially unlock the Rijndael algorithm from the constraints imposed by the AES standards. The Rijndael algorithm here supports a wider length of key sizes and allows users to explicitly set the number of rounds. This class is fully AES compliant when used with key sizes of 16, 24, or 32 bytes with rounds of 10, 12, and 14 respectivly.
Class | Password | Stores an encrypted version of the supplied password in memory so that it can be provided as clear-text to external systems.
Class | Password.EqualityComparer | Implements the equality comparer
Class | PasswordHash | Creates a salted hash
Class | PasswordKey | Creates an in-memory object that can be used for salted password encryption without storing the password in memory (based on Rfc2898DeriveBytes, SHA1 hash of password is stored)
Class | PBKDF2 | Provided an implementation of Rfc2898DeriveBytes accessable via the IPasswordDerivedBytes interface. One primary difference in GetBytes() ensures that the number of bytes generated are always rounded to hash size, thus GetBytes(4) + GetBytes(4) != GetBytes(8)
Class | RSAPrivateKey | Provides a wrapper around encrypting/decrypting with public/private key pairs from Certificats or CSP
Class | RSAPublicKey | Provides a wrapper around encrypting with public keys from Certificats or CSP
Class | RtlProcessKey | Provides the ability to encrypt and decrypt data accessable by the current process only, requires
Class | Salt | Represents a random sequence of bytes used to combine with hash and encryption values to provide an extra level of security.
Class | SaltedData | Represents the combination of Salt and Data together
Class | SecureStringStream | Allows you to stream raw bytes from a secure string, use UTF16 to decode text
Class | SecureStringUtils | Various utility methods for access to secure strings. Lets be real about this before you go off, SecureString is NOT secure, it obfuscated. If your in the process you can access it's contents; however, if you looking at a crash dump or swap file then the SecureString provides value... just not much ;) So these methods are actually my attempt to get people to USE a SecureString or similar class (i.e. Password) rather than continuing to use plain text strings. Hopefully with the ease of access within the process we can provide better security without.
Class | SecureTransfer | SecureTransfer is a static class that contains two user types, Sender and Receiver. Each provide one-half of a secure file transfer protocol. The security is based on pre-shared public keys used to sign all messages between the client and server. Additionally these keys are used durring the session negotiation to exchange a 256-bit session key. The session key is combined with a random salt for each message to produce an AES-256 cryptographic key. The file content is then tranfered with this session key.
Class | SecureTransfer.BeginTransferEventArgs | Event args that provides details about the start of a transfer
Class | SecureTransfer.BytesReceivedEventArgs | Event args that provides details about the contents of a transfer
Class | SecureTransfer.Client | Provides a file transfer handler for the client-side of file transfers.
Class | SecureTransfer.CompleteTransferEventArgs | Event args that provides details about the completion of a transfer
Class | SecureTransfer.DownloadBytesEventArgs | Event args that provides details about the contents of a transfer
Class | SecureTransfer.Server | Provides a file transfer handler for the server-side (receiver) of file transfers.
Class | UnicodeReader | Bufferless stream reader for Unicode data
Class | WhirlpoolManaged | The Whirlpool hashing function. References The Whirlpool algorithm was developed by Paulo S. L. M. Barreto and Vincent Rijmen. See P.S.L.M. Barreto, V. Rijmen, ``The Whirlpool hashing function,'' NESSIE submission, 2000 (tweaked version, 2001), https://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/whirlpool.zip @author Paulo S.L.M. Barreto @author Vincent Rijmen. ============================================================================= .Net Coversion on May 2010 by Roger O Knapp http://csharptest.net Performance considerations: coult be improved by moving to unmanaged/unsafe implementations, currently SHA512 is about 10% faster. The code remains, as much as was possible, exactly as it appears in the example 'c' implementation available from the documentation package on http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html ============================================================================= @version 3.0 (2003.03.12) ============================================================================= Differences from version 2.1: - Suboptimal diffusion matrix replaced by cir(1, 1, 4, 1, 8, 5, 2, 9). ============================================================================= Differences from version 2.0: - Generation of ISO/IEC 10118-3 test vectors. - Bug fix: nonzero carry was ignored when tallying the data length (this bug apparently only manifested itself when feeding data in pieces rather than in a single chunk at once). - Support for MS Visual C++ 64-bit integer arithmetic. Differences from version 1.0: - Original S-box replaced by the tweaked, hardware-efficient version. ============================================================================= THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Interfaces

 | Interface | Description
Interface | IEncryptDecrypt | A simple interface for encrypting and decrypting strings, obtain an instance through the static Encryption inteface calss.
Interface | IPasswordDerivedBytes | Provides an interface for abstracting the password derivation routine used for password key derivation

Delegates

 | Delegate | Description
Delegate | SecureTransfer.Client.TransmitMessageAction | Provides the transmission of a stream of bytes to the server/receiver and returns the result stream

Enumerations

 | Enumeration | Description
Enumeration | Salt.Size | Size of a salt-key in bits

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
AESCryptoKey Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AESCryptoKey Class

Glossary Item Box

Provides AES-256 bit encryption using a global IV (Init vector) based on the current process' entry assembly.

Syntax

Visual Basic (Declaration)
Public Class AESCryptoKey
   Inherits CryptoKey
   Implements IEncryptDecrypt
C#
public class AESCryptoKey : CryptoKey, IEncryptDecrypt

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] original = AESCryptoKey.ProcessDefaultIV;
try
{
    Assert.AreEqual(original, new AESCryptoKey().IV);

    byte[] newIv = new byte[16];
    new Random().NextBytes(newIv);
    AESCryptoKey.ProcessDefaultIV = newIv;

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV);
    Assert.AreEqual(newIv, new AESCryptoKey().IV);
}
finally
{
    AESCryptoKey.ProcessDefaultIV = original;
}
VB.NET Copy Code
Dim original As Byte() = AESCryptoKey.ProcessDefaultIV
Try
    Assert.AreEqual(original, New AESCryptoKey().IV)

    Dim newIv As Byte() = New Byte(16) {}
    New Random().NextBytes(newIv)
    AESCryptoKey.ProcessDefaultIV = newIv

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV)
    Assert.AreEqual(newIv, New AESCryptoKey().IV)
Finally
    AESCryptoKey.ProcessDefaultIV = original
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.AESCryptoKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Members
CSharpTest.Net.Crypto Namespace
AESCryptoKey PasswordKey.CreateKey()
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AESCryptoKey Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AESCryptoKey Class

Glossary Item Box

The following tables list the members exposed by AESCryptoKey.

Public Constructors

 | Name | Description
Public Constructor | AESCryptoKey Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | IV | Returns the AES 256 bit key this object was created with
Public Property | Key | Returns the AES 256 bit key this object was created with
static (Shared in Visual Basic) | ProcessDefaultIV | Used to define the IV for AES keys created in this process, by default this is MD5(UTF8(Name)) where Name is the short-name of either the entry-point assembly, or "CSharpTest.Net.Library" if undefined.
Top

Protected Properties

 | Name | Description
Protected Property | Algorithm | Returns the algorithm key or throws ObjectDisposedException
Top

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Overridden. Decrypts a stream of data
Public Method | Dispose | Overloaded. Overridden. Disposes of the key
Public Method | Encrypt | Overloaded. Overridden. Encrypts a stream of data
static (Shared in Visual Basic) | FromBytes | Serializes the KEY and IV to a single array of bytes. Use FromByteArray() to restore.
Public Method | ToArray | Serializes the KEY and IV to a single array of bytes. Use FromByteArray() to restore.
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Top

See Also

Reference

AESCryptoKey Class
CSharpTest.Net.Crypto Namespace
AESCryptoKey PasswordKey.CreateKey()
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AESCryptoKey Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : AESCryptoKey Constructor

Glossary Item Box

Overload List

Overload | Description
AESCryptoKey Constructor() | Creates a new key
AESCryptoKey Constructor(Byte[],Byte[]) | Creates an object representing the specified key and init vector

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AESCryptoKey Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class > AESCryptoKey Constructor : AESCryptoKey Constructor()

Glossary Item Box

Creates a new key

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public AESCryptoKey()

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] original = AESCryptoKey.ProcessDefaultIV;
try
{
    Assert.AreEqual(original, new AESCryptoKey().IV);

    byte[] newIv = new byte[16];
    new Random().NextBytes(newIv);
    AESCryptoKey.ProcessDefaultIV = newIv;

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV);
    Assert.AreEqual(newIv, new AESCryptoKey().IV);
}
finally
{
    AESCryptoKey.ProcessDefaultIV = original;
}
VB.NET Copy Code
Dim original As Byte() = AESCryptoKey.ProcessDefaultIV
Try
    Assert.AreEqual(original, New AESCryptoKey().IV)

    Dim newIv As Byte() = New Byte(16) {}
    New Random().NextBytes(newIv)
    AESCryptoKey.ProcessDefaultIV = newIv

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV)
    Assert.AreEqual(newIv, New AESCryptoKey().IV)
Finally
    AESCryptoKey.ProcessDefaultIV = original
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Overload List

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AESCryptoKey Constructor(Byte[],Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class > AESCryptoKey Constructor : AESCryptoKey Constructor(Byte[],Byte[])

key
iv

Glossary Item Box

Creates an object representing the specified key and init vector

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal key() As Byte, _
   ByVal iv() As Byte _
)
C#
public AESCryptoKey(
   byte[] key,
   byte[] iv
)

Parameters

key
iv

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] ivrandom = new byte[16];
new Random().NextBytes(ivrandom);

using (AESCryptoKey k1 = new AESCryptoKey())
using (AESCryptoKey k2 = new AESCryptoKey(k1.Key, k1.IV))
using (AESCryptoKey kBadIv = new AESCryptoKey(k1.Key, ivrandom))
{
    Assert.AreEqual(k1.Key, k2.Key);
    Assert.AreEqual(k1.IV, k2.IV);
    Assert.AreEqual("test", k2.Decrypt(k1.Encrypt("test")));

    Assert.AreEqual(k1.Key, kBadIv.Key);
    Assert.AreNotEqual(k1.IV, kBadIv.IV);
    try
    {   //one of two possible outcomes, junk or exception
        Assert.AreNotEqual("test", kBadIv.Decrypt(k1.Encrypt("test")));
    }
    catch (System.Security.Cryptography.CryptographicException) { }
}
VB.NET Copy Code
Dim ivrandom As Byte() = New Byte(16) {}
New Random().NextBytes(ivrandom)

Using k1 As New AESCryptoKey()
    Using k2 As New AESCryptoKey(k1.Key, k1.IV)
        Using kBadIv As New AESCryptoKey(k1.Key, ivrandom)
            Assert.AreEqual(k1.Key, k2.Key)
            Assert.AreEqual(k1.IV, k2.IV)
            Assert.AreEqual("test", k2.Decrypt(k1.Encrypt("test")))

            Assert.AreEqual(k1.Key, kBadIv.Key)
            Assert.AreNotEqual(k1.IV, kBadIv.IV)
            Try
                'one of two possible outcomes, junk or exception
                Assert.AreNotEqual("test", kBadIv.Decrypt(k1.Encrypt("test")))
            Catch generatedExceptionName As System.Security.Cryptography.CryptographicException
            End Try
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Overload List

Used By

AESCryptoKey AESCryptoKey.FromBytes(Byte[])
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AESCryptoKey Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AESCryptoKey Class

Glossary Item Box

For a list of all members of this type, see AESCryptoKey members.

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Overridden. Decrypts a stream of data
Public Method | Dispose | Overloaded. Overridden. Disposes of the key
Public Method | Encrypt | Overloaded. Overridden. Encrypts a stream of data
static (Shared in Visual Basic) | FromBytes | Serializes the KEY and IV to a single array of bytes. Use FromByteArray() to restore.
Public Method | ToArray | Serializes the KEY and IV to a single array of bytes. Use FromByteArray() to restore.
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Top

See Also

Reference

AESCryptoKey Class
CSharpTest.Net.Crypto Namespace
AESCryptoKey PasswordKey.CreateKey()
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : Decrypt Method

Glossary Item Box

Decrypts a stream of data

Overload List

Overload | Description
Decrypt(Stream) | Decrypts a stream of data
Decrypt(Byte[]) | Decrypts a raw data block as a set of bytes
Decrypt(String) | Decrypts the base-64 encoded bytes, decrypts the data and returns the string (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Decrypt(String,ByteEncoding) | Decrypts the base-64 encoded bytes, decrypts the data and returns the string (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Base Implementation in Decrypt


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class > Decrypt Method : Decrypt(Stream) Method

stream

Glossary Item Box

Decrypts a stream of data

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Decrypt( _
   ByVal stream As Stream _
) As Stream
C#
public override Stream Decrypt(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Overload List
Base Implementation in Decrypt(Stream)

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class > Decrypt Method : Decrypt(Byte[]) Method

blob

Glossary Item Box

Decrypts a raw data block as a set of bytes

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Decrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
public override byte[] Decrypt(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Overload List
Base Implementation in Decrypt(Byte[])

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : Dispose Method

Glossary Item Box

Disposes of the key

Overload List

Overload | Description
Dispose(Boolean) | Disposes of the key
Dispose() | Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of the key

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : Encrypt Method

Glossary Item Box

Encrypts a stream of data

Overload List

Overload | Description
Encrypt(Stream) | Encrypts a stream of data
Encrypt(Byte[]) | Encrypts a raw data block as a set of bytes
Encrypt(String) | Encrypts the encoded text and returns the base-64 encoded result (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Encrypt(String,ByteEncoding) | Encrypts the encoded text and returns the base-64 encoded result (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Base Implementation in Encrypt


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class > Encrypt Method : Encrypt(Stream) Method

stream

Glossary Item Box

Encrypts a stream of data

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Encrypt( _
   ByVal stream As Stream _
) As Stream
C#
public override Stream Encrypt(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Overload List
Base Implementation in Encrypt(Stream)

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class > Encrypt Method : Encrypt(Byte[]) Method

blob

Glossary Item Box

Encrypts a raw data block as a set of bytes

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Encrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
public override byte[] Encrypt(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members
Overload List
Base Implementation in Encrypt(Byte[])

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : FromBytes Method

serializedBytes

Glossary Item Box

Serializes the KEY and IV to a single array of bytes. Use FromByteArray() to restore.

Syntax

Visual Basic (Declaration)
Public Shared Function FromBytes( _
   ByVal serializedBytes() As Byte _
) As AESCryptoKey
C#
public static AESCryptoKey FromBytes(
   byte[] serializedBytes
)

Parameters

serializedBytes

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] ivrandom = new byte[16];
new Random().NextBytes(ivrandom);

using (AESCryptoKey k1 = new AESCryptoKey())
using (AESCryptoKey k2 = AESCryptoKey.FromBytes(k1.ToArray()))
{
    Assert.AreEqual(k1.Key, k2.Key);
    Assert.AreEqual(k1.IV, k2.IV);
}
VB.NET Copy Code
Dim ivrandom As Byte() = New Byte(16) {}
New Random().NextBytes(ivrandom)

Using k1 As New AESCryptoKey()
    Using k2 As AESCryptoKey = AESCryptoKey.FromBytes(k1.ToArray())
        Assert.AreEqual(k1.Key, k2.Key)
        Assert.AreEqual(k1.IV, k2.IV)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : ToArray Method

Glossary Item Box

Serializes the KEY and IV to a single array of bytes. Use FromByteArray() to restore.

Syntax

Visual Basic (Declaration)
Public Function ToArray() As Byte()
C#
public byte[] ToArray()

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] ivrandom = new byte[16];
new Random().NextBytes(ivrandom);

using (AESCryptoKey k1 = new AESCryptoKey())
using (AESCryptoKey k2 = AESCryptoKey.FromBytes(k1.ToArray()))
{
    Assert.AreEqual(k1.Key, k2.Key);
    Assert.AreEqual(k1.IV, k2.IV);
}
VB.NET Copy Code
Dim ivrandom As Byte() = New Byte(16) {}
New Random().NextBytes(ivrandom)

Using k1 As New AESCryptoKey()
    Using k2 As AESCryptoKey = AESCryptoKey.FromBytes(k1.ToArray())
        Assert.AreEqual(k1.Key, k2.Key)
        Assert.AreEqual(k1.IV, k2.IV)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
AESCryptoKey Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AESCryptoKey Class

Glossary Item Box

For a list of all members of this type, see AESCryptoKey members.

Public Properties

 | Name | Description
Public Property | IV | Returns the AES 256 bit key this object was created with
Public Property | Key | Returns the AES 256 bit key this object was created with
static (Shared in Visual Basic) | ProcessDefaultIV | Used to define the IV for AES keys created in this process, by default this is MD5(UTF8(Name)) where Name is the short-name of either the entry-point assembly, or "CSharpTest.Net.Library" if undefined.
Top

Protected Properties

 | Name | Description
Protected Property | Algorithm | Returns the algorithm key or throws ObjectDisposedException
Top

See Also

Reference

AESCryptoKey Class
CSharpTest.Net.Crypto Namespace
AESCryptoKey PasswordKey.CreateKey()
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Algorithm Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : Algorithm Property

Glossary Item Box

Returns the algorithm key or throws ObjectDisposedException

Syntax

Visual Basic (Declaration)
Protected ReadOnly Property Algorithm As SymmetricAlgorithm
C#
protected SymmetricAlgorithm Algorithm {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
IV Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : IV Property

Glossary Item Box

Returns the AES 256 bit key this object was created with

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IV As Byte()
C#
public byte[] IV {get;}

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] original = AESCryptoKey.ProcessDefaultIV;
try
{
    Assert.AreEqual(original, new AESCryptoKey().IV);

    byte[] newIv = new byte[16];
    new Random().NextBytes(newIv);
    AESCryptoKey.ProcessDefaultIV = newIv;

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV);
    Assert.AreEqual(newIv, new AESCryptoKey().IV);
}
finally
{
    AESCryptoKey.ProcessDefaultIV = original;
}
VB.NET Copy Code
Dim original As Byte() = AESCryptoKey.ProcessDefaultIV
Try
    Assert.AreEqual(original, New AESCryptoKey().IV)

    Dim newIv As Byte() = New Byte(16) {}
    New Random().NextBytes(newIv)
    AESCryptoKey.ProcessDefaultIV = newIv

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV)
    Assert.AreEqual(newIv, New AESCryptoKey().IV)
Finally
    AESCryptoKey.ProcessDefaultIV = original
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members

Used By

Byte[] AESCryptoKey.ToArray()

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Key Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : Key Property

Glossary Item Box

Returns the AES 256 bit key this object was created with

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Key As Byte()
C#
public byte[] Key {get;}

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] ivrandom = new byte[16];
new Random().NextBytes(ivrandom);

using (AESCryptoKey k1 = new AESCryptoKey())
using (AESCryptoKey k2 = AESCryptoKey.FromBytes(k1.ToArray()))
{
    Assert.AreEqual(k1.Key, k2.Key);
    Assert.AreEqual(k1.IV, k2.IV);
}
VB.NET Copy Code
Dim ivrandom As Byte() = New Byte(16) {}
New Random().NextBytes(ivrandom)

Using k1 As New AESCryptoKey()
    Using k2 As AESCryptoKey = AESCryptoKey.FromBytes(k1.ToArray())
        Assert.AreEqual(k1.Key, k2.Key)
        Assert.AreEqual(k1.IV, k2.IV)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members

Used By

Byte[] AESCryptoKey.ToArray()

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessDefaultIV Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AESCryptoKey Class : ProcessDefaultIV Property

Glossary Item Box

Used to define the IV for AES keys created in this process, by default this is MD5(UTF8(Name)) where Name is the short-name of either the entry-point assembly, or "CSharpTest.Net.Library" if undefined.

Syntax

Visual Basic (Declaration)
Public Shared Property ProcessDefaultIV As Byte()
C#
public static byte[] ProcessDefaultIV {get; set;}

Remarks

The process default IV is used with AESCryptoKey instances that are created without explicitly providing the IV value for the key. This is done internally when using the Password class' CreateKey(...), Encrypt(...), or Decrypt(...) methods. While this worked well enough for some programs, this has proven to be a flawed approach as the entry-point assembly can change. For example if another .NET process call Assembly.Execute() on your executable. Applications are advised that they should capture the existing value and store that in App.Config, and set the following prior to using this class, or the Password class. The entry-points related to this that have been marked Obsolete() will be removed in the long-term and by capturing this value and manually using it you can ensure your application will continue to function properly.

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] original = AESCryptoKey.ProcessDefaultIV;
try
{
    Assert.AreEqual(original, new AESCryptoKey().IV);

    byte[] newIv = new byte[16];
    new Random().NextBytes(newIv);
    AESCryptoKey.ProcessDefaultIV = newIv;

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV);
    Assert.AreEqual(newIv, new AESCryptoKey().IV);
}
finally
{
    AESCryptoKey.ProcessDefaultIV = original;
}
VB.NET Copy Code
Dim original As Byte() = AESCryptoKey.ProcessDefaultIV
Try
    Assert.AreEqual(original, New AESCryptoKey().IV)

    Dim newIv As Byte() = New Byte(16) {}
    New Random().NextBytes(newIv)
    AESCryptoKey.ProcessDefaultIV = newIv

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV)
    Assert.AreEqual(newIv, New AESCryptoKey().IV)
Finally
    AESCryptoKey.ProcessDefaultIV = original
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AESCryptoKey Class
AESCryptoKey Members

Source Code

Library/Crypto/AESCryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AsciiEncoder Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AsciiEncoder Class

Glossary Item Box

This class has been moved to CSharpTest.Net.Formatting.Safe64Encoding

Syntax

Visual Basic (Declaration)
Public Class AsciiEncoder
C#
public class AsciiEncoder

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.AsciiEncoder

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsciiEncoder Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/AsciiEncoder.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AsciiEncoder Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AsciiEncoder Class

Glossary Item Box

The following tables list the members exposed by AsciiEncoder.

Public Constructors

 | Name | Description
Public Constructor | AsciiEncoder Constructor |
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DecodeBytes | Overloaded. Returns the original byte array provided when the encoding was performed
static (Shared in Visual Basic) | EncodeBytes | Returns a encoded string of ascii characters that are URI safe
Top

See Also

Reference

AsciiEncoder Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/AsciiEncoder.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AsciiEncoder Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsciiEncoder Class : AsciiEncoder Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public AsciiEncoder()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsciiEncoder Class
AsciiEncoder Members

Source Code

Library/Crypto/AsciiEncoder.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AsciiEncoder Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AsciiEncoder Class

Glossary Item Box

For a list of all members of this type, see AsciiEncoder members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DecodeBytes | Overloaded. Returns the original byte array provided when the encoding was performed
static (Shared in Visual Basic) | EncodeBytes | Returns a encoded string of ascii characters that are URI safe
Top

See Also

Reference

AsciiEncoder Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/AsciiEncoder.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsciiEncoder Class : DecodeBytes Method

Glossary Item Box

Returns the original byte array provided when the encoding was performed

Overload List

Overload | Description
DecodeBytes(String) | Returns the original byte array provided when the encoding was performed
DecodeBytes(Byte[]) | Decodes the ascii text from the bytes provided into the original byte array

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsciiEncoder Class
AsciiEncoder Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsciiEncoder Class > DecodeBytes Method : DecodeBytes(String) Method

data

Glossary Item Box

Returns the original byte array provided when the encoding was performed

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal data As String _
) As Byte()
C#
public static byte[] DecodeBytes(
   string data
)

Parameters

data

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
//char count must by multiple of 4 for the compare to work
string encoded = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
byte[] data = Safe64Encoding.DecodeBytes(encoded);
Assert.AreEqual(encoded, Safe64Encoding.EncodeBytes(data));
data = AsciiEncoder.DecodeBytes(encoded);
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data));
data = AsciiEncoder.DecodeBytes(Encoding.ASCII.GetBytes(encoded));
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data));
VB.NET Copy Code
'char count must by multiple of 4 for the compare to work
Dim encoded As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
Dim data As Byte() = Safe64Encoding.DecodeBytes(encoded)
Assert.AreEqual(encoded, Safe64Encoding.EncodeBytes(data))
data = AsciiEncoder.DecodeBytes(encoded)
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data))
data = AsciiEncoder.DecodeBytes(Encoding.ASCII.GetBytes(encoded))
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsciiEncoder Class
AsciiEncoder Members
Overload List

Source Code

Library/Crypto/AsciiEncoder.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsciiEncoder Class > DecodeBytes Method : DecodeBytes(Byte[]) Method

inData

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal inData() As Byte _
) As Byte()
C#
public static byte[] DecodeBytes(
   byte[] inData
)

Parameters

inData

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
//char count must by multiple of 4 for the compare to work
string encoded = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
byte[] data = Safe64Encoding.DecodeBytes(encoded);
Assert.AreEqual(encoded, Safe64Encoding.EncodeBytes(data));
data = AsciiEncoder.DecodeBytes(encoded);
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data));
data = AsciiEncoder.DecodeBytes(Encoding.ASCII.GetBytes(encoded));
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data));
VB.NET Copy Code
'char count must by multiple of 4 for the compare to work
Dim encoded As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
Dim data As Byte() = Safe64Encoding.DecodeBytes(encoded)
Assert.AreEqual(encoded, Safe64Encoding.EncodeBytes(data))
data = AsciiEncoder.DecodeBytes(encoded)
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data))
data = AsciiEncoder.DecodeBytes(Encoding.ASCII.GetBytes(encoded))
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsciiEncoder Class
AsciiEncoder Members
Overload List

Source Code

Library/Crypto/AsciiEncoder.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsciiEncoder Class : EncodeBytes Method

inData

Glossary Item Box

Returns a encoded string of ascii characters that are URI safe

Syntax

Visual Basic (Declaration)
Public Shared Function EncodeBytes( _
   ByVal inData() As Byte _
) As String
C#
public static string EncodeBytes(
   byte[] inData
)

Parameters

inData

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
//char count must by multiple of 4 for the compare to work
string encoded = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
byte[] data = Safe64Encoding.DecodeBytes(encoded);
Assert.AreEqual(encoded, Safe64Encoding.EncodeBytes(data));
data = AsciiEncoder.DecodeBytes(encoded);
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data));
data = AsciiEncoder.DecodeBytes(Encoding.ASCII.GetBytes(encoded));
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data));
VB.NET Copy Code
'char count must by multiple of 4 for the compare to work
Dim encoded As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
Dim data As Byte() = Safe64Encoding.DecodeBytes(encoded)
Assert.AreEqual(encoded, Safe64Encoding.EncodeBytes(data))
data = AsciiEncoder.DecodeBytes(encoded)
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data))
data = AsciiEncoder.DecodeBytes(Encoding.ASCII.GetBytes(encoded))
Assert.AreEqual(encoded, AsciiEncoder.EncodeBytes(data))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsciiEncoder Class
AsciiEncoder Members

Source Code

Library/Crypto/AsciiEncoder.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AsymmetricKey Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AsymmetricKey Class

Glossary Item Box

Provides the ability to encrypt and decrypt block-transform data

Syntax

Visual Basic (Declaration)
Public MustInherit Class AsymmetricKey
   Inherits CryptoKey
   Implements IEncryptDecrypt
C#
public abstract class AsymmetricKey : CryptoKey, IEncryptDecrypt

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.AsymmetricKey
CSharpTest.Net.Crypto.LocalHostKey
CSharpTest.Net.Crypto.RSAPublicKey
CSharpTest.Net.Crypto.RtlProcessKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/AsymmetricKey.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AsymmetricKey Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AsymmetricKey Class

Glossary Item Box

The following tables list the members exposed by AsymmetricKey.

Protected Constructors

 | Name | Description
Protected Constructor | AsymmetricKey Constructor |
Top

Protected Properties

 | Name | Description
Protected Property | BlockSize | Provides the size, in bytes, of the maximum transform unit
Protected Property | TransformSize | Proivdes the output size, in bytes, assuming an input of BlockSize
Top

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Overridden. Decrypts a raw data block as a set of bytes
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Encrypt | Overloaded. Overridden. Encrypts a raw data block as a set of bytes
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Decrypts a raw data block as a set of bytes
Protected Method | EncryptBlock | Encrypts a raw data block as a set of bytes
Top

See Also

Reference

AsymmetricKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/AsymmetricKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AsymmetricKey Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class : AsymmetricKey Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected AsymmetricKey()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AsymmetricKey Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AsymmetricKey Class

Glossary Item Box

For a list of all members of this type, see AsymmetricKey members.

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Overridden. Decrypts a raw data block as a set of bytes
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Encrypt | Overloaded. Overridden. Encrypts a raw data block as a set of bytes
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Decrypts a raw data block as a set of bytes
Protected Method | EncryptBlock | Encrypts a raw data block as a set of bytes
Top

See Also

Reference

AsymmetricKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/AsymmetricKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class : Decrypt Method

Glossary Item Box

Decrypts a raw data block as a set of bytes

Overload List

Overload | Description
Decrypt(Byte[]) | Decrypts a raw data block as a set of bytes
Decrypt(Stream) | Wraps the stream with a cryptographic stream
Decrypt(String) | Decrypts the base-64 encoded bytes, decrypts the data and returns the string (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Decrypt(String,ByteEncoding) | Decrypts the base-64 encoded bytes, decrypts the data and returns the string (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members
Base Implementation in Decrypt


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class > Decrypt Method : Decrypt(Byte[]) Method

blob

Glossary Item Box

Decrypts a raw data block as a set of bytes

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Decrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
public override byte[] Decrypt(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members
Overload List
Base Implementation in Decrypt(Byte[])

Source Code

Library/Crypto/AsymmetricKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class > Decrypt Method : Decrypt(Stream) Method

stream

Glossary Item Box

Wraps the stream with a cryptographic stream

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Decrypt( _
   ByVal stream As Stream _
) As Stream
C#
public override Stream Decrypt(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members
Overload List
Base Implementation in Decrypt(Stream)

Source Code

Library/Crypto/AsymmetricKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecryptBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class : DecryptBlock Method

blob

Glossary Item Box

Decrypts a raw data block as a set of bytes

Syntax

Visual Basic (Declaration)
Protected MustOverride Function DecryptBlock( _
   ByVal blob() As Byte _
) As Byte()
C#
protected abstract byte[] DecryptBlock(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class : Encrypt Method

Glossary Item Box

Encrypts a raw data block as a set of bytes

Overload List

Overload | Description
Encrypt(Byte[]) | Encrypts a raw data block as a set of bytes
Encrypt(Stream) | Wraps the stream with a cryptographic stream
Encrypt(String) | Encrypts the encoded text and returns the base-64 encoded result (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Encrypt(String,ByteEncoding) | Encrypts the encoded text and returns the base-64 encoded result (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members
Base Implementation in Encrypt


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class > Encrypt Method : Encrypt(Byte[]) Method

blob

Glossary Item Box

Encrypts a raw data block as a set of bytes

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Encrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
public override byte[] Encrypt(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members
Overload List
Base Implementation in Encrypt(Byte[])

Source Code

Library/Crypto/AsymmetricKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class > Encrypt Method : Encrypt(Stream) Method

stream

Glossary Item Box

Wraps the stream with a cryptographic stream

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Encrypt( _
   ByVal stream As Stream _
) As Stream
C#
public override Stream Encrypt(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members
Overload List
Base Implementation in Encrypt(Stream)

Source Code

Library/Crypto/AsymmetricKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EncryptBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class : EncryptBlock Method

blob

Glossary Item Box

Encrypts a raw data block as a set of bytes

Syntax

Visual Basic (Declaration)
Protected MustOverride Function EncryptBlock( _
   ByVal blob() As Byte _
) As Byte()
C#
protected abstract byte[] EncryptBlock(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
AsymmetricKey Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AsymmetricKey Class

Glossary Item Box

For a list of all members of this type, see AsymmetricKey members.

Protected Properties

 | Name | Description
Protected Property | BlockSize | Provides the size, in bytes, of the maximum transform unit
Protected Property | TransformSize | Proivdes the output size, in bytes, assuming an input of BlockSize
Top

See Also

Reference

AsymmetricKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/AsymmetricKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BlockSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class : BlockSize Property

Glossary Item Box

Provides the size, in bytes, of the maximum transform unit

Syntax

Visual Basic (Declaration)
Protected MustOverride ReadOnly Property BlockSize As Integer
C#
protected abstract int BlockSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TransformSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > AsymmetricKey Class : TransformSize Property

Glossary Item Box

Proivdes the output size, in bytes, assuming an input of BlockSize

Syntax

Visual Basic (Declaration)
Protected MustOverride ReadOnly Property TransformSize As Integer
C#
protected abstract int TransformSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AsymmetricKey Class
AsymmetricKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BinaryComparer Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : BinaryComparer Class

Glossary Item Box

Dictionary comparer for comparing arrays of bytes by value equality

Syntax

Visual Basic (Declaration)
Public NotInheritable Class BinaryComparer
C#
public sealed class BinaryComparer

Example

Library/Library.Test/TestBinaryComparer.cs

C# Copy Code
List<byte[]> all = new List<byte[]>();

all.Add(null);
all.Add(Guid.Empty.ToByteArray());
for (int i = 0; i < 1000; i++)
    all.Add(Guid.NewGuid().ToByteArray());

all.Sort(new BinaryComparer());

byte[] last = null;
Assert.IsNull(all[0]);
all.RemoveAt(0);

foreach (byte[] entry in all)
{
    if(last != null)
        Assert.IsTrue(StringComparer.Ordinal.Compare(Convert.ToBase64String(last), Convert.ToBase64String(entry)) < 0);
    Assert.IsTrue(BinaryComparer.Compare(last, entry) < 0);
}
VB.NET Copy Code
Dim all As New List(Of Byte())()

all.Add(Nothing)
all.Add(Guid.Empty.ToByteArray())
Dim i As Integer = 0
While i < 1000
    all.Add(Guid.NewGuid().ToByteArray())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

all.Sort(New BinaryComparer())

Dim last As Byte() = Nothing
Assert.IsNull(all(0))
all.RemoveAt(0)

For Each entry As Byte() In all
    If last <> Nothing Then
        Assert.IsTrue(StringComparer.Ordinal.Compare(Convert.ToBase64String(last), Convert.ToBase64String(entry)) < 0)
    End If
    Assert.IsTrue(BinaryComparer.Compare(last, entry) < 0)
Next

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.BinaryComparer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BinaryComparer Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/BinaryComparer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BinaryComparer Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : BinaryComparer Class

Glossary Item Box

The following tables list the members exposed by BinaryComparer.

Public Constructors

 | Name | Description
Public Constructor | BinaryComparer Constructor |
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Compare | Compares the contents of the byte arrays and returns the result.
static (Shared in Visual Basic) | Equals | Overloaded. returns true if both arrays contain the exact same set of bytes.
static (Shared in Visual Basic) | GetHashCode | Overloaded. Returns a hash code the instance of the object
Top

See Also

Reference

BinaryComparer Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/BinaryComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BinaryComparer Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > BinaryComparer Class : BinaryComparer Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public BinaryComparer()

Example

Library/Library.Test/TestBinaryComparer.cs

C# Copy Code
List<byte[]> all = new List<byte[]>();

all.Add(null);
all.Add(Guid.Empty.ToByteArray());
for (int i = 0; i < 1000; i++)
    all.Add(Guid.NewGuid().ToByteArray());

all.Sort(new BinaryComparer());

byte[] last = null;
Assert.IsNull(all[0]);
all.RemoveAt(0);

foreach (byte[] entry in all)
{
    if(last != null)
        Assert.IsTrue(StringComparer.Ordinal.Compare(Convert.ToBase64String(last), Convert.ToBase64String(entry)) < 0);
    Assert.IsTrue(BinaryComparer.Compare(last, entry) < 0);
}
VB.NET Copy Code
Dim all As New List(Of Byte())()

all.Add(Nothing)
all.Add(Guid.Empty.ToByteArray())
Dim i As Integer = 0
While i < 1000
    all.Add(Guid.NewGuid().ToByteArray())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

all.Sort(New BinaryComparer())

Dim last As Byte() = Nothing
Assert.IsNull(all(0))
all.RemoveAt(0)

For Each entry As Byte() In all
    If last <> Nothing Then
        Assert.IsTrue(StringComparer.Ordinal.Compare(Convert.ToBase64String(last), Convert.ToBase64String(entry)) < 0)
    End If
    Assert.IsTrue(BinaryComparer.Compare(last, entry) < 0)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BinaryComparer Class
BinaryComparer Members

Source Code

Library/Crypto/BinaryComparer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BinaryComparer Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : BinaryComparer Class

Glossary Item Box

For a list of all members of this type, see BinaryComparer members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Compare | Compares the contents of the byte arrays and returns the result.
static (Shared in Visual Basic) | Equals | Overloaded. returns true if both arrays contain the exact same set of bytes.
static (Shared in Visual Basic) | GetHashCode | Overloaded. Returns a hash code the instance of the object
Top

See Also

Reference

BinaryComparer Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/BinaryComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Compare Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > BinaryComparer Class : Compare Method

ar1
ar2

Glossary Item Box

Compares the contents of the byte arrays and returns the result.

Syntax

Visual Basic (Declaration)
Public Shared Function Compare( _
   ByVal ar1() As Byte, _
   ByVal ar2() As Byte _
) As Integer
C#
public static int Compare(
   byte[] ar1,
   byte[] ar2
)

Parameters

ar1
ar2

Example

Library/Library.Test/TestBinaryComparer.cs

C# Copy Code
List<byte[]> all = new List<byte[]>();

all.Add(null);
all.Add(Guid.Empty.ToByteArray());
for (int i = 0; i < 1000; i++)
    all.Add(Guid.NewGuid().ToByteArray());

all.Sort(new BinaryComparer());

byte[] last = null;
Assert.IsNull(all[0]);
all.RemoveAt(0);

foreach (byte[] entry in all)
{
    if(last != null)
        Assert.IsTrue(StringComparer.Ordinal.Compare(Convert.ToBase64String(last), Convert.ToBase64String(entry)) < 0);
    Assert.IsTrue(BinaryComparer.Compare(last, entry) < 0);
}
VB.NET Copy Code
Dim all As New List(Of Byte())()

all.Add(Nothing)
all.Add(Guid.Empty.ToByteArray())
Dim i As Integer = 0
While i < 1000
    all.Add(Guid.NewGuid().ToByteArray())
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

all.Sort(New BinaryComparer())

Dim last As Byte() = Nothing
Assert.IsNull(all(0))
all.RemoveAt(0)

For Each entry As Byte() In all
    If last <> Nothing Then
        Assert.IsTrue(StringComparer.Ordinal.Compare(Convert.ToBase64String(last), Convert.ToBase64String(entry)) < 0)
    End If
    Assert.IsTrue(BinaryComparer.Compare(last, entry) < 0)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BinaryComparer Class
BinaryComparer Members

Used By

Int32 Hash.CompareTo(Hash)
Int32 PasswordHash.CompareTo(PasswordHash)
Boolean BinaryComparer.Equals(Byte[],Byte[])

Source Code

Library/Crypto/BinaryComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > BinaryComparer Class : Equals Method

Glossary Item Box

returns true if both arrays contain the exact same set of bytes.

Overload List

Overload | Description
Equals(Byte[],Byte[]) | returns true if both arrays contain the exact same set of bytes.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BinaryComparer Class
BinaryComparer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Byte[],Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > BinaryComparer Class > Equals Method : Equals(Byte[],Byte[]) Method

ar1
ar2

Glossary Item Box

returns true if both arrays contain the exact same set of bytes.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Equals( _
   ByVal ar1() As Byte, _
   ByVal ar2() As Byte _
) As Boolean
C#
public static bool Equals(
   byte[] ar1,
   byte[] ar2
)

Parameters

ar1
ar2

Example

Library/Library.Test/TestBinaryComparer.cs

C# Copy Code
Assert.IsTrue(BinaryComparer.Equals(null, null));
Assert.IsTrue(BinaryComparer.Equals(new byte[] { }, new byte[] { }));
Assert.IsTrue(BinaryComparer.Equals(new byte[] { 1, 2, 3 }, new byte[] { 1, 2, 3 }));

Assert.IsFalse(BinaryComparer.Equals(null, new byte[] { 1, 2, 3 }));
Assert.IsFalse(BinaryComparer.Equals(new byte[] { 1, 2, 3 }, null));
Assert.IsFalse(BinaryComparer.Equals(new byte[] { 1, 2 }, new byte[] { 1, 2, 3 }));
Assert.IsFalse(BinaryComparer.Equals(new byte[] { 1, 2, 3 }, new byte[] { 1, 2 }));
VB.NET Copy Code
Assert.IsTrue(BinaryComparer.Equals(Nothing, Nothing))
Assert.IsTrue(BinaryComparer.Equals(New Byte() {}, New Byte() {}))
Assert.IsTrue(BinaryComparer.Equals(New Byte() {1, 2, 3}, New Byte() {1, 2, 3}))

Assert.IsFalse(BinaryComparer.Equals(Nothing, New Byte() {1, 2, 3}))
Assert.IsFalse(BinaryComparer.Equals(New Byte() {1, 2, 3}, Nothing))
Assert.IsFalse(BinaryComparer.Equals(New Byte() {1, 2}, New Byte() {1, 2, 3}))
Assert.IsFalse(BinaryComparer.Equals(New Byte() {1, 2, 3}, New Byte() {1, 2}))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BinaryComparer Class
BinaryComparer Members
Overload List

Source Code

Library/Crypto/BinaryComparer.cs

Used By

Boolean Salt.Equals(Salt)


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > BinaryComparer Class : GetHashCode Method

Glossary Item Box

Returns a hash code the instance of the object

Overload List

Overload | Description
GetHashCode(Byte[]) | Returns a hash code the instance of the object

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BinaryComparer Class
BinaryComparer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > BinaryComparer Class > GetHashCode Method : GetHashCode(Byte[]) Method

bytes

Glossary Item Box

Returns a hash code the instance of the object

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function GetHashCode( _
   ByVal bytes() As Byte _
) As Integer
C#
public static int GetHashCode(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestBinaryComparer.cs

C# Copy Code
Assert.AreEqual(0, BinaryComparer.GetHashCode(null));
Assert.AreEqual(0, BinaryComparer.GetHashCode(new byte[] { }));
Assert.AreEqual(BinaryComparer.GetHashCode(new byte[] { 1, 2, 3 }), BinaryComparer.GetHashCode(new byte[] { 1, 2, 3 }));

Assert.AreNotEqual(BinaryComparer.GetHashCode(null), BinaryComparer.GetHashCode(new byte[] { 1, 2, 3 }));
Assert.AreNotEqual(BinaryComparer.GetHashCode(new byte[] { 1, 2, 3 }), BinaryComparer.GetHashCode(null));
Assert.AreNotEqual(BinaryComparer.GetHashCode(new byte[] { 1, 2 }), BinaryComparer.GetHashCode(new byte[] { 1, 2, 3 }));
Assert.AreNotEqual(BinaryComparer.GetHashCode(new byte[] { 1, 2, 3 }), BinaryComparer.GetHashCode(new byte[] { 1, 2 }));
VB.NET Copy Code
Assert.AreEqual(0, BinaryComparer.GetHashCode(Nothing))
Assert.AreEqual(0, BinaryComparer.GetHashCode(New Byte() {}))
Assert.AreEqual(BinaryComparer.GetHashCode(New Byte() {1, 2, 3}), BinaryComparer.GetHashCode(New Byte() {1, 2, 3}))

Assert.AreNotEqual(BinaryComparer.GetHashCode(Nothing), BinaryComparer.GetHashCode(New Byte() {1, 2, 3}))
Assert.AreNotEqual(BinaryComparer.GetHashCode(New Byte() {1, 2, 3}), BinaryComparer.GetHashCode(Nothing))
Assert.AreNotEqual(BinaryComparer.GetHashCode(New Byte() {1, 2}), BinaryComparer.GetHashCode(New Byte() {1, 2, 3}))
Assert.AreNotEqual(BinaryComparer.GetHashCode(New Byte() {1, 2, 3}), BinaryComparer.GetHashCode(New Byte() {1, 2}))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BinaryComparer Class
BinaryComparer Members
Overload List

Source Code

Library/Crypto/BinaryComparer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CryptoKey Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : CryptoKey Class

Glossary Item Box

Base class for encryption/decryption classes

Syntax

Visual Basic (Declaration)
Public MustInherit Class CryptoKey
   Implements IEncryptDecrypt
C#
public abstract class CryptoKey : IEncryptDecrypt

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.AESCryptoKey
CSharpTest.Net.Crypto.AsymmetricKey
CSharpTest.Net.Crypto.PasswordKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/CryptoKey.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
CryptoKey Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : CryptoKey Class

Glossary Item Box

The following tables list the members exposed by CryptoKey.

Protected Constructors

 | Name | Description
Protected Constructor | CryptoKey Constructor |
Top

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Wraps the stream with a cryptographic stream
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object
Public Method | Encrypt | Overloaded. Wraps the stream with a cryptographic stream
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines.
Protected Method | Finalize |
Top

See Also

Reference

CryptoKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/CryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CryptoKey Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class : CryptoKey Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected CryptoKey()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
CryptoKey Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : CryptoKey Class

Glossary Item Box

For a list of all members of this type, see CryptoKey members.

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Wraps the stream with a cryptographic stream
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object
Public Method | Encrypt | Overloaded. Wraps the stream with a cryptographic stream
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines.
Protected Method | Finalize |
Top

See Also

Reference

CryptoKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/CryptoKey.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Assert<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class : Assert<T> Method

t

Glossary Item Box

Throws ObjectDisposedException if the object has been disposed

Syntax

Visual Basic (Declaration)
Protected Function Assert(Of T)( _
   ByVal t As T _
) As T
C#
protected T Assert<T>(
   T t
)

Parameters

t

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CryptographicException Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class : CryptographicException Method

Glossary Item Box

Used to ensure generality in excpetions raised from cryptographic routines.

Syntax

Visual Basic (Declaration)
Protected Overridable Function CryptographicException() As Exception
C#
protected virtual Exception CryptographicException()

Example

catch { throw CryptographicException(); }

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members

Used By

String CryptoKey.Encrypt(String,ByteEncoding)
String CryptoKey.Decrypt(String,ByteEncoding)
Byte[] AsymmetricKey.Encrypt(Byte[])
Byte[] AsymmetricKey.Decrypt(Byte[])
Stream AsymmetricKey.Encrypt(Stream)
Stream AsymmetricKey.Decrypt(Stream)
Stream AESCryptoKey.Encrypt(Stream)
Stream AESCryptoKey.Decrypt(Stream)
Byte[] AESCryptoKey.Encrypt(Byte[])
Byte[] AESCryptoKey.Decrypt(Byte[])
Stream PasswordKey.Encrypt(Stream)
Stream PasswordKey.Decrypt(Stream)
Stream PasswordKey.Decrypt(Stream,Salt.Size)
Byte[] PasswordKey.Encrypt(Byte[])
Byte[] PasswordKey.Decrypt(Byte[])
Byte[] PasswordKey.Decrypt(Byte[],Salt.Size)


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class : Decrypt Method

Glossary Item Box

Wraps the stream with a cryptographic stream

Overload List

Overload | Description
Decrypt(Stream) | Wraps the stream with a cryptographic stream
Decrypt(Byte[]) | Decrypts the given bytes
Decrypt(String) | Decrypts the base-64 encoded bytes, decrypts the data and returns the string
Decrypt(String,ByteEncoding) | Decrypts the base-64 encoded bytes, decrypts the data and returns the string

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Decrypt Method : Decrypt(Stream) Method

stream

Glossary Item Box

Wraps the stream with a cryptographic stream

Syntax

Visual Basic (Declaration)
Public Overloads MustOverride Function Decrypt( _
   ByVal stream As Stream _
) As Stream
C#
public abstract Stream Decrypt(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List

Source Code

Library/Crypto/CryptoKey.cs

Used By

Byte[] AsymmetricKey.Decrypt(Byte[])
Byte[] AESCryptoKey.Decrypt(Byte[])
Stream PasswordKey.Decrypt(Stream,Salt.Size)


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Decrypt Method : Decrypt(Byte[]) Method

blob

Glossary Item Box

Decrypts the given bytes

Syntax

Visual Basic (Declaration)
Public Overloads MustOverride Function Decrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
public abstract byte[] Decrypt(
   byte[] blob
)

Parameters

blob

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] rawdata = new byte[8001];
new Random().NextBytes(rawdata);

byte[] cypher;
using (RSAPublicKey publicKey = new RSAPublicKey(TestCertPublicKey()))
    cypher = publicKey.Encrypt(rawdata);

using (RSAPrivateKey privateKey = new RSAPrivateKey(TestCertPrivateKey()))
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher));
VB.NET Copy Code
Dim rawdata As Byte() = New Byte(8001) {}
New Random().NextBytes(rawdata)

Dim cypher As Byte()
Using publicKey As New RSAPublicKey(TestCertPublicKey())
    cypher = publicKey.Encrypt(rawdata)
End Using

Using privateKey As New RSAPrivateKey(TestCertPrivateKey())
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List

Source Code

Library/Crypto/CryptoKey.cs

Used By

String CryptoKey.Decrypt(String,ByteEncoding)
Byte[] PasswordKey.Decrypt(Byte[],Salt.Size)


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Decrypt Method : Decrypt(String) Method

text

Glossary Item Box

Decrypts the base-64 encoded bytes, decrypts the data and returns the string

Syntax

Visual Basic (Declaration)
Public Overloads Function Decrypt( _
   ByVal text As String _
) As String
C#
public string Decrypt(
   string text
)

Parameters

text

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] ivrandom = new byte[16];
new Random().NextBytes(ivrandom);

using (AESCryptoKey k1 = new AESCryptoKey())
using (AESCryptoKey k2 = new AESCryptoKey(k1.Key, k1.IV))
using (AESCryptoKey kBadIv = new AESCryptoKey(k1.Key, ivrandom))
{
    Assert.AreEqual(k1.Key, k2.Key);
    Assert.AreEqual(k1.IV, k2.IV);
    Assert.AreEqual("test", k2.Decrypt(k1.Encrypt("test")));

    Assert.AreEqual(k1.Key, kBadIv.Key);
    Assert.AreNotEqual(k1.IV, kBadIv.IV);
    try
    {   //one of two possible outcomes, junk or exception
        Assert.AreNotEqual("test", kBadIv.Decrypt(k1.Encrypt("test")));
    }
    catch (System.Security.Cryptography.CryptographicException) { }
}
VB.NET Copy Code
Dim ivrandom As Byte() = New Byte(16) {}
New Random().NextBytes(ivrandom)

Using k1 As New AESCryptoKey()
    Using k2 As New AESCryptoKey(k1.Key, k1.IV)
        Using kBadIv As New AESCryptoKey(k1.Key, ivrandom)
            Assert.AreEqual(k1.Key, k2.Key)
            Assert.AreEqual(k1.IV, k2.IV)
            Assert.AreEqual("test", k2.Decrypt(k1.Encrypt("test")))

            Assert.AreEqual(k1.Key, kBadIv.Key)
            Assert.AreNotEqual(k1.IV, kBadIv.IV)
            Try
                'one of two possible outcomes, junk or exception
                Assert.AreNotEqual("test", kBadIv.Decrypt(k1.Encrypt("test")))
            Catch generatedExceptionName As System.Security.Cryptography.CryptographicException
            End Try
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List

Source Code

Library/Crypto/CryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(String,ByteEncoding) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Decrypt Method : Decrypt(String,ByteEncoding) Method

text
encoding

Glossary Item Box

Decrypts the base-64 encoded bytes, decrypts the data and returns the string

Syntax

Visual Basic (Declaration)
Public Overloads Function Decrypt( _
   ByVal text As String, _
   ByVal encoding As ByteEncoding _
) As String
C#
public string Decrypt(
   string text,
   ByteEncoding encoding
)

Parameters

text
encoding

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List
ByteEncoding

Used By

String CryptoKey.Decrypt(String)

Source Code

Library/Crypto/CryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class : Dispose Method

Glossary Item Box

Clears any secure memory associated with this object

Overload List

Overload | Description
Dispose() | Clears any secure memory associated with this object
Dispose(Boolean) | Clears any secure memory associated with this object

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Dispose Method : Dispose() Method

Glossary Item Box

Clears any secure memory associated with this object

Syntax

Visual Basic (Declaration)
Public Overloads Sub Dispose()
C#
public void Dispose()

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
string keyname = this.GetType().FullName + ".TestKeyCreateAndDelete";
using (RSAPrivateKey key = new RSAPrivateKey())
{
    Assert.IsFalse(key.DeleteFromStore());

    key.WriteToStore(keyname);

    CspParameters cp = new CspParameters();
    cp.KeyContainerName = keyname;
    cp.Flags = CspProviderFlags.UseExistingKey;

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(cp))
        Assert.AreEqual(key.ToXml(), key2.ToXml());

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(keyname))
    {
        Assert.AreEqual(key.ToXml(), key2.ToXml());
        Assert.IsTrue(key2.DeleteFromStore());
        key2.Dispose();
    }
}
VB.NET Copy Code
Dim keyname As String = Me.[GetType]().FullName + ".TestKeyCreateAndDelete"
Using key As New RSAPrivateKey()
    Assert.IsFalse(key.DeleteFromStore())

    key.WriteToStore(keyname)

    Dim cp As New CspParameters()
    cp.KeyContainerName = keyname
    cp.Flags = CspProviderFlags.UseExistingKey

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(cp)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
    End Using

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(keyname)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
        Assert.IsTrue(key2.DeleteFromStore())
        key2.Dispose()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List

Source Code

Library/Crypto/CryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Clears any secure memory associated with this object

Syntax

Visual Basic (Declaration)
Protected Overloads Overridable Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected virtual void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List

Used By

CryptoKey.Dispose()


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class : Encrypt Method

Glossary Item Box

Wraps the stream with a cryptographic stream

Overload List

Overload | Description
Encrypt(Stream) | Wraps the stream with a cryptographic stream
Encrypt(Byte[]) | Encrypts the given bytes
Encrypt(String) | Encrypts the encoded text and returns the base-64 encoded result
Encrypt(String,ByteEncoding) | Encrypts the encoded text and returns the base-64 encoded result

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Encrypt Method : Encrypt(Stream) Method

stream

Glossary Item Box

Wraps the stream with a cryptographic stream

Syntax

Visual Basic (Declaration)
Public Overloads MustOverride Function Encrypt( _
   ByVal stream As Stream _
) As Stream
C#
public abstract Stream Encrypt(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List

Source Code

Library/Crypto/CryptoKey.cs

Used By

Byte[] AsymmetricKey.Encrypt(Byte[])
Byte[] AESCryptoKey.Encrypt(Byte[])
Stream PasswordKey.Encrypt(Stream)


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Encrypt Method : Encrypt(Byte[]) Method

blob

Glossary Item Box

Encrypts the given bytes

Syntax

Visual Basic (Declaration)
Public Overloads MustOverride Function Encrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
public abstract byte[] Encrypt(
   byte[] blob
)

Parameters

blob

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] rawdata = new byte[8001];
new Random().NextBytes(rawdata);

byte[] cypher;
using (RSAPublicKey publicKey = new RSAPublicKey(TestCertPublicKey()))
    cypher = publicKey.Encrypt(rawdata);

using (RSAPrivateKey privateKey = new RSAPrivateKey(TestCertPrivateKey()))
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher));
VB.NET Copy Code
Dim rawdata As Byte() = New Byte(8001) {}
New Random().NextBytes(rawdata)

Dim cypher As Byte()
Using publicKey As New RSAPublicKey(TestCertPublicKey())
    cypher = publicKey.Encrypt(rawdata)
End Using

Using privateKey As New RSAPrivateKey(TestCertPrivateKey())
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List

Source Code

Library/Crypto/CryptoKey.cs

Used By

String CryptoKey.Encrypt(String,ByteEncoding)
Byte[] PasswordKey.Encrypt(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Encrypt Method : Encrypt(String) Method

text

Glossary Item Box

Encrypts the encoded text and returns the base-64 encoded result

Syntax

Visual Basic (Declaration)
Public Overloads Function Encrypt( _
   ByVal text As String _
) As String
C#
public string Encrypt(
   string text
)

Parameters

text

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
byte[] ivrandom = new byte[16];
new Random().NextBytes(ivrandom);

using (AESCryptoKey k1 = new AESCryptoKey())
using (AESCryptoKey k2 = new AESCryptoKey(k1.Key, k1.IV))
using (AESCryptoKey kBadIv = new AESCryptoKey(k1.Key, ivrandom))
{
    Assert.AreEqual(k1.Key, k2.Key);
    Assert.AreEqual(k1.IV, k2.IV);
    Assert.AreEqual("test", k2.Decrypt(k1.Encrypt("test")));

    Assert.AreEqual(k1.Key, kBadIv.Key);
    Assert.AreNotEqual(k1.IV, kBadIv.IV);
    try
    {   //one of two possible outcomes, junk or exception
        Assert.AreNotEqual("test", kBadIv.Decrypt(k1.Encrypt("test")));
    }
    catch (System.Security.Cryptography.CryptographicException) { }
}
VB.NET Copy Code
Dim ivrandom As Byte() = New Byte(16) {}
New Random().NextBytes(ivrandom)

Using k1 As New AESCryptoKey()
    Using k2 As New AESCryptoKey(k1.Key, k1.IV)
        Using kBadIv As New AESCryptoKey(k1.Key, ivrandom)
            Assert.AreEqual(k1.Key, k2.Key)
            Assert.AreEqual(k1.IV, k2.IV)
            Assert.AreEqual("test", k2.Decrypt(k1.Encrypt("test")))

            Assert.AreEqual(k1.Key, kBadIv.Key)
            Assert.AreNotEqual(k1.IV, kBadIv.IV)
            Try
                'one of two possible outcomes, junk or exception
                Assert.AreNotEqual("test", kBadIv.Decrypt(k1.Encrypt("test")))
            Catch generatedExceptionName As System.Security.Cryptography.CryptographicException
            End Try
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List

Source Code

Library/Crypto/CryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(String,ByteEncoding) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class > Encrypt Method : Encrypt(String,ByteEncoding) Method

text
encoding

Glossary Item Box

Encrypts the encoded text and returns the base-64 encoded result

Syntax

Visual Basic (Declaration)
Public Overloads Function Encrypt( _
   ByVal text As String, _
   ByVal encoding As ByteEncoding _
) As String
C#
public string Encrypt(
   string text,
   ByteEncoding encoding
)

Parameters

text
encoding

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Overload List
ByteEncoding

Used By

String CryptoKey.Encrypt(String)

Source Code

Library/Crypto/CryptoKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Finalize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > CryptoKey Class : Finalize Method

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Overrides Sub Finalize()
C#
protected override void Finalize()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CryptoKey Class
CryptoKey Members
Base Implementation in Finalize


%%PageItemTitle%%

[image]
CSharpTest.Net
Encryption Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Encryption Class

Glossary Item Box

Maintains backwards compatibility for access to the encryption api

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class Encryption
C#
public static class Encryption

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.Encryption

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Encryption Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/Encryption.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Encryption Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Encryption Class

Glossary Item Box

The following tables list the members exposed by Encryption.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | CurrentUser | Encrypts data for the current user
static (Shared in Visual Basic) | LocalMachine | Encrypts data for the this machine
static (Shared in Visual Basic) | Passthrough | Implements the encryption api but does not change any data
Top

See Also

Reference

Encryption Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/Encryption.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
Encryption Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Encryption Class

Glossary Item Box

For a list of all members of this type, see Encryption members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | CurrentUser | Encrypts data for the current user
static (Shared in Visual Basic) | LocalMachine | Encrypts data for the this machine
static (Shared in Visual Basic) | Passthrough | Implements the encryption api but does not change any data
Top

See Also

Reference

Encryption Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/Encryption.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CurrentUser Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Encryption Class : CurrentUser Field

Glossary Item Box

Encrypts data for the current user

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly CurrentUser As IEncryptDecrypt
C#
public static readonly IEncryptDecrypt CurrentUser

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Encryption Class
Encryption Members

Source Code

Library/Crypto/Encryption.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalMachine Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Encryption Class : LocalMachine Field

Glossary Item Box

Encrypts data for the this machine

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly LocalMachine As IEncryptDecrypt
C#
public static readonly IEncryptDecrypt LocalMachine

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Encryption Class
Encryption Members

Source Code

Library/Crypto/Encryption.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Passthrough Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Encryption Class : Passthrough Field

Glossary Item Box

Implements the encryption api but does not change any data

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Passthrough As IEncryptDecrypt
C#
public static readonly IEncryptDecrypt Passthrough

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Encryption Class
Encryption Members

Source Code

Library/Crypto/Encryption.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Hash Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Hash Class

Glossary Item Box

Represents a comparable, sortable, hash code

Syntax

Visual Basic (Declaration)
Public NotInheritable Class Hash
   Inherits CSharpTest.Net.Bases.Comparable(Of Hash)
C#
public sealed class Hash : CSharpTest.Net.Bases.Comparable<Hash>

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Equatable<T>
CSharpTest.Net.Bases.Comparable<T>
CSharpTest.Net.Crypto.Hash

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Members
CSharpTest.Net.Crypto Namespace
Hash DataValue.Hash
Hash SecureTransfer.CompleteTransferEventArgs.ContentHash
Hash HashStream.FinalizeHash()
Hash HashStream.Close()
Boolean RSAPublicKey.VerifyHash(Byte[],Hash)
Byte[] RSAPrivateKey.SignHash(Hash)

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Hash Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Hash Class

Glossary Item Box

The following tables list the members exposed by Hash.

Public Properties

 | Name | Description
Public Property | AlgorithmName | Returns the name of the hash algorithm
Public Property | AlgorithmOID | Returns the OID of the hash algorithm
Public Property | Length | Returns the length in bytes of the hash code
Top

Protected Properties

 | Name | Description
Protected Property | HashCode | Overridden. Returns a hash of the hash code :)
Top

Public Methods

 | Name | Description
Public Method | Combine | Overloaded. If the hash provided is the same size as this hash both hash codes are feed back into the hash algorithm associated with this length of hash to produce the result value. If the hash provided is a different length, it is first hashed with this algorithm before the two values are combined.
Public Method | CompareTo | Overridden. Compares the hash codes and returns the result
Public Method | CreateAlgorithm | Creates the hash algorithm associated with this length of hash
Public Method | Equals | Overloaded. Determines whether the specified System.Object is equal to the current System.Object. (Inherited from CSharpTest.Net.Bases.Equatable<Hash>)
static (Shared in Visual Basic) | FromBytes | Creates a comparable Hash object from the given hashcode bytes
static (Shared in Visual Basic) | FromString | Creates a comparable Hash object from the base-64 encoded hashcode bytes
static (Shared in Visual Basic) | MD5 | Overloaded. Computes an MD5 hash
static (Shared in Visual Basic) | SHA1 | Overloaded. Computes an SHA1 hash
static (Shared in Visual Basic) | SHA256 | Overloaded. Computes an SHA256 hash
static (Shared in Visual Basic) | SHA384 | Overloaded. Computes an SHA384 hash
static (Shared in Visual Basic) | SHA512 | Overloaded. Computes an SHA512 hash
Public Method | ToArray | Returns a copy of the hash code bytes
Public Method | ToString | Returns the hash code as a base-64 encoded string
Top

See Also

Reference

Hash Class
CSharpTest.Net.Crypto Namespace
Hash DataValue.Hash
Hash SecureTransfer.CompleteTransferEventArgs.ContentHash
Hash HashStream.FinalizeHash()
Hash HashStream.Close()
Boolean RSAPublicKey.VerifyHash(Byte[],Hash)
Byte[] RSAPrivateKey.SignHash(Hash)

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Hash Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Hash Class

Glossary Item Box

For a list of all members of this type, see Hash members.

Public Methods

 | Name | Description
Public Method | Combine | Overloaded. If the hash provided is the same size as this hash both hash codes are feed back into the hash algorithm associated with this length of hash to produce the result value. If the hash provided is a different length, it is first hashed with this algorithm before the two values are combined.
Public Method | CompareTo | Overridden. Compares the hash codes and returns the result
Public Method | CreateAlgorithm | Creates the hash algorithm associated with this length of hash
Public Method | Equals | Overloaded. Determines whether the specified System.Object is equal to the current System.Object. (Inherited from CSharpTest.Net.Bases.Equatable<Hash>)
static (Shared in Visual Basic) | FromBytes | Creates a comparable Hash object from the given hashcode bytes
static (Shared in Visual Basic) | FromString | Creates a comparable Hash object from the base-64 encoded hashcode bytes
static (Shared in Visual Basic) | MD5 | Overloaded. Computes an MD5 hash
static (Shared in Visual Basic) | SHA1 | Overloaded. Computes an SHA1 hash
static (Shared in Visual Basic) | SHA256 | Overloaded. Computes an SHA256 hash
static (Shared in Visual Basic) | SHA384 | Overloaded. Computes an SHA384 hash
static (Shared in Visual Basic) | SHA512 | Overloaded. Computes an SHA512 hash
Public Method | ToArray | Returns a copy of the hash code bytes
Public Method | ToString | Returns the hash code as a base-64 encoded string
Top

See Also

Reference

Hash Class
CSharpTest.Net.Crypto Namespace
Hash DataValue.Hash
Hash SecureTransfer.CompleteTransferEventArgs.ContentHash
Hash HashStream.FinalizeHash()
Hash HashStream.Close()
Boolean RSAPublicKey.VerifyHash(Byte[],Hash)
Byte[] RSAPrivateKey.SignHash(Hash)

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Combine Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : Combine Method

Glossary Item Box

If the hash provided is the same size as this hash both hash codes are feed back into the hash algorithm associated with this length of hash to produce the result value. If the hash provided is a different length, it is first hashed with this algorithm before the two values are combined.

Overload List

Overload | Description
Combine(Hash) | If the hash provided is the same size as this hash both hash codes are feed back into the hash algorithm associated with this length of hash to produce the result value. If the hash provided is a different length, it is first hashed with this algorithm before the two values are combined.
Combine(Byte[]) | Combines the bytes provided by first computing a like sized hash of those bytes and then combining the two equal hash values with the same hash algorithm.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Combine(Hash) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > Combine Method : Combine(Hash) Method

other

Glossary Item Box

If the hash provided is the same size as this hash both hash codes are feed back into the hash algorithm associated with this length of hash to produce the result value. If the hash provided is a different length, it is first hashed with this algorithm before the two values are combined.

Syntax

Visual Basic (Declaration)
Public Overloads Function Combine( _
   ByVal other As Hash _
) As Hash
C#
public Hash Combine(
   Hash other
)

Parameters

other

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[] a = new byte[10], b = new byte[10];
r.NextBytes(a);
r.NextBytes(b);

Hash h1 = Hash.SHA256(a);
Hash h2 = Hash.SHA1(b);
Hash h3 = h1.Combine(h2);

Assert.AreEqual(h3.ToString(), Hash.SHA256(
    new CombinedStream(
        new MemoryStream(h1.ToArray()),
        new MemoryStream(Hash.SHA256(h2.ToArray()).ToArray()) //the dissimilar hash is first made the same length
        )).ToString());
VB.NET Copy Code
Dim r As New Random()
Dim a As Byte() = New Byte(10) {}, b As Byte() = New Byte(10) {}
r.NextBytes(a)
r.NextBytes(b)

Dim h1 As Hash = Hash.SHA256(a)
Dim h2 As Hash = Hash.SHA1(b)
Dim h3 As Hash = h1.Combine(h2)

'the dissimilar hash is first made the same length
Assert.AreEqual(h3.ToString(), Hash.SHA256(New CombinedStream(New MemoryStream(h1.ToArray()), New MemoryStream(Hash.SHA256(h2.ToArray()).ToArray()))).ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs

Used By

Hash Hash.Combine(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
Combine(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > Combine Method : Combine(Byte[]) Method

bytes

Glossary Item Box

Combines the bytes provided by first computing a like sized hash of those bytes and then combining the two equal hash values with the same hash algorithm.

Syntax

Visual Basic (Declaration)
Public Overloads Function Combine( _
   ByVal bytes() As Byte _
) As Hash
C#
public Hash Combine(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[] a = new byte[10], b = new byte[32];
r.NextBytes(a);
r.NextBytes(b);

Hash h1 = Hash.SHA256(a);
Hash h3 = h1.Combine(b);

Assert.AreEqual(h3.ToString(), Hash.SHA256(
    new CombinedStream(
        new MemoryStream(h1.ToArray()),
        new MemoryStream(Hash.SHA256(b).ToArray())//bytes combined are hashed first
        )).ToString());
VB.NET Copy Code
Dim r As New Random()
Dim a As Byte() = New Byte(10) {}, b As Byte() = New Byte(32) {}
r.NextBytes(a)
r.NextBytes(b)

Dim h1 As Hash = Hash.SHA256(a)
Dim h3 As Hash = h1.Combine(b)

'bytes combined are hashed first
Assert.AreEqual(h3.ToString(), Hash.SHA256(New CombinedStream(New MemoryStream(h1.ToArray()), New MemoryStream(Hash.SHA256(b).ToArray()))).ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Used By

Hash Hash.Combine(Hash)

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CompareTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : CompareTo Method

other

Glossary Item Box

Compares the hash codes and returns the result

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable Function CompareTo( _
   ByVal other As Hash _
) As Integer
C#
public override int CompareTo(
   Hash other
)

Parameters

other

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Base Implementation in CompareTo

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateAlgorithm Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : CreateAlgorithm Method

Glossary Item Box

Creates the hash algorithm associated with this length of hash

Syntax

Visual Basic (Declaration)
Public Function CreateAlgorithm() As HashAlgorithm
C#
public HashAlgorithm CreateAlgorithm()

Example

Library/Library.Test/TestHash.cs

C# Copy Code
foreach(int sz in new int [] { 16, 20, 32, 48, 64 })
{
    Hash test = Hash.FromBytes(new byte[sz]);
    HashAlgorithm ha = test.CreateAlgorithm();
    Assert.IsNotNull(ha);
    Assert.AreEqual(sz, ha.ComputeHash(new byte[0]).Length);
}
VB.NET Copy Code
For Each sz As Integer In New Integer() {16, 20, 32, 48, 64}
    Dim test As Hash = Hash.FromBytes(New Byte(sz) {})
    Dim ha As HashAlgorithm = test.CreateAlgorithm()
    Assert.IsNotNull(ha)
    Assert.AreEqual(sz, ha.ComputeHash(New Byte(0) {}).Length)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members

Source Code

Library/Crypto/Hash.cs

Used By

Hash Hash.Combine(Hash)
Hash Hash.Combine(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
FromBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : FromBytes Method

bytes

Glossary Item Box

Creates a comparable Hash object from the given hashcode bytes

Syntax

Visual Basic (Declaration)
Public Shared Function FromBytes( _
   ByVal bytes() As Byte _
) As Hash
C#
public static Hash FromBytes(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] data = new byte[100];
new Random().NextBytes(data);

foreach (HashAlgorithm ha in new HashAlgorithm[] { MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create() })
{
    Hash hash = Hash.FromBytes(ha.ComputeHash(data));
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.GetType().FullName), hash.AlgorithmOID);

    using (RSAPrivateKey key = new RSAPrivateKey())
    {
        byte[] sig = key.SignHash(hash);

        using (RSAPublicKey pub = key.PublicKey)
        {
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
            data[0] = (byte)~data[0];
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
        }
    }
}
VB.NET Copy Code
Dim data As Byte() = New Byte(100) {}
New Random().NextBytes(data)

For Each ha As HashAlgorithm In New HashAlgorithm() {MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create()}
    Dim hash As Hash = Hash.FromBytes(ha.ComputeHash(data))
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.[GetType]().FullName), hash.AlgorithmOID)

    Using key As New RSAPrivateKey()
        Dim sig As Byte() = key.SignHash(hash)

        Using pub As RSAPublicKey = key.PublicKey
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
            data(0) = DirectCast(Not data(0), Byte)
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
        End Using
    End Using
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members

Used By

Hash HashStream.FinalizeHash()
Hash Hash.Combine(Hash)
Hash Hash.Combine(Byte[])

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromString Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : FromString Method

encodedBytes

Glossary Item Box

Creates a comparable Hash object from the base-64 encoded hashcode bytes

Syntax

Visual Basic (Declaration)
Public Shared Function FromString( _
   ByVal encodedBytes As String _
) As Hash
C#
public static Hash FromString(
   string encodedBytes
)

Parameters

encodedBytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Hash hash = Hash.MD5(TestData);
Hash copy = Hash.FromBytes(hash.ToArray());
Assert.AreEqual(hash, copy);
Assert.AreEqual(hash.ToString(), copy.ToString());

copy = Hash.FromString(hash.ToString());
Assert.AreEqual(hash, copy);
Assert.AreEqual(hash.ToString(), copy.ToString());
VB.NET Copy Code
Dim hash As Hash = Hash.MD5(TestData)
Dim copy As Hash = Hash.FromBytes(hash.ToArray())
Assert.AreEqual(hash, copy)
Assert.AreEqual(hash.ToString(), copy.ToString())

copy = Hash.FromString(hash.ToString())
Assert.AreEqual(hash, copy)
Assert.AreEqual(hash.ToString(), copy.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MD5 Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : MD5 Method

Glossary Item Box

Computes an MD5 hash

Overload List

Overload | Description
MD5(Byte[]) | Computes an MD5 hash
MD5(Stream) | Computes an MD5 hash

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members


%%PageItemTitle%%

[image]
CSharpTest.Net
MD5(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > MD5 Method : MD5(Byte[]) Method

bytes

Glossary Item Box

Computes an MD5 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function MD5( _
   ByVal bytes() As Byte _
) As Hash
C#
public static Hash MD5(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Hash hash = Hash.MD5(TestData);
Assert.AreEqual(MD5.Create().ComputeHash(TestData), hash.ToArray());
Hash hash2 = Hash.MD5(TestDataStream());

Assert.AreEqual(hash, hash2);
Assert.IsTrue(hash == hash2);
Assert.IsTrue(hash.Equals(hash2));
Assert.IsTrue(hash.Equals((object)hash2));
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode());
Assert.AreEqual(hash.Length, hash2.Length);
Assert.AreEqual(hash.ToString(), hash2.ToString());
Assert.AreEqual(hash.ToArray(), hash2.ToArray());
Assert.IsFalse(hash != hash2);
VB.NET Copy Code
Dim hash As Hash = Hash.MD5(TestData)
Assert.AreEqual(MD5.Create().ComputeHash(TestData), hash.ToArray())
Dim hash2 As Hash = Hash.MD5(TestDataStream())

Assert.AreEqual(hash, hash2)
Assert.IsTrue(hash = hash2)
Assert.IsTrue(hash.Equals(hash2))
Assert.IsTrue(hash.Equals(DirectCast(hash2, Object)))
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode())
Assert.AreEqual(hash.Length, hash2.Length)
Assert.AreEqual(hash.ToString(), hash2.ToString())
Assert.AreEqual(hash.ToArray(), hash2.ToArray())
Assert.IsFalse(hash <> hash2)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MD5(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > MD5 Method : MD5(Stream) Method

bytes

Glossary Item Box

Computes an MD5 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function MD5( _
   ByVal bytes As Stream _
) As Hash
C#
public static Hash MD5(
   Stream bytes
)

Parameters

bytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Hash hash = Hash.MD5(TestData);
Assert.AreEqual(MD5.Create().ComputeHash(TestData), hash.ToArray());
Hash hash2 = Hash.MD5(TestDataStream());

Assert.AreEqual(hash, hash2);
Assert.IsTrue(hash == hash2);
Assert.IsTrue(hash.Equals(hash2));
Assert.IsTrue(hash.Equals((object)hash2));
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode());
Assert.AreEqual(hash.Length, hash2.Length);
Assert.AreEqual(hash.ToString(), hash2.ToString());
Assert.AreEqual(hash.ToArray(), hash2.ToArray());
Assert.IsFalse(hash != hash2);
VB.NET Copy Code
Dim hash As Hash = Hash.MD5(TestData)
Assert.AreEqual(MD5.Create().ComputeHash(TestData), hash.ToArray())
Dim hash2 As Hash = Hash.MD5(TestDataStream())

Assert.AreEqual(hash, hash2)
Assert.IsTrue(hash = hash2)
Assert.IsTrue(hash.Equals(hash2))
Assert.IsTrue(hash.Equals(DirectCast(hash2, Object)))
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode())
Assert.AreEqual(hash.Length, hash2.Length)
Assert.AreEqual(hash.ToString(), hash2.ToString())
Assert.AreEqual(hash.ToArray(), hash2.ToArray())
Assert.IsFalse(hash <> hash2)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs

Used By

Int32 Password.GetHashCode()


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA1 Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : SHA1 Method

Glossary Item Box

Computes an SHA1 hash

Overload List

Overload | Description
SHA1(Byte[]) | Computes an SHA1 hash
SHA1(Stream) | Computes an SHA1 hash

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA1(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > SHA1 Method : SHA1(Byte[]) Method

bytes

Glossary Item Box

Computes an SHA1 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function SHA1( _
   ByVal bytes() As Byte _
) As Hash
C#
public static Hash SHA1(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[] a = new byte[10], b = new byte[10];
r.NextBytes(a);
r.NextBytes(b);

Hash h1 = Hash.SHA256(a);
Hash h2 = Hash.SHA1(b);
Hash h3 = h1.Combine(h2);

Assert.AreEqual(h3.ToString(), Hash.SHA256(
    new CombinedStream(
        new MemoryStream(h1.ToArray()),
        new MemoryStream(Hash.SHA256(h2.ToArray()).ToArray()) //the dissimilar hash is first made the same length
        )).ToString());
VB.NET Copy Code
Dim r As New Random()
Dim a As Byte() = New Byte(10) {}, b As Byte() = New Byte(10) {}
r.NextBytes(a)
r.NextBytes(b)

Dim h1 As Hash = Hash.SHA256(a)
Dim h2 As Hash = Hash.SHA1(b)
Dim h3 As Hash = h1.Combine(h2)

'the dissimilar hash is first made the same length
Assert.AreEqual(h3.ToString(), Hash.SHA256(New CombinedStream(New MemoryStream(h1.ToArray()), New MemoryStream(Hash.SHA256(h2.ToArray()).ToArray()))).ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA1(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > SHA1 Method : SHA1(Stream) Method

bytes

Glossary Item Box

Computes an SHA1 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function SHA1( _
   ByVal bytes As Stream _
) As Hash
C#
public static Hash SHA1(
   Stream bytes
)

Parameters

bytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Hash hash = Hash.SHA1(TestData);
Assert.AreEqual(SHA1.Create().ComputeHash(TestData), hash.ToArray());
Hash hash2 = Hash.SHA1(TestDataStream());

Assert.AreEqual(hash, hash2);
Assert.IsTrue(hash == hash2);
Assert.IsTrue(hash.Equals(hash2));
Assert.IsTrue(hash.Equals((object)hash2));
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode());
Assert.AreEqual(hash.Length, hash2.Length);
Assert.AreEqual(hash.ToString(), hash2.ToString());
Assert.AreEqual(hash.ToArray(), hash2.ToArray());
Assert.IsFalse(hash != hash2);
VB.NET Copy Code
Dim hash As Hash = Hash.SHA1(TestData)
Assert.AreEqual(SHA1.Create().ComputeHash(TestData), hash.ToArray())
Dim hash2 As Hash = Hash.SHA1(TestDataStream())

Assert.AreEqual(hash, hash2)
Assert.IsTrue(hash = hash2)
Assert.IsTrue(hash.Equals(hash2))
Assert.IsTrue(hash.Equals(DirectCast(hash2, Object)))
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode())
Assert.AreEqual(hash.Length, hash2.Length)
Assert.AreEqual(hash.ToString(), hash2.ToString())
Assert.AreEqual(hash.ToArray(), hash2.ToArray())
Assert.IsFalse(hash <> hash2)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA256 Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : SHA256 Method

Glossary Item Box

Computes an SHA256 hash

Overload List

Overload | Description
SHA256(Byte[]) | Computes an SHA256 hash
SHA256(Stream) | Computes an SHA256 hash

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA256(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > SHA256 Method : SHA256(Byte[]) Method

bytes

Glossary Item Box

Computes an SHA256 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function SHA256( _
   ByVal bytes() As Byte _
) As Hash
C#
public static Hash SHA256(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
byte[] testValid = Encoding.ASCII.GetBytes("12345678");
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize);
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray());
testValid = null;

//now test with an odd number of bytes, should always hash to Sha256
byte[] notValid = Encoding.ASCII.GetBytes("0123456789");
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize);
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray());

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize);
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray());
VB.NET Copy Code
Dim testValid As Byte() = Encoding.ASCII.GetBytes("12345678")
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize)
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray())
testValid = Nothing

'now test with an odd number of bytes, should always hash to Sha256
Dim notValid As Byte() = Encoding.ASCII.GetBytes("0123456789")
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize)
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray())

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize)
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA256(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > SHA256 Method : SHA256(Stream) Method

bytes

Glossary Item Box

Computes an SHA256 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function SHA256( _
   ByVal bytes As Stream _
) As Hash
C#
public static Hash SHA256(
   Stream bytes
)

Parameters

bytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[] a = new byte[10], b = new byte[32];
r.NextBytes(a);
r.NextBytes(b);

Hash h1 = Hash.SHA256(a);
Hash h3 = h1.Combine(b);

Assert.AreEqual(h3.ToString(), Hash.SHA256(
    new CombinedStream(
        new MemoryStream(h1.ToArray()),
        new MemoryStream(Hash.SHA256(b).ToArray())//bytes combined are hashed first
        )).ToString());
VB.NET Copy Code
Dim r As New Random()
Dim a As Byte() = New Byte(10) {}, b As Byte() = New Byte(32) {}
r.NextBytes(a)
r.NextBytes(b)

Dim h1 As Hash = Hash.SHA256(a)
Dim h3 As Hash = h1.Combine(b)

'bytes combined are hashed first
Assert.AreEqual(h3.ToString(), Hash.SHA256(New CombinedStream(New MemoryStream(h1.ToArray()), New MemoryStream(Hash.SHA256(b).ToArray()))).ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA384 Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : SHA384 Method

Glossary Item Box

Computes an SHA384 hash

Overload List

Overload | Description
SHA384(Byte[]) | Computes an SHA384 hash
SHA384(Stream) | Computes an SHA384 hash

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA384(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > SHA384 Method : SHA384(Byte[]) Method

bytes

Glossary Item Box

Computes an SHA384 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function SHA384( _
   ByVal bytes() As Byte _
) As Hash
C#
public static Hash SHA384(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Hash hash = Hash.SHA384(TestData);
Assert.AreEqual(SHA384.Create().ComputeHash(TestData), hash.ToArray());
Hash hash2 = Hash.SHA384(TestDataStream());

Assert.AreEqual(hash, hash2);
Assert.IsTrue(hash == hash2);
Assert.IsTrue(hash.Equals(hash2));
Assert.IsTrue(hash.Equals((object)hash2));
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode());
Assert.AreEqual(hash.Length, hash2.Length);
Assert.AreEqual(hash.ToString(), hash2.ToString());
Assert.AreEqual(hash.ToArray(), hash2.ToArray());
Assert.IsFalse(hash != hash2);
VB.NET Copy Code
Dim hash As Hash = Hash.SHA384(TestData)
Assert.AreEqual(SHA384.Create().ComputeHash(TestData), hash.ToArray())
Dim hash2 As Hash = Hash.SHA384(TestDataStream())

Assert.AreEqual(hash, hash2)
Assert.IsTrue(hash = hash2)
Assert.IsTrue(hash.Equals(hash2))
Assert.IsTrue(hash.Equals(DirectCast(hash2, Object)))
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode())
Assert.AreEqual(hash.Length, hash2.Length)
Assert.AreEqual(hash.ToString(), hash2.ToString())
Assert.AreEqual(hash.ToArray(), hash2.ToArray())
Assert.IsFalse(hash <> hash2)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA384(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > SHA384 Method : SHA384(Stream) Method

bytes

Glossary Item Box

Computes an SHA384 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function SHA384( _
   ByVal bytes As Stream _
) As Hash
C#
public static Hash SHA384(
   Stream bytes
)

Parameters

bytes

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Hash hash = Hash.SHA384(TestData);
Assert.AreEqual(SHA384.Create().ComputeHash(TestData), hash.ToArray());
Hash hash2 = Hash.SHA384(TestDataStream());

Assert.AreEqual(hash, hash2);
Assert.IsTrue(hash == hash2);
Assert.IsTrue(hash.Equals(hash2));
Assert.IsTrue(hash.Equals((object)hash2));
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode());
Assert.AreEqual(hash.Length, hash2.Length);
Assert.AreEqual(hash.ToString(), hash2.ToString());
Assert.AreEqual(hash.ToArray(), hash2.ToArray());
Assert.IsFalse(hash != hash2);
VB.NET Copy Code
Dim hash As Hash = Hash.SHA384(TestData)
Assert.AreEqual(SHA384.Create().ComputeHash(TestData), hash.ToArray())
Dim hash2 As Hash = Hash.SHA384(TestDataStream())

Assert.AreEqual(hash, hash2)
Assert.IsTrue(hash = hash2)
Assert.IsTrue(hash.Equals(hash2))
Assert.IsTrue(hash.Equals(DirectCast(hash2, Object)))
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode())
Assert.AreEqual(hash.Length, hash2.Length)
Assert.AreEqual(hash.ToString(), hash2.ToString())
Assert.AreEqual(hash.ToArray(), hash2.ToArray())
Assert.IsFalse(hash <> hash2)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA512 Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : SHA512 Method

Glossary Item Box

Computes an SHA512 hash

Overload List

Overload | Description
SHA512(Byte[]) | Computes an SHA512 hash
SHA512(Stream) | Computes an SHA512 hash

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA512(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > SHA512 Method : SHA512(Byte[]) Method

bytes

Glossary Item Box

Computes an SHA512 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function SHA512( _
   ByVal bytes() As Byte _
) As Hash
C#
public static Hash SHA512(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestIOStreamUtils.cs

C# Copy Code
byte[] testData = new byte[ushort.MaxValue];
new Random().NextBytes(testData);
Array.Clear(testData, 0, testData.Length / 2);
Hash compressedHash;
Hash hash = Hash.SHA512(testData);

using (TempFile f = new TempFile())
{
    f.WriteAllBytes(testData);
    Assert.AreEqual((long)testData.Length, f.Length);

    IOStream.Compress(f.TempPath);
    Assert.IsTrue(f.Length < testData.Length);
    compressedHash = Hash.SHA512(f.Read());
    Assert.IsFalse(compressedHash == hash);

    IOStream.Decompress(f.TempPath);
    Assert.AreEqual((long)testData.Length, f.Length);
    Assert.IsTrue(hash == Hash.SHA512(f.Read()));
}

MemoryStream ms = new MemoryStream(testData), gz = new MemoryStream();
IOStream.Compress(ms, gz);

Assert.IsTrue(compressedHash == Hash.SHA512(gz.ToArray()));
ms = new MemoryStream();
gz.Position = 0;
IOStream.Decompress(gz, ms);

Assert.IsTrue(hash == Hash.SHA512(ms.ToArray()));
VB.NET Copy Code
Dim testData As Byte() = New Byte(UShort.MaxValue) {}
New Random().NextBytes(testData)
Array.Clear(testData, 0, testData.Length / 2)
Dim compressedHash As Hash
Dim hash As Hash = Hash.SHA512(testData)

Using f As New TempFile()
    f.WriteAllBytes(testData)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)

    IOStream.Compress(f.TempPath)
    Assert.IsTrue(f.Length < testData.Length)
    compressedHash = Hash.SHA512(f.Read())
    Assert.IsFalse(compressedHash = hash)

    IOStream.Decompress(f.TempPath)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)
    Assert.IsTrue(hash = Hash.SHA512(f.Read()))
End Using

Dim ms As New MemoryStream(testData), gz As New MemoryStream()
IOStream.Compress(ms, gz)

Assert.IsTrue(compressedHash = Hash.SHA512(gz.ToArray()))
ms = New MemoryStream()
gz.Position = 0
IOStream.Decompress(gz, ms)

Assert.IsTrue(hash = Hash.SHA512(ms.ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SHA512(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class > SHA512 Method : SHA512(Stream) Method

bytes

Glossary Item Box

Computes an SHA512 hash

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function SHA512( _
   ByVal bytes As Stream _
) As Hash
C#
public static Hash SHA512(
   Stream bytes
)

Parameters

bytes

Example

Library/Library.Test/TestIOStreamUtils.cs

C# Copy Code
byte[] testData = new byte[ushort.MaxValue];
new Random().NextBytes(testData);
Array.Clear(testData, 0, testData.Length / 2);
Hash compressedHash;
Hash hash = Hash.SHA512(testData);

using (TempFile f = new TempFile())
{
    f.WriteAllBytes(testData);
    Assert.AreEqual((long)testData.Length, f.Length);

    IOStream.Compress(f.TempPath);
    Assert.IsTrue(f.Length < testData.Length);
    compressedHash = Hash.SHA512(f.Read());
    Assert.IsFalse(compressedHash == hash);

    IOStream.Decompress(f.TempPath);
    Assert.AreEqual((long)testData.Length, f.Length);
    Assert.IsTrue(hash == Hash.SHA512(f.Read()));
}

MemoryStream ms = new MemoryStream(testData), gz = new MemoryStream();
IOStream.Compress(ms, gz);

Assert.IsTrue(compressedHash == Hash.SHA512(gz.ToArray()));
ms = new MemoryStream();
gz.Position = 0;
IOStream.Decompress(gz, ms);

Assert.IsTrue(hash == Hash.SHA512(ms.ToArray()));
VB.NET Copy Code
Dim testData As Byte() = New Byte(UShort.MaxValue) {}
New Random().NextBytes(testData)
Array.Clear(testData, 0, testData.Length / 2)
Dim compressedHash As Hash
Dim hash As Hash = Hash.SHA512(testData)

Using f As New TempFile()
    f.WriteAllBytes(testData)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)

    IOStream.Compress(f.TempPath)
    Assert.IsTrue(f.Length < testData.Length)
    compressedHash = Hash.SHA512(f.Read())
    Assert.IsFalse(compressedHash = hash)

    IOStream.Decompress(f.TempPath)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)
    Assert.IsTrue(hash = Hash.SHA512(f.Read()))
End Using

Dim ms As New MemoryStream(testData), gz As New MemoryStream()
IOStream.Compress(ms, gz)

Assert.IsTrue(compressedHash = Hash.SHA512(gz.ToArray()))
ms = New MemoryStream()
gz.Position = 0
IOStream.Decompress(gz, ms)

Assert.IsTrue(hash = Hash.SHA512(ms.ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Overload List

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : ToArray Method

Glossary Item Box

Returns a copy of the hash code bytes

Syntax

Visual Basic (Declaration)
Public Function ToArray() As Byte()
C#
public byte[] ToArray()

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
byte[] testValid = Encoding.ASCII.GetBytes("12345678");
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize);
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray());
testValid = null;

//now test with an odd number of bytes, should always hash to Sha256
byte[] notValid = Encoding.ASCII.GetBytes("0123456789");
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize);
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray());

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize);
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray());
VB.NET Copy Code
Dim testValid As Byte() = Encoding.ASCII.GetBytes("12345678")
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize)
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray())
testValid = Nothing

'now test with an odd number of bytes, should always hash to Sha256
Dim notValid As Byte() = Encoding.ASCII.GetBytes("0123456789")
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize)
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray())

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize)
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members

Used By

Boolean RSAPublicKey.VerifyHash(Byte[],Hash)
Byte[] RSAPrivateKey.SignHash(Hash)

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : ToString Method

Glossary Item Box

Returns the hash code as a base-64 encoded string

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Base Implementation in ToString

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Hash Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Hash Class

Glossary Item Box

For a list of all members of this type, see Hash members.

Public Properties

 | Name | Description
Public Property | AlgorithmName | Returns the name of the hash algorithm
Public Property | AlgorithmOID | Returns the OID of the hash algorithm
Public Property | Length | Returns the length in bytes of the hash code
Top

Protected Properties

 | Name | Description
Protected Property | HashCode | Overridden. Returns a hash of the hash code :)
Top

See Also

Reference

Hash Class
CSharpTest.Net.Crypto Namespace
Hash DataValue.Hash
Hash SecureTransfer.CompleteTransferEventArgs.ContentHash
Hash HashStream.FinalizeHash()
Hash HashStream.Close()
Boolean RSAPublicKey.VerifyHash(Byte[],Hash)
Byte[] RSAPrivateKey.SignHash(Hash)

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AlgorithmName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : AlgorithmName Property

Glossary Item Box

Returns the name of the hash algorithm

Syntax

Visual Basic (Declaration)
Public ReadOnly Property AlgorithmName As String
C#
public string AlgorithmName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members

Used By

HashAlgorithm Hash.CreateAlgorithm()

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AlgorithmOID Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : AlgorithmOID Property

Glossary Item Box

Returns the OID of the hash algorithm

Syntax

Visual Basic (Declaration)
Public ReadOnly Property AlgorithmOID As String
C#
public string AlgorithmOID {get;}

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] data = new byte[100];
new Random().NextBytes(data);

foreach (HashAlgorithm ha in new HashAlgorithm[] { MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create() })
{
    Hash hash = Hash.FromBytes(ha.ComputeHash(data));
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.GetType().FullName), hash.AlgorithmOID);

    using (RSAPrivateKey key = new RSAPrivateKey())
    {
        byte[] sig = key.SignHash(hash);

        using (RSAPublicKey pub = key.PublicKey)
        {
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
            data[0] = (byte)~data[0];
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
        }
    }
}
VB.NET Copy Code
Dim data As Byte() = New Byte(100) {}
New Random().NextBytes(data)

For Each ha As HashAlgorithm In New HashAlgorithm() {MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create()}
    Dim hash As Hash = Hash.FromBytes(ha.ComputeHash(data))
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.[GetType]().FullName), hash.AlgorithmOID)

    Using key As New RSAPrivateKey()
        Dim sig As Byte() = key.SignHash(hash)

        Using pub As RSAPublicKey = key.PublicKey
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
            data(0) = DirectCast(Not data(0), Byte)
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
        End Using
    End Using
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members

Used By

Boolean RSAPublicKey.VerifyHash(Byte[],Hash)
Byte[] RSAPrivateKey.SignHash(Hash)

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashCode Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : HashCode Property

Glossary Item Box

Returns a hash of the hash code :)

Syntax

Visual Basic (Declaration)
Protected Overrides NotOverridable ReadOnly Property HashCode As Integer
C#
protected override int HashCode {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members
Base Implementation in HashCode


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Hash Class : Length Property

Glossary Item Box

Returns the length in bytes of the hash code

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Length As Integer
C#
public int Length {get;}

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Hash hash = Hash.SHA512(TestData);
Assert.AreEqual(SHA512.Create().ComputeHash(TestData), hash.ToArray());
Hash hash2 = Hash.SHA512(TestDataStream());

Assert.AreEqual(hash, hash2);
Assert.IsTrue(hash == hash2);
Assert.IsTrue(hash.Equals(hash2));
Assert.IsTrue(hash.Equals((object)hash2));
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode());
Assert.AreEqual(hash.Length, hash2.Length);
Assert.AreEqual(hash.ToString(), hash2.ToString());
Assert.AreEqual(hash.ToArray(), hash2.ToArray());
Assert.IsFalse(hash != hash2);
VB.NET Copy Code
Dim hash As Hash = Hash.SHA512(TestData)
Assert.AreEqual(SHA512.Create().ComputeHash(TestData), hash.ToArray())
Dim hash2 As Hash = Hash.SHA512(TestDataStream())

Assert.AreEqual(hash, hash2)
Assert.IsTrue(hash = hash2)
Assert.IsTrue(hash.Equals(hash2))
Assert.IsTrue(hash.Equals(DirectCast(hash2, Object)))
Assert.AreEqual(hash.GetHashCode(), hash2.GetHashCode())
Assert.AreEqual(hash.Length, hash2.Length)
Assert.AreEqual(hash.ToString(), hash2.ToString())
Assert.AreEqual(hash.ToArray(), hash2.ToArray())
Assert.IsFalse(hash <> hash2)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Hash Class
Hash Members

Used By

Hash Hash.Combine(Hash)

Source Code

Library/Crypto/Hash.cs


%%PageItemTitle%%

THash
[image]
CSharpTest.Net
HashDerivedBytes<THash> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : HashDerivedBytes<THash> Class

Glossary Item Box

Provided an implementation very similiar to that of the Rfc2898DeriveBytes with the following excpetions: 1) any hash size can be used, 2) original key bytes are always hashed, 3) bytes generated are always rounded to hash size, thus GetBytes(4) + GetBytes(4) != GetBytes(8)

Syntax

Visual Basic (Declaration)
Public Class HashDerivedBytes(Of THash As {New, HMAC})
   Inherits System.Security.Cryptography.DeriveBytes
   Implements IPasswordDerivedBytes
C#
public class HashDerivedBytes<THash> : System.Security.Cryptography.DeriveBytes, IPasswordDerivedBytes
where THash: new(), HMAC

Type Parameters

THash

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
int iter = 100;
Salt salt = new Salt();
byte[] passbytes = Password.Encoding.GetBytes(TEST_PASSWORD);
IPasswordDerivedBytes[] types = new IPasswordDerivedBytes[] {
    new PBKDF2(passbytes, salt, iter),
    new HashDerivedBytes<HMACMD5>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA1>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA256>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA384>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA512>(passbytes, salt, iter),
};

foreach (IPasswordDerivedBytes db in types)
{
    byte[] key;

    Stopwatch w = new Stopwatch();
    w.Start();
    for (int i = 0; i < 100; i++)
        key = new PasswordKey(db, salt).CreateKey().Key;
    w.Stop();

    Console.Error.WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.GetType().Name);
}
VB.NET Copy Code
Dim iter As Integer = 100
Dim salt As New Salt()
Dim passbytes As Byte() = Password.Encoding.GetBytes(TEST_PASSWORD)
Dim types As IPasswordDerivedBytes() = New IPasswordDerivedBytes() {New PBKDF2(passbytes, salt, iter), New HashDerivedBytes(Of HMACMD5)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA1)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA256)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA384)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA512)(passbytes, salt, iter)}

For Each db As IPasswordDerivedBytes In types
    Dim key As Byte()

    Dim w As New Stopwatch()
    w.Start()
    Dim i As Integer = 0
    While i < 100
        key = New PasswordKey(db, salt).CreateKey().Key
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    w.[Stop]()

    Console.[Error].WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.[GetType]().Name)
Next

Inheritance Hierarchy

System.Object
System.Security.Cryptography.DeriveBytes
CSharpTest.Net.Crypto.HashDerivedBytes<THash>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HashDerivedBytes<THash> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : HashDerivedBytes<THash> Class

Glossary Item Box

The following tables list the members exposed by HashDerivedBytes<THash>.

Public Constructors

 | Name | Description
Public Constructor | HashDerivedBytes<THash> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | IterationCount | Gets or sets the number of iterations for the operation.
Public Property | Salt | Gets or sets the key salt value for the operation.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of the object
Public Method | GetBytes | Overridden. Returns a pseudo-random key from a password, salt and iteration count.
Public Method | Reset | Overridden. Resets the state of the operation.
Top

See Also

Reference

HashDerivedBytes<THash> Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashDerivedBytes<THash> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class : HashDerivedBytes<THash> Constructor

Glossary Item Box

Overload List

Overload | Description
HashDerivedBytes<THash> Constructor(THash,Stream,Salt,Int32) | Constructs the byte generation routine with the specified key, salt, and iteration count
HashDerivedBytes<THash> Constructor(Stream,Salt,Int32) | Constructs the byte generation routine with the specified key, salt, and iteration count
HashDerivedBytes<THash> Constructor(Boolean,Byte[],Salt,Int32) | Constructs the byte generation routine with the specified key, salt, and iteration count
HashDerivedBytes<THash> Constructor(Byte[],Salt,Int32) | Constructs the byte generation routine with the specified key, salt, and iteration count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
HashDerivedBytes<THash> Constructor(THash,Stream,Salt,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class > HashDerivedBytes<THash> Constructor : HashDerivedBytes<THash> Constructor(THash,Stream,Salt,Int32)

algo
password
salt
iterations

Glossary Item Box

Constructs the byte generation routine with the specified key, salt, and iteration count

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal algo As THash, _
   ByVal password As Stream, _
   ByVal salt As Salt, _
   ByVal iterations As Integer _
)
C#
public HashDerivedBytes<THash>(
   THash algo,
   Stream password,
   Salt salt,
   int iterations
)

Parameters

algo
password
salt
iterations

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members
Overload List

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashDerivedBytes<THash> Constructor(Stream,Salt,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class > HashDerivedBytes<THash> Constructor : HashDerivedBytes<THash> Constructor(Stream,Salt,Int32)

password
salt
iterations

Glossary Item Box

Constructs the byte generation routine with the specified key, salt, and iteration count

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal password As Stream, _
   ByVal salt As Salt, _
   ByVal iterations As Integer _
)
C#
public HashDerivedBytes<THash>(
   Stream password,
   Salt salt,
   int iterations
)

Parameters

password
salt
iterations

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members
Overload List

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashDerivedBytes<THash> Constructor(Boolean,Byte[],Salt,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class > HashDerivedBytes<THash> Constructor : HashDerivedBytes<THash> Constructor(Boolean,Byte[],Salt,Int32)

clear
password
salt
iterations

Glossary Item Box

Constructs the byte generation routine with the specified key, salt, and iteration count

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal clear As Boolean, _
   ByVal password() As Byte, _
   ByVal salt As Salt, _
   ByVal iterations As Integer _
)
C#
public HashDerivedBytes<THash>(
   bool clear,
   byte[] password,
   Salt salt,
   int iterations
)

Parameters

clear
password
salt
iterations

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members
Overload List

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashDerivedBytes<THash> Constructor(Byte[],Salt,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class > HashDerivedBytes<THash> Constructor : HashDerivedBytes<THash> Constructor(Byte[],Salt,Int32)

password
salt
iterations

Glossary Item Box

Constructs the byte generation routine with the specified key, salt, and iteration count

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal password() As Byte, _
   ByVal salt As Salt, _
   ByVal iterations As Integer _
)
C#
public HashDerivedBytes<THash>(
   byte[] password,
   Salt salt,
   int iterations
)

Parameters

password
salt
iterations

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
int iter = 100;
Salt salt = new Salt();
byte[] passbytes = Password.Encoding.GetBytes(TEST_PASSWORD);
IPasswordDerivedBytes[] types = new IPasswordDerivedBytes[] {
    new PBKDF2(passbytes, salt, iter),
    new HashDerivedBytes<HMACMD5>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA1>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA256>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA384>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA512>(passbytes, salt, iter),
};

foreach (IPasswordDerivedBytes db in types)
{
    byte[] key;

    Stopwatch w = new Stopwatch();
    w.Start();
    for (int i = 0; i < 100; i++)
        key = new PasswordKey(db, salt).CreateKey().Key;
    w.Stop();

    Console.Error.WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.GetType().Name);
}
VB.NET Copy Code
Dim iter As Integer = 100
Dim salt As New Salt()
Dim passbytes As Byte() = Password.Encoding.GetBytes(TEST_PASSWORD)
Dim types As IPasswordDerivedBytes() = New IPasswordDerivedBytes() {New PBKDF2(passbytes, salt, iter), New HashDerivedBytes(Of HMACMD5)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA1)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA256)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA384)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA512)(passbytes, salt, iter)}

For Each db As IPasswordDerivedBytes In types
    Dim key As Byte()

    Dim w As New Stopwatch()
    w.Start()
    Dim i As Integer = 0
    While i < 100
        key = New PasswordKey(db, salt).CreateKey().Key
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    w.[Stop]()

    Console.[Error].WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.[GetType]().Name)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members
Overload List

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HashDerivedBytes<THash> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : HashDerivedBytes<THash> Class

Glossary Item Box

For a list of all members of this type, see HashDerivedBytes<THash> members.

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of the object
Public Method | GetBytes | Overridden. Returns a pseudo-random key from a password, salt and iteration count.
Public Method | Reset | Overridden. Resets the state of the operation.
Top

See Also

Reference

HashDerivedBytes<THash> Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class : Dispose Method

Glossary Item Box

Disposes of the object

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class : GetBytes Method

cb

Glossary Item Box

Returns a pseudo-random key from a password, salt and iteration count.

Syntax

Visual Basic (Declaration)
Public Overrides Function GetBytes( _
   ByVal cb As Integer _
) As Byte()
C#
public override byte[] GetBytes(
   int cb
)

Parameters

cb

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members
Base Implementation in GetBytes

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Reset Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class : Reset Method

Glossary Item Box

Resets the state of the operation.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Reset()
C#
public override void Reset()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members
Base Implementation in Reset

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HashDerivedBytes<THash> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : HashDerivedBytes<THash> Class

Glossary Item Box

For a list of all members of this type, see HashDerivedBytes<THash> members.

Public Properties

 | Name | Description
Public Property | IterationCount | Gets or sets the number of iterations for the operation.
Public Property | Salt | Gets or sets the key salt value for the operation.
Top

See Also

Reference

HashDerivedBytes<THash> Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IterationCount Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class : IterationCount Property

Glossary Item Box

Gets or sets the number of iterations for the operation.

Syntax

Visual Basic (Declaration)
Public Property IterationCount As Integer
C#
public int IterationCount {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashDerivedBytes<THash> Class : Salt Property

Glossary Item Box

Gets or sets the key salt value for the operation.

Syntax

Visual Basic (Declaration)
Public Property Salt As Byte()
C#
public byte[] Salt {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashDerivedBytes<THash> Class
HashDerivedBytes<THash> Members

Source Code

Library/Crypto/HashDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : HashStream Class

Glossary Item Box

Represents a writtable stream for computing the hash value without retaining the data

Syntax

Visual Basic (Declaration)
Public NotInheritable Class HashStream
   Inherits CSharpTest.Net.IO.AggregateStream
C#
public sealed class HashStream : CSharpTest.Net.IO.AggregateStream

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[][] test =
new byte[][]
    {
        new byte[300],
        new byte[1],
        new byte[500],
        new byte[11],
        new byte[1],
        new byte[1000],
    };
using (HashStream hs = new HashStream(new SHA256Managed()))
using (MemoryStream ms = new MemoryStream())
using (HashStream hsWrap = new HashStream(new SHA256Managed(), ms))
{
    Assert.IsTrue(hs.CanWrite);
    long len = 0;
    foreach (byte[] bytes in test)
    {
        len += bytes.Length;
        r.NextBytes(bytes);
        hsWrap.Write(bytes, 0, bytes.Length);
        hs.Write(bytes, 0, bytes.Length);
    }
    for (int i = 0; i < 5; i++)
    {
        len += 1;
        byte val = (byte)r.Next(255);
        hsWrap.WriteByte(val);
        hs.WriteByte(val);
    }

    Assert.AreEqual(len, ms.Position);
    Hash expect = Hash.SHA256(ms.ToArray());
    Hash actual = hs.Close();

    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());

    //wrapped test
    actual = hsWrap.FinalizeHash();
    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());
}
VB.NET Copy Code
Dim r As New Random()
Dim test As Byte()() = New Byte()() {New Byte(300) {}, New Byte(1) {}, New Byte(500) {}, New Byte(11) {}, New Byte(1) {}, New Byte(1000) {}}
Using hs As New HashStream(New SHA256Managed())
    Using ms As New MemoryStream()
        Using hsWrap As New HashStream(New SHA256Managed(), ms)
            Assert.IsTrue(hs.CanWrite)
            Dim len As Long = 0
            For Each bytes As Byte() In test
                len += bytes.Length
                r.NextBytes(bytes)
                hsWrap.Write(bytes, 0, bytes.Length)
                hs.Write(bytes, 0, bytes.Length)
            Next
            Dim i As Integer = 0
            While i < 5
                len += 1
                Dim val As Byte = DirectCast(r.[Next](255), Byte)
                hsWrap.WriteByte(val)
                hs.WriteByte(val)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While

            Assert.AreEqual(len, ms.Position)
            Dim expect As Hash = Hash.SHA256(ms.ToArray())
            Dim actual As Hash = hs.Close()

            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())

            'wrapped test
            actual = hsWrap.FinalizeHash()
            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.AggregateStream
CSharpTest.Net.Crypto.HashStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HashStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : HashStream Class

Glossary Item Box

The following tables list the members exposed by HashStream.

Public Constructors

 | Name | Description
Public Constructor | HashStream Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Protected Properties

 | Name | Description
Protected Property | Stream | Allows modifying the underlying stream (Inherited from CSharpTest.Net.IO.AggregateStream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | ChangeStream | Change the underlying stream that is being written to / read from without affecting the current hash
Public Method | Close | Represents a writtable stream for computing the hash value without retaining the data
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | FinalizeHash | Can be called once, and only once, to obtain the hash generated while reading/writing. After this is called the stream will reset the hash and start computing a new hash value.
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

HashStream Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : HashStream Constructor

Glossary Item Box

Overload List

Overload | Description
HashStream Constructor(HashAlgorithm) | Represents a writtable stream for computing the hash value without retaining the data
HashStream Constructor(HashAlgorithm,Stream) | Wraps an existing stream while computing a hash on all bytes read from/written to the stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
HashStream Constructor(HashAlgorithm)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class > HashStream Constructor : HashStream Constructor(HashAlgorithm)

algo

Glossary Item Box

Represents a writtable stream for computing the hash value without retaining the data

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal algo As HashAlgorithm _
)
C#
public HashStream(
   HashAlgorithm algo
)

Parameters

algo

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[][] test =
new byte[][]
    {
        new byte[300],
        new byte[1],
        new byte[500],
        new byte[11],
        new byte[1],
        new byte[1000],
    };
using (HashStream hs = new HashStream(new SHA256Managed()))
using (MemoryStream ms = new MemoryStream())
using (HashStream hsWrap = new HashStream(new SHA256Managed(), ms))
{
    Assert.IsTrue(hs.CanWrite);
    long len = 0;
    foreach (byte[] bytes in test)
    {
        len += bytes.Length;
        r.NextBytes(bytes);
        hsWrap.Write(bytes, 0, bytes.Length);
        hs.Write(bytes, 0, bytes.Length);
    }
    for (int i = 0; i < 5; i++)
    {
        len += 1;
        byte val = (byte)r.Next(255);
        hsWrap.WriteByte(val);
        hs.WriteByte(val);
    }

    Assert.AreEqual(len, ms.Position);
    Hash expect = Hash.SHA256(ms.ToArray());
    Hash actual = hs.Close();

    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());

    //wrapped test
    actual = hsWrap.FinalizeHash();
    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());
}
VB.NET Copy Code
Dim r As New Random()
Dim test As Byte()() = New Byte()() {New Byte(300) {}, New Byte(1) {}, New Byte(500) {}, New Byte(11) {}, New Byte(1) {}, New Byte(1000) {}}
Using hs As New HashStream(New SHA256Managed())
    Using ms As New MemoryStream()
        Using hsWrap As New HashStream(New SHA256Managed(), ms)
            Assert.IsTrue(hs.CanWrite)
            Dim len As Long = 0
            For Each bytes As Byte() In test
                len += bytes.Length
                r.NextBytes(bytes)
                hsWrap.Write(bytes, 0, bytes.Length)
                hs.Write(bytes, 0, bytes.Length)
            Next
            Dim i As Integer = 0
            While i < 5
                len += 1
                Dim val As Byte = DirectCast(r.[Next](255), Byte)
                hsWrap.WriteByte(val)
                hs.WriteByte(val)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While

            Assert.AreEqual(len, ms.Position)
            Dim expect As Hash = Hash.SHA256(ms.ToArray())
            Dim actual As Hash = hs.Close()

            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())

            'wrapped test
            actual = hsWrap.FinalizeHash()
            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Overload List

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashStream Constructor(HashAlgorithm,Stream)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class > HashStream Constructor : HashStream Constructor(HashAlgorithm,Stream)

algo
underlyingStream

Glossary Item Box

Wraps an existing stream while computing a hash on all bytes read from/written to the stream

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal algo As HashAlgorithm, _
   ByVal underlyingStream As Stream _
)
C#
public HashStream(
   HashAlgorithm algo,
   Stream underlyingStream
)

Parameters

algo
underlyingStream

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[][] test =
new byte[][]
    {
        new byte[300],
        new byte[1],
        new byte[500],
        new byte[11],
        new byte[1],
        new byte[1000],
    };
using (HashStream hs = new HashStream(new SHA256Managed()))
using (MemoryStream ms = new MemoryStream())
using (HashStream hsWrap = new HashStream(new SHA256Managed(), ms))
{
    Assert.IsTrue(hs.CanWrite);
    long len = 0;
    foreach (byte[] bytes in test)
    {
        len += bytes.Length;
        r.NextBytes(bytes);
        hsWrap.Write(bytes, 0, bytes.Length);
        hs.Write(bytes, 0, bytes.Length);
    }
    for (int i = 0; i < 5; i++)
    {
        len += 1;
        byte val = (byte)r.Next(255);
        hsWrap.WriteByte(val);
        hs.WriteByte(val);
    }

    Assert.AreEqual(len, ms.Position);
    Hash expect = Hash.SHA256(ms.ToArray());
    Hash actual = hs.Close();

    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());

    //wrapped test
    actual = hsWrap.FinalizeHash();
    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());
}
VB.NET Copy Code
Dim r As New Random()
Dim test As Byte()() = New Byte()() {New Byte(300) {}, New Byte(1) {}, New Byte(500) {}, New Byte(11) {}, New Byte(1) {}, New Byte(1000) {}}
Using hs As New HashStream(New SHA256Managed())
    Using ms As New MemoryStream()
        Using hsWrap As New HashStream(New SHA256Managed(), ms)
            Assert.IsTrue(hs.CanWrite)
            Dim len As Long = 0
            For Each bytes As Byte() In test
                len += bytes.Length
                r.NextBytes(bytes)
                hsWrap.Write(bytes, 0, bytes.Length)
                hs.Write(bytes, 0, bytes.Length)
            Next
            Dim i As Integer = 0
            While i < 5
                len += 1
                Dim val As Byte = DirectCast(r.[Next](255), Byte)
                hsWrap.WriteByte(val)
                hs.WriteByte(val)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While

            Assert.AreEqual(len, ms.Position)
            Dim expect As Hash = Hash.SHA256(ms.ToArray())
            Dim actual As Hash = hs.Close()

            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())

            'wrapped test
            actual = hsWrap.FinalizeHash()
            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Overload List

Used By

Boolean SecureTransfer.Client.Upload(String,Int64,Stream)

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HashStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : HashStream Class

Glossary Item Box

For a list of all members of this type, see HashStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | ChangeStream | Change the underlying stream that is being written to / read from without affecting the current hash
Public Method | Close | Represents a writtable stream for computing the hash value without retaining the data
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | FinalizeHash | Can be called once, and only once, to obtain the hash generated while reading/writing. After this is called the stream will reset the hash and start computing a new hash value.
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

HashStream Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ChangeStream Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : ChangeStream Method

stream

Glossary Item Box

Change the underlying stream that is being written to / read from without affecting the current hash

Syntax

Visual Basic (Declaration)
Public Sub ChangeStream( _
   ByVal stream As Stream _
)
C#
public void ChangeStream(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : Close Method

Glossary Item Box

Represents a writtable stream for computing the hash value without retaining the data

Syntax

Visual Basic (Declaration)
Public Shadows Function Close() As Hash
C#
public new Hash Close()

Return Value

The hash code computed by the series of Write(...) calls

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[][] test =
new byte[][]
    {
        new byte[300],
        new byte[1],
        new byte[500],
        new byte[11],
        new byte[1],
        new byte[1000],
    };
using (HashStream hs = new HashStream(new SHA256Managed()))
using (MemoryStream ms = new MemoryStream())
using (HashStream hsWrap = new HashStream(new SHA256Managed(), ms))
{
    Assert.IsTrue(hs.CanWrite);
    long len = 0;
    foreach (byte[] bytes in test)
    {
        len += bytes.Length;
        r.NextBytes(bytes);
        hsWrap.Write(bytes, 0, bytes.Length);
        hs.Write(bytes, 0, bytes.Length);
    }
    for (int i = 0; i < 5; i++)
    {
        len += 1;
        byte val = (byte)r.Next(255);
        hsWrap.WriteByte(val);
        hs.WriteByte(val);
    }

    Assert.AreEqual(len, ms.Position);
    Hash expect = Hash.SHA256(ms.ToArray());
    Hash actual = hs.Close();

    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());

    //wrapped test
    actual = hsWrap.FinalizeHash();
    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());
}
VB.NET Copy Code
Dim r As New Random()
Dim test As Byte()() = New Byte()() {New Byte(300) {}, New Byte(1) {}, New Byte(500) {}, New Byte(11) {}, New Byte(1) {}, New Byte(1000) {}}
Using hs As New HashStream(New SHA256Managed())
    Using ms As New MemoryStream()
        Using hsWrap As New HashStream(New SHA256Managed(), ms)
            Assert.IsTrue(hs.CanWrite)
            Dim len As Long = 0
            For Each bytes As Byte() In test
                len += bytes.Length
                r.NextBytes(bytes)
                hsWrap.Write(bytes, 0, bytes.Length)
                hs.Write(bytes, 0, bytes.Length)
            Next
            Dim i As Integer = 0
            While i < 5
                len += 1
                Dim val As Byte = DirectCast(r.[Next](255), Byte)
                hsWrap.WriteByte(val)
                hs.WriteByte(val)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While

            Assert.AreEqual(len, ms.Position)
            Dim expect As Hash = Hash.SHA256(ms.ToArray())
            Dim actual As Hash = hs.Close()

            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())

            'wrapped test
            actual = hsWrap.FinalizeHash()
            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Hash

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : Dispose Method

Glossary Item Box

Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

Overload List

Overload | Description
Dispose(Boolean) | Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides NotOverridable Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
FinalizeHash Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : FinalizeHash Method

Glossary Item Box

Can be called once, and only once, to obtain the hash generated while reading/writing. After this is called the stream will reset the hash and start computing a new hash value.

Syntax

Visual Basic (Declaration)
Public Function FinalizeHash() As Hash
C#
public Hash FinalizeHash()

Example

Library/Library.Test/TestHash.cs

C# Copy Code
Random r = new Random();
byte[][] test =
new byte[][]
    {
        new byte[300],
        new byte[1],
        new byte[500],
        new byte[11],
        new byte[1],
        new byte[1000],
    };
using (HashStream hs = new HashStream(new SHA256Managed()))
using (MemoryStream ms = new MemoryStream())
using (HashStream hsWrap = new HashStream(new SHA256Managed(), ms))
{
    Assert.IsTrue(hs.CanWrite);
    long len = 0;
    foreach (byte[] bytes in test)
    {
        len += bytes.Length;
        r.NextBytes(bytes);
        hsWrap.Write(bytes, 0, bytes.Length);
        hs.Write(bytes, 0, bytes.Length);
    }
    for (int i = 0; i < 5; i++)
    {
        len += 1;
        byte val = (byte)r.Next(255);
        hsWrap.WriteByte(val);
        hs.WriteByte(val);
    }

    Assert.AreEqual(len, ms.Position);
    Hash expect = Hash.SHA256(ms.ToArray());
    Hash actual = hs.Close();

    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());

    //wrapped test
    actual = hsWrap.FinalizeHash();
    Assert.AreEqual(expect, actual);
    Assert.AreEqual(expect.ToArray(), actual.ToArray());
    Assert.AreEqual(expect.ToString(), actual.ToString());
}
VB.NET Copy Code
Dim r As New Random()
Dim test As Byte()() = New Byte()() {New Byte(300) {}, New Byte(1) {}, New Byte(500) {}, New Byte(11) {}, New Byte(1) {}, New Byte(1000) {}}
Using hs As New HashStream(New SHA256Managed())
    Using ms As New MemoryStream()
        Using hsWrap As New HashStream(New SHA256Managed(), ms)
            Assert.IsTrue(hs.CanWrite)
            Dim len As Long = 0
            For Each bytes As Byte() In test
                len += bytes.Length
                r.NextBytes(bytes)
                hsWrap.Write(bytes, 0, bytes.Length)
                hs.Write(bytes, 0, bytes.Length)
            Next
            Dim i As Integer = 0
            While i < 5
                len += 1
                Dim val As Byte = DirectCast(r.[Next](255), Byte)
                hsWrap.WriteByte(val)
                hs.WriteByte(val)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While

            Assert.AreEqual(len, ms.Position)
            Dim expect As Hash = Hash.SHA256(ms.ToArray())
            Dim actual As Hash = hs.Close()

            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())

            'wrapped test
            actual = hsWrap.FinalizeHash()
            Assert.AreEqual(expect, actual)
            Assert.AreEqual(expect.ToArray(), actual.ToArray())
            Assert.AreEqual(expect.ToString(), actual.ToString())
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Hash

Used By

Boolean SecureTransfer.Client.Upload(String,Int64,Stream)
Hash HashStream.Close()

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : Read Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int Read(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Base Implementation in Read

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : ReadByte Method

Glossary Item Box

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable Function ReadByte() As Integer
C#
public override int ReadByte()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Base Implementation in ReadByte

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : Write Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
)
C#
public override void Write(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Base Implementation in Write

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : WriteByte Method

value

Glossary Item Box

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable Sub WriteByte( _
   ByVal value As Byte _
)
C#
public override void WriteByte(
   byte value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Base Implementation in WriteByte

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HashStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : HashStream Class

Glossary Item Box

For a list of all members of this type, see HashStream members.

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Protected Properties

 | Name | Description
Protected Property | Stream | Allows modifying the underlying stream (Inherited from CSharpTest.Net.IO.AggregateStream)
Top

See Also

Reference

HashStream Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanWrite Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > HashStream Class : CanWrite Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable ReadOnly Property CanWrite As Boolean
C#
public override bool CanWrite {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HashStream Class
HashStream Members
Base Implementation in CanWrite

Source Code

Library/Crypto/HashStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalHostKey Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : LocalHostKey Class

Glossary Item Box

Provides access to local machine and local user encryption via the ProtectedData class

Syntax

Visual Basic (Declaration)
Public Class LocalHostKey
   Inherits AsymmetricKey
   Implements IEncryptDecrypt
C#
public class LocalHostKey : AsymmetricKey, IEncryptDecrypt

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.AsymmetricKey
CSharpTest.Net.Crypto.LocalHostKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LocalHostKey Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/LocalHostKey.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LocalHostKey Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : LocalHostKey Class

Glossary Item Box

The following tables list the members exposed by LocalHostKey.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | CurrentUser | Encrypts data for the current user
static (Shared in Visual Basic) | LocalMachine | Encrypts data for the this machine
Top

Protected Properties

 | Name | Description
Protected Property | BlockSize | Overridden. Block size
Protected Property | TransformSize | Overridden. Output size
Top

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Decrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Encrypt | Overloaded. Encrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | WithSalt | Sets or changes the salt for this encryption key
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Overridden. Decrypts the given bytes
Protected Method | EncryptBlock | Overridden. Encrypts the given bytes
Top

See Also

Reference

LocalHostKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/LocalHostKey.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LocalHostKey Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : LocalHostKey Class

Glossary Item Box

For a list of all members of this type, see LocalHostKey members.

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Decrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Encrypt | Overloaded. Encrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | WithSalt | Sets or changes the salt for this encryption key
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Overridden. Decrypts the given bytes
Protected Method | EncryptBlock | Overridden. Encrypts the given bytes
Top

See Also

Reference

LocalHostKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/LocalHostKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecryptBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > LocalHostKey Class : DecryptBlock Method

blob

Glossary Item Box

Decrypts the given bytes

Syntax

Visual Basic (Declaration)
Protected Overrides Function DecryptBlock( _
   ByVal blob() As Byte _
) As Byte()
C#
protected override byte[] DecryptBlock(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LocalHostKey Class
LocalHostKey Members
Base Implementation in DecryptBlock


%%PageItemTitle%%

[image]
CSharpTest.Net
EncryptBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > LocalHostKey Class : EncryptBlock Method

blob

Glossary Item Box

Encrypts the given bytes

Syntax

Visual Basic (Declaration)
Protected Overrides Function EncryptBlock( _
   ByVal blob() As Byte _
) As Byte()
C#
protected override byte[] EncryptBlock(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LocalHostKey Class
LocalHostKey Members
Base Implementation in EncryptBlock


%%PageItemTitle%%

[image]
CSharpTest.Net
WithSalt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > LocalHostKey Class : WithSalt Method

salt

Glossary Item Box

Sets or changes the salt for this encryption key

Syntax

Visual Basic (Declaration)
Public Function WithSalt( _
   ByVal salt As Salt _
) As LocalHostKey
C#
public LocalHostKey WithSalt(
   Salt salt
)

Parameters

salt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LocalHostKey Class
LocalHostKey Members
Salt

Source Code

Library/Crypto/LocalHostKey.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LocalHostKey Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : LocalHostKey Class

Glossary Item Box

For a list of all members of this type, see LocalHostKey members.

Protected Properties

 | Name | Description
Protected Property | BlockSize | Overridden. Block size
Protected Property | TransformSize | Overridden. Output size
Top

See Also

Reference

LocalHostKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/LocalHostKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BlockSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > LocalHostKey Class : BlockSize Property

Glossary Item Box

Block size

Syntax

Visual Basic (Declaration)
Protected Overrides ReadOnly Property BlockSize As Integer
C#
protected override int BlockSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LocalHostKey Class
LocalHostKey Members
Base Implementation in BlockSize


%%PageItemTitle%%

[image]
CSharpTest.Net
TransformSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > LocalHostKey Class : TransformSize Property

Glossary Item Box

Output size

Syntax

Visual Basic (Declaration)
Protected Overrides ReadOnly Property TransformSize As Integer
C#
protected override int TransformSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LocalHostKey Class
LocalHostKey Members
Base Implementation in TransformSize


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
LocalHostKey Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : LocalHostKey Class

Glossary Item Box

For a list of all members of this type, see LocalHostKey members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | CurrentUser | Encrypts data for the current user
static (Shared in Visual Basic) | LocalMachine | Encrypts data for the this machine
Top

See Also

Reference

LocalHostKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/LocalHostKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CurrentUser Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > LocalHostKey Class : CurrentUser Field

Glossary Item Box

Encrypts data for the current user

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly CurrentUser As LocalHostKey
C#
public static readonly LocalHostKey CurrentUser

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LocalHostKey Class
LocalHostKey Members

Source Code

Library/Crypto/LocalHostKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalMachine Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > LocalHostKey Class : LocalMachine Field

Glossary Item Box

Encrypts data for the this machine

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly LocalMachine As LocalHostKey
C#
public static readonly LocalHostKey LocalMachine

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LocalHostKey Class
LocalHostKey Members

Source Code

Library/Crypto/LocalHostKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ModifiedRijndael Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : ModifiedRijndael Class

Glossary Item Box

This class is provided to essentially unlock the Rijndael algorithm from the constraints imposed by the AES standards. The Rijndael algorithm here supports a wider length of key sizes and allows users to explicitly set the number of rounds. This class is fully AES compliant when used with key sizes of 16, 24, or 32 bytes with rounds of 10, 12, and 14 respectivly.

Syntax

Visual Basic (Declaration)
Public Class ModifiedRijndael
   Inherits System.Security.Cryptography.SymmetricAlgorithm
C#
public class ModifiedRijndael : System.Security.Cryptography.SymmetricAlgorithm

Example

Library/Library.Test/TestModifiedRijndael.cs

C# Copy Code
RijndaelManaged r = new RijndaelManaged();

foreach (int blksz in AllKeySizes(r.LegalBlockSizes))
{
    r.BlockSize = blksz;
    r.GenerateIV();

    foreach (int keysz in AllKeySizes(r.LegalKeySizes))
    {
        r.KeySize = keysz;
        r.GenerateKey();

        ModifiedRijndael modified = ModifiedRijndael.Create(typeof(ModifiedRijndael).FullName);
        modified.BlockSize = r.BlockSize;
        modified.KeySize = r.KeySize;
        modified.IV = r.IV;
        modified.Key = r.Key;
        modified.Padding = r.Padding;
        modified.Mode = r.Mode;

        TestEncryptDecrypt(r, modified);
        TestEncryptDecrypt(modified, r);
    }
}
VB.NET Copy Code
Dim r As New RijndaelManaged()

For Each blksz As Integer In AllKeySizes(r.LegalBlockSizes)
    r.BlockSize = blksz
    r.GenerateIV()

    For Each keysz As Integer In AllKeySizes(r.LegalKeySizes)
        r.KeySize = keysz
        r.GenerateKey()

        Dim modified As ModifiedRijndael = ModifiedRijndael.Create(GetType(ModifiedRijndael).FullName)
        modified.BlockSize = r.BlockSize
        modified.KeySize = r.KeySize
        modified.IV = r.IV
        modified.Key = r.Key
        modified.Padding = r.Padding
        modified.Mode = r.Mode

        TestEncryptDecrypt(r, modified)
        TestEncryptDecrypt(modified, r)
    Next
Next

Inheritance Hierarchy

System.Object
System.Security.Cryptography.SymmetricAlgorithm
CSharpTest.Net.Crypto.ModifiedRijndael

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/ModifiedRijndael.cs

Used By

ModifiedRijndael ModifiedRijndael.Create(String)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ModifiedRijndael Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : ModifiedRijndael Class

Glossary Item Box

The following tables list the members exposed by ModifiedRijndael.

Public Constructors

 | Name | Description
Public Constructor | ModifiedRijndael Constructor | Creates a ModifiedRijndael which can be used with larger key sizes and a specified number of rounds.
Top

Protected Fields

 | Name | Description
Protected Field | BlockSizeValue | Represents the block size, in bits, of the cryptographic operation. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | FeedbackSizeValue | Represents the feedback size, in bits, of the cryptographic operation. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | IVValue | Represents the initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV) for the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | KeySizeValue | Represents the size, in bits, of the secret key used by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | KeyValue | Represents the secret key for the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | LegalBlockSizesValue | Specifies the block sizes, in bits, that are supported by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | LegalKeySizesValue | Specifies the key sizes, in bits, that are supported by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | ModeValue | Represents the cipher mode used in the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | PaddingValue | Represents the padding mode used in the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Top

Public Properties

 | Name | Description
Public Property | BlockSize | Gets or sets the block size, in bits, of the cryptographic operation. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | FeedbackSize | Gets or sets the feedback size, in bits, of the cryptographic operation. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | IV | Gets or sets the initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV) for the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | Key | Gets or sets the secret key for the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | KeySize | Gets or sets the size, in bits, of the secret key used by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | LegalBlockSizes | Gets the block sizes, in bits, that are supported by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | LegalKeySizes | Gets the key sizes, in bits, that are supported by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | MaxRounds | Returns the Maximum value for Rounds given the current BlockSize and KeySize values
Public Property | Mode | Gets or sets the mode for operation of the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | NormalRounds | Returns the AES standard round numbers for keys of 128, 192, and 256 bit, or provides a rough 1/3 of MaxRounds for other key sizes based on a constant block size of 128 bit.
Public Property | Padding | Gets or sets the padding mode used in the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | Rounds | Gets or sets the number of rounds the encryption algorithm will use when encrypting/decrypting data.
Top

Public Methods

 | Name | Description
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.SymmetricAlgorithm class. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
static (Shared in Visual Basic) | Create | return a new instance
Public Method | CreateDecryptor | Overloaded. Overridden. When overridden in a derived class, creates a symmetric decryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).
Public Method | CreateEncryptor | Overloaded. Overridden. When overridden in a derived class, creates a symmetric encryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).
Public Method | GenerateIV | Overridden. When overridden in a derived class, generates a random initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV) to use for the algorithm.
Public Method | GenerateKey | Overridden. When overridden in a derived class, generates a random key (System.Security.Cryptography.SymmetricAlgorithm.Key) to use for the algorithm.
Public Method | ValidKeySize | Determines whether the specified key size is valid for the current algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Top

Protected Methods

 | Name | Description
Protected Method | Dispose | Releases the unmanaged resources used by the System.Security.Cryptography.SymmetricAlgorithm and optionally releases the managed resources. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Top

See Also

Reference

ModifiedRijndael Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/ModifiedRijndael.cs

Used By

ModifiedRijndael ModifiedRijndael.Create(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
ModifiedRijndael Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : ModifiedRijndael Constructor

Glossary Item Box

Creates a ModifiedRijndael which can be used with larger key sizes and a specified number of rounds.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public ModifiedRijndael()

Example

Library/Library.Test/TestModifiedRijndael.cs

C# Copy Code
ModifiedRijndael r = new ModifiedRijndael();

foreach (int blksz in AllKeySizes(r.LegalBlockSizes))
{
    r.BlockSize = blksz;
    r.GenerateIV();
    Assert.AreEqual(blksz, r.IV.Length*8);

    foreach (int keysz in AllKeySizes(r.LegalKeySizes))
    {
        r.KeySize = keysz;
        r.GenerateKey();
        Assert.AreEqual(keysz, r.Key.Length*8);

        r.Rounds = r.NormalRounds;
        TestEncryptDecrypt(r, r);
        r.Rounds = r.MaxRounds;
        TestEncryptDecrypt(r, r);
    }
}
VB.NET Copy Code
Dim r As New ModifiedRijndael()

For Each blksz As Integer In AllKeySizes(r.LegalBlockSizes)
    r.BlockSize = blksz
    r.GenerateIV()
    Assert.AreEqual(blksz, r.IV.Length * 8)

    For Each keysz As Integer In AllKeySizes(r.LegalKeySizes)
        r.KeySize = keysz
        r.GenerateKey()
        Assert.AreEqual(keysz, r.Key.Length * 8)

        r.Rounds = r.NormalRounds
        TestEncryptDecrypt(r, r)
        r.Rounds = r.MaxRounds
        TestEncryptDecrypt(r, r)
    Next
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members

Used By

ModifiedRijndael ModifiedRijndael.Create()
ModifiedRijndael ModifiedRijndael.Create(String)

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ModifiedRijndael Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : ModifiedRijndael Class

Glossary Item Box

For a list of all members of this type, see ModifiedRijndael members.

Public Methods

 | Name | Description
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.SymmetricAlgorithm class. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
static (Shared in Visual Basic) | Create | return a new instance
Public Method | CreateDecryptor | Overloaded. Overridden. When overridden in a derived class, creates a symmetric decryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).
Public Method | CreateEncryptor | Overloaded. Overridden. When overridden in a derived class, creates a symmetric encryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).
Public Method | GenerateIV | Overridden. When overridden in a derived class, generates a random initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV) to use for the algorithm.
Public Method | GenerateKey | Overridden. When overridden in a derived class, generates a random key (System.Security.Cryptography.SymmetricAlgorithm.Key) to use for the algorithm.
Public Method | ValidKeySize | Determines whether the specified key size is valid for the current algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Top

Protected Methods

 | Name | Description
Protected Method | Dispose | Releases the unmanaged resources used by the System.Security.Cryptography.SymmetricAlgorithm and optionally releases the managed resources. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Top

See Also

Reference

ModifiedRijndael Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/ModifiedRijndael.cs

Used By

ModifiedRijndael ModifiedRijndael.Create(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : Create Method

Glossary Item Box

return a new instance

Syntax

Visual Basic (Declaration)
Public Shared Shadows Function Create() As ModifiedRijndael
C#
public new static ModifiedRijndael Create()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateDecryptor Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : CreateDecryptor Method

Glossary Item Box

When overridden in a derived class, creates a symmetric decryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).

Overload List

Overload | Description
CreateDecryptor(Byte[],Byte[]) | When overridden in a derived class, creates a symmetric decryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).
CreateDecryptor() | Creates a symmetric decryptor object with the current System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV). (Inherited from System.Security.Cryptography.SymmetricAlgorithm)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members
Base Implementation in CreateDecryptor


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateDecryptor(Byte[],Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class > CreateDecryptor Method : CreateDecryptor(Byte[],Byte[]) Method

keybytes
iv

Glossary Item Box

When overridden in a derived class, creates a symmetric decryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function CreateDecryptor( _
   ByVal keybytes() As Byte, _
   ByVal iv() As Byte _
) As ICryptoTransform
C#
public override ICryptoTransform CreateDecryptor(
   byte[] keybytes,
   byte[] iv
)

Parameters

keybytes
iv

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members
Overload List
Base Implementation in CreateDecryptor(Byte[],Byte[])

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateEncryptor Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : CreateEncryptor Method

Glossary Item Box

When overridden in a derived class, creates a symmetric encryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).

Overload List

Overload | Description
CreateEncryptor(Byte[],Byte[]) | When overridden in a derived class, creates a symmetric encryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).
CreateEncryptor() | Creates a symmetric encryptor object with the current System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV). (Inherited from System.Security.Cryptography.SymmetricAlgorithm)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members
Base Implementation in CreateEncryptor


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateEncryptor(Byte[],Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class > CreateEncryptor Method : CreateEncryptor(Byte[],Byte[]) Method

keybytes
iv

Glossary Item Box

When overridden in a derived class, creates a symmetric encryptor object with the specified System.Security.Cryptography.SymmetricAlgorithm.Key property and initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV).

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function CreateEncryptor( _
   ByVal keybytes() As Byte, _
   ByVal iv() As Byte _
) As ICryptoTransform
C#
public override ICryptoTransform CreateEncryptor(
   byte[] keybytes,
   byte[] iv
)

Parameters

keybytes
iv

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members
Overload List
Base Implementation in CreateEncryptor(Byte[],Byte[])

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GenerateIV Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : GenerateIV Method

Glossary Item Box

When overridden in a derived class, generates a random initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV) to use for the algorithm.

Syntax

Visual Basic (Declaration)
Public Overrides Sub GenerateIV()
C#
public override void GenerateIV()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members
Base Implementation in GenerateIV

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GenerateKey Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : GenerateKey Method

Glossary Item Box

When overridden in a derived class, generates a random key (System.Security.Cryptography.SymmetricAlgorithm.Key) to use for the algorithm.

Syntax

Visual Basic (Declaration)
Public Overrides Sub GenerateKey()
C#
public override void GenerateKey()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members
Base Implementation in GenerateKey

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ModifiedRijndael Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : ModifiedRijndael Class

Glossary Item Box

For a list of all members of this type, see ModifiedRijndael members.

Public Properties

 | Name | Description
Public Property | BlockSize | Gets or sets the block size, in bits, of the cryptographic operation. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | FeedbackSize | Gets or sets the feedback size, in bits, of the cryptographic operation. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | IV | Gets or sets the initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV) for the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | Key | Gets or sets the secret key for the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | KeySize | Gets or sets the size, in bits, of the secret key used by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | LegalBlockSizes | Gets the block sizes, in bits, that are supported by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | LegalKeySizes | Gets the key sizes, in bits, that are supported by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | MaxRounds | Returns the Maximum value for Rounds given the current BlockSize and KeySize values
Public Property | Mode | Gets or sets the mode for operation of the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | NormalRounds | Returns the AES standard round numbers for keys of 128, 192, and 256 bit, or provides a rough 1/3 of MaxRounds for other key sizes based on a constant block size of 128 bit.
Public Property | Padding | Gets or sets the padding mode used in the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Public Property | Rounds | Gets or sets the number of rounds the encryption algorithm will use when encrypting/decrypting data.
Top

See Also

Reference

ModifiedRijndael Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/ModifiedRijndael.cs

Used By

ModifiedRijndael ModifiedRijndael.Create(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxRounds Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : MaxRounds Property

Glossary Item Box

Returns the Maximum value for Rounds given the current BlockSize and KeySize values

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MaxRounds As Integer
C#
public int MaxRounds {get;}

Example

Library/Library.Test/TestModifiedRijndael.cs

C# Copy Code
ModifiedRijndael r = new ModifiedRijndael();

foreach (int blksz in AllKeySizes(r.LegalBlockSizes))
{
    r.BlockSize = blksz;
    r.GenerateIV();
    Assert.AreEqual(blksz, r.IV.Length*8);

    foreach (int keysz in AllKeySizes(r.LegalKeySizes))
    {
        r.KeySize = keysz;
        r.GenerateKey();
        Assert.AreEqual(keysz, r.Key.Length*8);

        r.Rounds = r.NormalRounds;
        TestEncryptDecrypt(r, r);
        r.Rounds = r.MaxRounds;
        TestEncryptDecrypt(r, r);
    }
}
VB.NET Copy Code
Dim r As New ModifiedRijndael()

For Each blksz As Integer In AllKeySizes(r.LegalBlockSizes)
    r.BlockSize = blksz
    r.GenerateIV()
    Assert.AreEqual(blksz, r.IV.Length * 8)

    For Each keysz As Integer In AllKeySizes(r.LegalKeySizes)
        r.KeySize = keysz
        r.GenerateKey()
        Assert.AreEqual(keysz, r.Key.Length * 8)

        r.Rounds = r.NormalRounds
        TestEncryptDecrypt(r, r)
        r.Rounds = r.MaxRounds
        TestEncryptDecrypt(r, r)
    Next
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NormalRounds Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : NormalRounds Property

Glossary Item Box

Returns the AES standard round numbers for keys of 128, 192, and 256 bit, or provides a rough 1/3 of MaxRounds for other key sizes based on a constant block size of 128 bit.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property NormalRounds As Integer
C#
public int NormalRounds {get;}

Example

Library/Library.Test/TestModifiedRijndael.cs

C# Copy Code
ModifiedRijndael r = new ModifiedRijndael();

foreach (int blksz in AllKeySizes(r.LegalBlockSizes))
{
    r.BlockSize = blksz;
    r.GenerateIV();
    Assert.AreEqual(blksz, r.IV.Length*8);

    foreach (int keysz in AllKeySizes(r.LegalKeySizes))
    {
        r.KeySize = keysz;
        r.GenerateKey();
        Assert.AreEqual(keysz, r.Key.Length*8);

        r.Rounds = r.NormalRounds;
        TestEncryptDecrypt(r, r);
        r.Rounds = r.MaxRounds;
        TestEncryptDecrypt(r, r);
    }
}
VB.NET Copy Code
Dim r As New ModifiedRijndael()

For Each blksz As Integer In AllKeySizes(r.LegalBlockSizes)
    r.BlockSize = blksz
    r.GenerateIV()
    Assert.AreEqual(blksz, r.IV.Length * 8)

    For Each keysz As Integer In AllKeySizes(r.LegalKeySizes)
        r.KeySize = keysz
        r.GenerateKey()
        Assert.AreEqual(keysz, r.Key.Length * 8)

        r.Rounds = r.NormalRounds
        TestEncryptDecrypt(r, r)
        r.Rounds = r.MaxRounds
        TestEncryptDecrypt(r, r)
    Next
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Rounds Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > ModifiedRijndael Class : Rounds Property

Glossary Item Box

Gets or sets the number of rounds the encryption algorithm will use when encrypting/decrypting data.

Syntax

Visual Basic (Declaration)
Public Property Rounds As Integer
C#
public int Rounds {get; set;}

Example

Library/Library.Test/TestModifiedRijndael.cs

C# Copy Code
ModifiedRijndael r = new ModifiedRijndael();

foreach (int blksz in AllKeySizes(r.LegalBlockSizes))
{
    r.BlockSize = blksz;
    r.GenerateIV();
    Assert.AreEqual(blksz, r.IV.Length*8);

    foreach (int keysz in AllKeySizes(r.LegalKeySizes))
    {
        r.KeySize = keysz;
        r.GenerateKey();
        Assert.AreEqual(keysz, r.Key.Length*8);

        r.Rounds = r.NormalRounds;
        TestEncryptDecrypt(r, r);
        r.Rounds = r.MaxRounds;
        TestEncryptDecrypt(r, r);
    }
}
VB.NET Copy Code
Dim r As New ModifiedRijndael()

For Each blksz As Integer In AllKeySizes(r.LegalBlockSizes)
    r.BlockSize = blksz
    r.GenerateIV()
    Assert.AreEqual(blksz, r.IV.Length * 8)

    For Each keysz As Integer In AllKeySizes(r.LegalKeySizes)
        r.KeySize = keysz
        r.GenerateKey()
        Assert.AreEqual(keysz, r.Key.Length * 8)

        r.Rounds = r.NormalRounds
        TestEncryptDecrypt(r, r)
        r.Rounds = r.MaxRounds
        TestEncryptDecrypt(r, r)
    Next
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ModifiedRijndael Class
ModifiedRijndael Members

Source Code

Library/Crypto/ModifiedRijndael.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Password Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Password Class

Glossary Item Box

Stores an encrypted version of the supplied password in memory so that it can be provided as clear-text to external systems.

Object Model

Password ClassIPasswordDerivedBytes InterfaceIEncryptDecrypt InterfaceSalt Class

Syntax

Visual Basic (Declaration)
Public Class Password
   Inherits PasswordKey
   Implements IEncryptDecrypt
C#
public class Password : PasswordKey, IEncryptDecrypt

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.PasswordKey
CSharpTest.Net.Crypto.Password

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Members
CSharpTest.Net.Crypto Namespace
Boolean Password.EqualityComparer.Equals(Password,Password)
Int32 Password.EqualityComparer.GetHashCode(Password)
Boolean PasswordHash.VerifyPassword(Password)

Source Code

Library/Crypto/Password.cs

Used By

Boolean Password.Equals(Object)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Password Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Password Class

Glossary Item Box

The following tables list the members exposed by Password.

Public Constructors

 | Name | Description
Public Constructor | Password Constructor | Overloaded.
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | return a non-reference equality comparer for this class
Top

Public Properties

 | Name | Description
static (Shared in Visual Basic) | Encoding | Returns the encoding used for passwords
Public Property | IterationCount | Sets or Gets the iterations used with deriving the encryption key (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Public Property | IV | Sets or Gets the IV used when deriving the encryption key (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Public Property | Salt | Sets or Gets the salt used with deriving the encryption key (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Top

Protected Properties

 | Name | Description
Protected Property | DerivedBytes | Returns the derived bytes algorithm for this instance or throws ObjectDisposedException (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Protected Property | Passkey | Allows overriding the encryption/decryption support for the in-memory password
Top

Public Methods

 | Name | Description
Public Method | CreateHash | Overloaded. Returns a salted hash for the password
Public Method | CreateKey | Overloaded. Returns the key generated with the current password and salt (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Public Method | Decrypt | Overloaded. Wraps the stream with a cryptographic stream (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Dispose | Overloaded. Overridden. Removes the memory representation of this password and key
Public Method | Encrypt | Overloaded. Wraps the stream with a cryptographic stream (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Equals | Overloaded. Returns true if the other object is equal to this one
Public Method | GetHashCode | Overloaded. Extracts the correct hash code
Public Method | ReadBytes | Returns a stream from which the password can be read
Public Method | ReadText | Returns a stream from which the password can be read
Public Method | ToSecureString | Returns a System.Security.SecureString from the password
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Top

Public Operators

public Operator Equality | Compares the two objects for non-reference equality
public Operator Inequality | Compares the two objects for non-reference equality
Top

See Also

Reference

Password Class
CSharpTest.Net.Crypto Namespace
Boolean Password.EqualityComparer.Equals(Password,Password)
Int32 Password.EqualityComparer.GetHashCode(Password)
Boolean PasswordHash.VerifyPassword(Password)

Source Code

Library/Crypto/Password.cs

Used By

Boolean Password.Equals(Object)


%%PageItemTitle%%

[image]
CSharpTest.Net
Password Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : Password Constructor

Glossary Item Box

Overload List

Overload | Description
Password Constructor(Boolean,Byte[]) | Creates the password from the given bytes and salt
Password Constructor(String) | Creates the password from the given data and salt
Password Constructor(SecureString) | Creates the password from the given data and salt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Password Constructor(Boolean,Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Password Constructor : Password Constructor(Boolean,Byte[])

clear
bytes

Glossary Item Box

Creates the password from the given bytes and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal clear As Boolean, _
   ByVal bytes() As Byte _
)
C#
public Password(
   bool clear,
   byte[] bytes
)

Parameters

clear
bytes

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
const int count = 1000;
Random rand = new Random();
byte[] bytes = new byte[100];
rand.NextBytes(bytes);
Stopwatch time = new Stopwatch();
time.Start();

for (int i = 0; i < count; i++)
{
    bytes = new byte[rand.Next(450) + 50];
    rand.NextBytes(bytes);
    using (Password pwd = new Password(false, bytes))
    {
        byte[] copy = IOStream.ReadAllBytes(pwd.ReadBytes());
        Assert.AreEqual(bytes, copy);
    }
}
time.Stop();
Trace.WriteLine(time.Elapsed.ToString(), count.ToString() + " Passwords");
VB.NET Copy Code
Const  count As Integer = 1000
Dim rand As New Random()
Dim bytes As Byte() = New Byte(100) {}
rand.NextBytes(bytes)
Dim time As New Stopwatch()
time.Start()

Dim i As Integer = 0
While i < count
    bytes = New Byte(rand.[Next](450) + 50) {}
    rand.NextBytes(bytes)
    Using pwd As New Password(False, bytes)
        Dim copy As Byte() = IOStream.ReadAllBytes(pwd.ReadBytes())
        Assert.AreEqual(bytes, copy)
    End Using
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
time.[Stop]()
Trace.WriteLine(time.Elapsed.ToString(), count.ToString() + " Passwords")

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Password Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Password Constructor : Password Constructor(String)

data

Glossary Item Box

Creates the password from the given data and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal data As String _
)
C#
public Password(
   string data
)

Parameters

data

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Password Constructor(SecureString)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Password Constructor : Password Constructor(SecureString)

data

Glossary Item Box

Creates the password from the given data and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal data As SecureString _
)
C#
public Password(
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
using (Password p1 = new Password(TEST_PASSWORD))
using (SecureString sstr = p1.ToSecureString())
using (Password p2 = new Password(sstr))
{
    Assert.AreEqual(p1, p2);
}
VB.NET Copy Code
Using p1 As New Password(TEST_PASSWORD)
    Using sstr As SecureString = p1.ToSecureString()
        Using p2 As New Password(sstr)
            Assert.AreEqual(p1, p2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Password Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Password Class

Glossary Item Box

For a list of all members of this type, see Password members.

Public Methods

 | Name | Description
Public Method | CreateHash | Overloaded. Returns a salted hash for the password
Public Method | CreateKey | Overloaded. Returns the key generated with the current password and salt (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Public Method | Decrypt | Overloaded. Wraps the stream with a cryptographic stream (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Dispose | Overloaded. Overridden. Removes the memory representation of this password and key
Public Method | Encrypt | Overloaded. Wraps the stream with a cryptographic stream (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Equals | Overloaded. Returns true if the other object is equal to this one
Public Method | GetHashCode | Overloaded. Extracts the correct hash code
Public Method | ReadBytes | Returns a stream from which the password can be read
Public Method | ReadText | Returns a stream from which the password can be read
Public Method | ToSecureString | Returns a System.Security.SecureString from the password
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Top

See Also

Reference

Password Class
CSharpTest.Net.Crypto Namespace
Boolean Password.EqualityComparer.Equals(Password,Password)
Int32 Password.EqualityComparer.GetHashCode(Password)
Boolean PasswordHash.VerifyPassword(Password)

Source Code

Library/Crypto/Password.cs

Used By

Boolean Password.Equals(Object)


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateHash Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : CreateHash Method

Glossary Item Box

Returns a salted hash for the password

Overload List

Overload | Description
CreateHash() | Returns a salted hash for the password
CreateHash(Salt) | Returns a salted hash for the password

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateHash() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > CreateHash Method : CreateHash() Method

Glossary Item Box

Returns a salted hash for the password

Syntax

Visual Basic (Declaration)
Public Overloads Function CreateHash() As PasswordHash
C#
public PasswordHash CreateHash()

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
byte[] pwdBytes = Guid.NewGuid().ToByteArray();

using (Password pwd = new Password(false, pwdBytes))
{
    using (PasswordHash hash = pwd.CreateHash())
        Assert.IsTrue(hash.VerifyPassword(pwdBytes));
    using (PasswordHash hash = new PasswordHash(pwd))
        Assert.IsTrue(hash.VerifyPassword(pwdBytes));
}

using (Password pwd = new Password(false, pwdBytes))
{
    using (PasswordHash hash = new PasswordHash(false, pwdBytes, new Salt()))
        Assert.AreEqual(hash, pwd.CreateHash(hash.Salt));
}
VB.NET Copy Code
Dim pwdBytes As Byte() = Guid.NewGuid().ToByteArray()

Using pwd As New Password(False, pwdBytes)
    Using hash As PasswordHash = pwd.CreateHash()
        Assert.IsTrue(hash.VerifyPassword(pwdBytes))
    End Using
    Using hash As New PasswordHash(pwd)
        Assert.IsTrue(hash.VerifyPassword(pwdBytes))
    End Using
End Using

Using pwd As New Password(False, pwdBytes)
    Using hash As New PasswordHash(False, pwdBytes, New Salt())
        Assert.AreEqual(hash, pwd.CreateHash(hash.Salt))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List
PasswordHash

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateHash(Salt) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > CreateHash Method : CreateHash(Salt) Method

salt

Glossary Item Box

Returns a salted hash for the password

Syntax

Visual Basic (Declaration)
Public Overloads Function CreateHash( _
   ByVal salt As Salt _
) As PasswordHash
C#
public PasswordHash CreateHash(
   Salt salt
)

Parameters

salt

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
byte[] pwdBytes = Guid.NewGuid().ToByteArray();

using (Password pwd = new Password(false, pwdBytes))
{
    using (PasswordHash hash = pwd.CreateHash())
        Assert.IsTrue(hash.VerifyPassword(pwdBytes));
    using (PasswordHash hash = new PasswordHash(pwd))
        Assert.IsTrue(hash.VerifyPassword(pwdBytes));
}

using (Password pwd = new Password(false, pwdBytes))
{
    using (PasswordHash hash = new PasswordHash(false, pwdBytes, new Salt()))
        Assert.AreEqual(hash, pwd.CreateHash(hash.Salt));
}
VB.NET Copy Code
Dim pwdBytes As Byte() = Guid.NewGuid().ToByteArray()

Using pwd As New Password(False, pwdBytes)
    Using hash As PasswordHash = pwd.CreateHash()
        Assert.IsTrue(hash.VerifyPassword(pwdBytes))
    End Using
    Using hash As New PasswordHash(pwd)
        Assert.IsTrue(hash.VerifyPassword(pwdBytes))
    End Using
End Using

Using pwd As New Password(False, pwdBytes)
    Using hash As New PasswordHash(False, pwdBytes, New Salt())
        Assert.AreEqual(hash, pwd.CreateHash(hash.Salt))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List
Salt
PasswordHash

Used By

PasswordHash Password.CreateHash()
Boolean PasswordHash.VerifyPassword(Password)

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : Dispose Method

Glossary Item Box

Removes the memory representation of this password and key

Overload List

Overload | Description
Dispose(Boolean) | Removes the memory representation of this password and key
Dispose() | Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Removes the memory representation of this password and key

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : Equals Method

Glossary Item Box

Returns true if the other object is equal to this one

Overload List

Overload | Description
Equals(Object) | Returns true if the other object is equal to this one
Equals(Password) | Returns true if the other object is equal to this one
Equals(Password,Password) | Compares the two objects for non-reference equality

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Base Implementation in Equals


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Equals Method : Equals(Object) Method

obj

Glossary Item Box

Returns true if the other object is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Equals( _
   ByVal obj As Object _
) As Boolean
C#
public override bool Equals(
   object obj
)

Parameters

obj

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List
Base Implementation in Equals(Object)

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Password) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Equals Method : Equals(Password) Method

other

Glossary Item Box

Returns true if the other object is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Function Equals( _
   ByVal other As Password _
) As Boolean
C#
public bool Equals(
   Password other
)

Parameters

other

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
using (Password pwd1 = new Password(TEST_PASSWORD))
{
    using (Password pwd2 = new Password(TEST_PASSWORD))
    {
        Assert.AreEqual(pwd1, pwd2);
        Assert.IsTrue(Password.Equals(pwd1, pwd2));
        Assert.IsTrue(pwd1 == pwd2);
        Assert.IsFalse(pwd1 != pwd2);
        Assert.IsTrue(pwd1.Equals(pwd2));
        Assert.IsTrue(pwd1.Equals((object)pwd2));
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
    }

    Assert.IsFalse(pwd1 == new Password("Not the same"));
    Assert.IsFalse(pwd1 == null);
    Assert.IsFalse(null == pwd1);
    Assert.IsFalse(pwd1.Equals(null));

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1));
}
VB.NET Copy Code
Using pwd1 As New Password(TEST_PASSWORD)
    Using pwd2 As New Password(TEST_PASSWORD)
        Assert.AreEqual(pwd1, pwd2)
        Assert.IsTrue(Password.Equals(pwd1, pwd2))
        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsFalse(pwd1 <> pwd2)
        Assert.IsTrue(pwd1.Equals(pwd2))
        Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
    End Using

    Assert.IsFalse(pwd1 = New Password("Not the same"))
    Assert.IsFalse(pwd1 = Nothing)
    Assert.IsFalse(Nothing = pwd1)
    Assert.IsFalse(pwd1.Equals(Nothing))

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List

Source Code

Library/Crypto/Password.cs

Used By

Boolean Password.EqualityComparer.Equals(Password,Password)


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Password,Password) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Equals Method : Equals(Password,Password) Method

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Equals( _
   ByVal x As Password, _
   ByVal y As Password _
) As Boolean
C#
public static bool Equals(
   Password x,
   Password y
)

Parameters

x
y

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
using (Password pwd1 = new Password(TEST_PASSWORD))
{
    using (Password pwd2 = new Password(TEST_PASSWORD))
    {
        Assert.AreEqual(pwd1, pwd2);
        Assert.IsTrue(Password.Equals(pwd1, pwd2));
        Assert.IsTrue(pwd1 == pwd2);
        Assert.IsFalse(pwd1 != pwd2);
        Assert.IsTrue(pwd1.Equals(pwd2));
        Assert.IsTrue(pwd1.Equals((object)pwd2));
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
    }

    Assert.IsFalse(pwd1 == new Password("Not the same"));
    Assert.IsFalse(pwd1 == null);
    Assert.IsFalse(null == pwd1);
    Assert.IsFalse(pwd1.Equals(null));

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1));
}
VB.NET Copy Code
Using pwd1 As New Password(TEST_PASSWORD)
    Using pwd2 As New Password(TEST_PASSWORD)
        Assert.AreEqual(pwd1, pwd2)
        Assert.IsTrue(Password.Equals(pwd1, pwd2))
        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsFalse(pwd1 <> pwd2)
        Assert.IsTrue(pwd1.Equals(pwd2))
        Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
    End Using

    Assert.IsFalse(pwd1 = New Password("Not the same"))
    Assert.IsFalse(pwd1 = Nothing)
    Assert.IsFalse(Nothing = pwd1)
    Assert.IsFalse(pwd1.Equals(Nothing))

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : GetHashCode Method

Glossary Item Box

Extracts the correct hash code

Overload List

Overload | Description
GetHashCode() | Extracts the correct hash code
GetHashCode(Password) | Compares the two objects for non-reference equality

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Base Implementation in GetHashCode


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > GetHashCode Method : GetHashCode() Method

Glossary Item Box

Extracts the correct hash code

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function GetHashCode() As Integer
C#
public override int GetHashCode()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List
Base Implementation in GetHashCode

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode(Password) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > GetHashCode Method : GetHashCode(Password) Method

obj

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function GetHashCode( _
   ByVal obj As Password _
) As Integer
C#
public static int GetHashCode(
   Password obj
)

Parameters

obj

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
using (Password pwd1 = new Password(TEST_PASSWORD))
{
    using (Password pwd2 = new Password(TEST_PASSWORD))
    {
        Assert.AreEqual(pwd1, pwd2);
        Assert.IsTrue(Password.Equals(pwd1, pwd2));
        Assert.IsTrue(pwd1 == pwd2);
        Assert.IsFalse(pwd1 != pwd2);
        Assert.IsTrue(pwd1.Equals(pwd2));
        Assert.IsTrue(pwd1.Equals((object)pwd2));
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
    }

    Assert.IsFalse(pwd1 == new Password("Not the same"));
    Assert.IsFalse(pwd1 == null);
    Assert.IsFalse(null == pwd1);
    Assert.IsFalse(pwd1.Equals(null));

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1));
}
VB.NET Copy Code
Using pwd1 As New Password(TEST_PASSWORD)
    Using pwd2 As New Password(TEST_PASSWORD)
        Assert.AreEqual(pwd1, pwd2)
        Assert.IsTrue(Password.Equals(pwd1, pwd2))
        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsFalse(pwd1 <> pwd2)
        Assert.IsTrue(pwd1.Equals(pwd2))
        Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
    End Using

    Assert.IsFalse(pwd1 = New Password("Not the same"))
    Assert.IsFalse(pwd1 = Nothing)
    Assert.IsFalse(Nothing = pwd1)
    Assert.IsFalse(pwd1.Equals(Nothing))

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members
Overload List

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : ReadBytes Method

Glossary Item Box

Returns a stream from which the password can be read

Syntax

Visual Basic (Declaration)
Public Function ReadBytes() As Stream
C#
public Stream ReadBytes()

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
const int count = 1000;
Random rand = new Random();
byte[] bytes = new byte[100];
rand.NextBytes(bytes);
Stopwatch time = new Stopwatch();
time.Start();

for (int i = 0; i < count; i++)
{
    bytes = new byte[rand.Next(450) + 50];
    rand.NextBytes(bytes);
    using (Password pwd = new Password(false, bytes))
    {
        byte[] copy = IOStream.ReadAllBytes(pwd.ReadBytes());
        Assert.AreEqual(bytes, copy);
    }
}
time.Stop();
Trace.WriteLine(time.Elapsed.ToString(), count.ToString() + " Passwords");
VB.NET Copy Code
Const  count As Integer = 1000
Dim rand As New Random()
Dim bytes As Byte() = New Byte(100) {}
rand.NextBytes(bytes)
Dim time As New Stopwatch()
time.Start()

Dim i As Integer = 0
While i < count
    bytes = New Byte(rand.[Next](450) + 50) {}
    rand.NextBytes(bytes)
    Using pwd As New Password(False, bytes)
        Dim copy As Byte() = IOStream.ReadAllBytes(pwd.ReadBytes())
        Assert.AreEqual(bytes, copy)
    End Using
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
time.[Stop]()
Trace.WriteLine(time.Elapsed.ToString(), count.ToString() + " Passwords")

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members

Source Code

Library/Crypto/Password.cs

Used By

TextReader Password.ReadText()
SecureString Password.ToSecureString()
Boolean Password.Equals(Password)
Int32 Password.GetHashCode()


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadText Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : ReadText Method

Glossary Item Box

Returns a stream from which the password can be read

Syntax

Visual Basic (Declaration)
Public Function ReadText() As TextReader
C#
public TextReader ReadText()

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
byte[] pwdBytes = Guid.NewGuid().ToByteArray();

using (Password pwd = new Password(false, pwdBytes))
{
    Assert.AreEqual(pwdBytes, IOStream.ReadAllBytes(pwd.ReadBytes()));
}
using (Password pwd = new Password(TEST_PASSWORD))
{
    Assert.AreEqual(TEST_PASSWORD, pwd.ReadText().ReadToEnd());
}
VB.NET Copy Code
Dim pwdBytes As Byte() = Guid.NewGuid().ToByteArray()

Using pwd As New Password(False, pwdBytes)
    Assert.AreEqual(pwdBytes, IOStream.ReadAllBytes(pwd.ReadBytes()))
End Using
Using pwd As New Password(TEST_PASSWORD)
    Assert.AreEqual(TEST_PASSWORD, pwd.ReadText().ReadToEnd())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToSecureString Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : ToSecureString Method

Glossary Item Box

Returns a System.Security.SecureString from the password

Syntax

Visual Basic (Declaration)
Public Function ToSecureString() As SecureString
C#
public SecureString ToSecureString()

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
using (Password p1 = new Password(TEST_PASSWORD))
using (SecureString sstr = p1.ToSecureString())
using (Password p2 = new Password(sstr))
{
    Assert.AreEqual(p1, p2);
}
VB.NET Copy Code
Using p1 As New Password(TEST_PASSWORD)
    Using sstr As SecureString = p1.ToSecureString()
        Using p2 As New Password(sstr)
            Assert.AreEqual(p1, p2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Password Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Password Class

Glossary Item Box

For a list of all members of this type, see Password members.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | Encoding | Returns the encoding used for passwords
Public Property | IterationCount | Sets or Gets the iterations used with deriving the encryption key (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Public Property | IV | Sets or Gets the IV used when deriving the encryption key (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Public Property | Salt | Sets or Gets the salt used with deriving the encryption key (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Top

Protected Properties

 | Name | Description
Protected Property | DerivedBytes | Returns the derived bytes algorithm for this instance or throws ObjectDisposedException (Inherited from CSharpTest.Net.Crypto.PasswordKey)
Protected Property | Passkey | Allows overriding the encryption/decryption support for the in-memory password
Top

See Also

Reference

Password Class
CSharpTest.Net.Crypto Namespace
Boolean Password.EqualityComparer.Equals(Password,Password)
Int32 Password.EqualityComparer.GetHashCode(Password)
Boolean PasswordHash.VerifyPassword(Password)

Source Code

Library/Crypto/Password.cs

Used By

Boolean Password.Equals(Object)


%%PageItemTitle%%

[image]
CSharpTest.Net
Encoding Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : Encoding Property

Glossary Item Box

Returns the encoding used for passwords

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Encoding As Encoding
C#
public static Encoding Encoding {get;}

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members

Used By

TextReader Password.ReadText()
SecureString Password.ToSecureString()
Boolean PasswordHash.VerifyPassword(String)

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Passkey Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : Passkey Property

Glossary Item Box

Allows overriding the encryption/decryption support for the in-memory password

Syntax

Visual Basic (Declaration)
Protected Overridable ReadOnly Property Passkey As IEncryptDecrypt
C#
protected virtual IEncryptDecrypt Passkey {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
Password Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Password Class

Glossary Item Box

For a list of all members of this type, see Password members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | return a non-reference equality comparer for this class
Top

See Also

Reference

Password Class
CSharpTest.Net.Crypto Namespace
Boolean Password.EqualityComparer.Equals(Password,Password)
Int32 Password.EqualityComparer.GetHashCode(Password)
Boolean PasswordHash.VerifyPassword(Password)

Source Code

Library/Crypto/Password.cs

Used By

Boolean Password.Equals(Object)


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : Comparer Field

Glossary Item Box

return a non-reference equality comparer for this class

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Comparer As Password.EqualityComparer
C#
public static readonly Password.EqualityComparer Comparer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members

Used By

Boolean Password.Equals(Object)
Boolean Password.Equals(Password,Password)
Int32 Password.GetHashCode(Password)

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : Equality Operator

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Operator =( _
   ByVal x As Password, _
   ByVal y As Password _
) As Boolean
C#
public bool operator ==(
   Password x,
   Password y
)

Parameters

x
y

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
using (Password pwd1 = new Password(TEST_PASSWORD))
{
    using (Password pwd2 = new Password(TEST_PASSWORD))
    {
        Assert.AreEqual(pwd1, pwd2);
        Assert.IsTrue(Password.Equals(pwd1, pwd2));
        Assert.IsTrue(pwd1 == pwd2);
        Assert.IsFalse(pwd1 != pwd2);
        Assert.IsTrue(pwd1.Equals(pwd2));
        Assert.IsTrue(pwd1.Equals((object)pwd2));
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
    }

    Assert.IsFalse(pwd1 == new Password("Not the same"));
    Assert.IsFalse(pwd1 == null);
    Assert.IsFalse(null == pwd1);
    Assert.IsFalse(pwd1.Equals(null));

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1));
}
VB.NET Copy Code
Using pwd1 As New Password(TEST_PASSWORD)
    Using pwd2 As New Password(TEST_PASSWORD)
        Assert.AreEqual(pwd1, pwd2)
        Assert.IsTrue(Password.Equals(pwd1, pwd2))
        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsFalse(pwd1 <> pwd2)
        Assert.IsTrue(pwd1.Equals(pwd2))
        Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
    End Using

    Assert.IsFalse(pwd1 = New Password("Not the same"))
    Assert.IsFalse(pwd1 = Nothing)
    Assert.IsFalse(Nothing = pwd1)
    Assert.IsFalse(pwd1.Equals(Nothing))

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class : Inequality Operator

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Operator <>( _
   ByVal x As Password, _
   ByVal y As Password _
) As Boolean
C#
public bool operator !=(
   Password x,
   Password y
)

Parameters

x
y

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
using (Password pwd1 = new Password(TEST_PASSWORD))
{
    using (Password pwd2 = new Password(TEST_PASSWORD))
    {
        Assert.AreEqual(pwd1, pwd2);
        Assert.IsTrue(Password.Equals(pwd1, pwd2));
        Assert.IsTrue(pwd1 == pwd2);
        Assert.IsFalse(pwd1 != pwd2);
        Assert.IsTrue(pwd1.Equals(pwd2));
        Assert.IsTrue(pwd1.Equals((object)pwd2));
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
    }

    Assert.IsFalse(pwd1 == new Password("Not the same"));
    Assert.IsFalse(pwd1 == null);
    Assert.IsFalse(null == pwd1);
    Assert.IsFalse(pwd1.Equals(null));

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1));
}
VB.NET Copy Code
Using pwd1 As New Password(TEST_PASSWORD)
    Using pwd2 As New Password(TEST_PASSWORD)
        Assert.AreEqual(pwd1, pwd2)
        Assert.IsTrue(Password.Equals(pwd1, pwd2))
        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsFalse(pwd1 <> pwd2)
        Assert.IsTrue(pwd1.Equals(pwd2))
        Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
    End Using

    Assert.IsFalse(pwd1 = New Password("Not the same"))
    Assert.IsFalse(pwd1 = Nothing)
    Assert.IsFalse(Nothing = pwd1)
    Assert.IsFalse(pwd1.Equals(Nothing))

    Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password Class
Password Members

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Password.EqualityComparer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Password.EqualityComparer Class

Glossary Item Box

Implements the equality comparer

Syntax

Visual Basic (Declaration)
Public NotInheritable Class Password.EqualityComparer
   Inherits System.Collections.Generic.EqualityComparer(Of Password)
C#
public sealed class Password.EqualityComparer : System.Collections.Generic.EqualityComparer<Password>

Inheritance Hierarchy

System.Object
System.Collections.Generic.EqualityComparer<T>
CSharpTest.Net.Crypto.Password.EqualityComparer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password.EqualityComparer Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Password.EqualityComparer Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Password.EqualityComparer Class

Glossary Item Box

The following tables list the members exposed by Password.EqualityComparer.

Public Constructors

 | Name | Description
Public Constructor | Password.EqualityComparer Constructor |
Top

Public Methods

 | Name | Description
Public Method | Equals | Overloaded. Overridden. Compares the two objects for non-reference equality
Public Method | GetHashCode | Overloaded. Overridden. Extracts the correct hash code
Top

See Also

Reference

Password.EqualityComparer Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Password.EqualityComparer Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password.EqualityComparer Class : Password.EqualityComparer Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public Password.EqualityComparer()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password.EqualityComparer Class
Password.EqualityComparer Members

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Password.EqualityComparer Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Password.EqualityComparer Class

Glossary Item Box

For a list of all members of this type, see Password.EqualityComparer members.

Public Methods

 | Name | Description
Public Method | Equals | Overloaded. Overridden. Compares the two objects for non-reference equality
Public Method | GetHashCode | Overloaded. Overridden. Extracts the correct hash code
Top

See Also

Reference

Password.EqualityComparer Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password.EqualityComparer Class : Equals Method

Glossary Item Box

Compares the two objects for non-reference equality

Overload List

Overload | Description
Equals(Password,Password) | Compares the two objects for non-reference equality

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password.EqualityComparer Class
Password.EqualityComparer Members
Base Implementation in Equals


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Password,Password) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password.EqualityComparer Class > Equals Method : Equals(Password,Password) Method

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Overloads Overrides NotOverridable Function Equals( _
   ByVal x As Password, _
   ByVal y As Password _
) As Boolean
C#
public override bool Equals(
   Password x,
   Password y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password.EqualityComparer Class
Password.EqualityComparer Members
Overload List
Password

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password.EqualityComparer Class : GetHashCode Method

Glossary Item Box

Extracts the correct hash code

Overload List

Overload | Description
GetHashCode(Password) | Extracts the correct hash code

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password.EqualityComparer Class
Password.EqualityComparer Members
Base Implementation in GetHashCode


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode(Password) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password.EqualityComparer Class > GetHashCode Method : GetHashCode(Password) Method

obj

Glossary Item Box

Extracts the correct hash code

Syntax

Visual Basic (Declaration)
Public Overloads Overrides NotOverridable Function GetHashCode( _
   ByVal obj As Password _
) As Integer
C#
public override int GetHashCode(
   Password obj
)

Parameters

obj

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Password.EqualityComparer Class
Password.EqualityComparer Members
Overload List
Password

Source Code

Library/Crypto/Password.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordHash Class

Glossary Item Box

Creates a salted hash

Object Model

PasswordHash ClassSalt Class

Syntax

Visual Basic (Declaration)
Public NotInheritable Class PasswordHash
   Inherits CSharpTest.Net.Bases.Comparable(Of PasswordHash)
C#
public sealed class PasswordHash : CSharpTest.Net.Bases.Comparable<PasswordHash>

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Equatable<T>
CSharpTest.Net.Bases.Comparable<T>
CSharpTest.Net.Crypto.PasswordHash

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Members
CSharpTest.Net.Crypto Namespace
PasswordHash Password.CreateHash()
PasswordHash Password.CreateHash(Salt)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PasswordHash Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordHash Class

Glossary Item Box

The following tables list the members exposed by PasswordHash.

Public Constructors

 | Name | Description
Public Constructor | PasswordHash Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | StandardIterations | Defines the derived hash iteration count used
Top

Public Properties

 | Name | Description
Public Property | Length | returns the salted-hash length in bytes
Public Property | Salt | returns the salt used to create this hash
Top

Protected Properties

 | Name | Description
Protected Property | HashCode | Overridden. Gets the hash
Top

Public Methods

 | Name | Description
Public Method | CompareTo | Overridden. Compares the hash
Public Method | Dispose | Disposes of hash bytes
Public Method | Equals | Overloaded. Determines whether the specified System.Object is equal to the current System.Object. (Inherited from CSharpTest.Net.Bases.Equatable<PasswordHash>)
static (Shared in Visual Basic) | FromBytes | recreates a hash from the bytes returned by ToArray()
static (Shared in Visual Basic) | FromString | recreates a hash from a base-64 encoded string
Public Method | ToArray | returns the salted-hash bytes
Public Method | ToString | Returns the hash as a base-64 encoded string
Public Method | VerifyPassword | Overloaded. Returns true if the provided password matches this hash
Top

See Also

Reference

PasswordHash Class
CSharpTest.Net.Crypto Namespace
PasswordHash Password.CreateHash()
PasswordHash Password.CreateHash(Salt)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : PasswordHash Constructor

Glossary Item Box

Overload List

Overload | Description
PasswordHash Constructor(Stream,Salt) | Creates a salted hash from the given bytes and salt
PasswordHash Constructor(Password) | Creates a salted hash from the given password
PasswordHash Constructor(Password,Salt) | Creates a salted hash from the given password and salt
PasswordHash Constructor(Boolean,Byte[],Salt) | Creates the hash from the given bytes and salt
PasswordHash Constructor(Boolean,Byte[]) | Creates the hash from the given bytes
PasswordHash Constructor(String,Salt) | Creates the hash from the given data and salt
PasswordHash Constructor(String) | Creates the hash from the given data and salt
PasswordHash Constructor(SecureString,Salt) | Creates the hash from the given data and salt
PasswordHash Constructor(SecureString) | Creates the hash from the given data and salt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(Stream,Salt)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(Stream,Salt)

bytes
salt

Glossary Item Box

Creates a salted hash from the given bytes and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bytes As Stream, _
   ByVal salt As Salt _
)
C#
public PasswordHash(
   Stream bytes,
   Salt salt
)

Parameters

bytes
salt

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Used By

Boolean PasswordHash.VerifyPassword(Stream)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(Password)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(Password)

bytes

Glossary Item Box

Creates a salted hash from the given password

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bytes As Password _
)
C#
public PasswordHash(
   Password bytes
)

Parameters

bytes

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
byte[] pwdBytes = Guid.NewGuid().ToByteArray();

using (Password pwd = new Password(false, pwdBytes))
{
    using (PasswordHash hash = pwd.CreateHash())
        Assert.IsTrue(hash.VerifyPassword(pwdBytes));
    using (PasswordHash hash = new PasswordHash(pwd))
        Assert.IsTrue(hash.VerifyPassword(pwdBytes));
}

using (Password pwd = new Password(false, pwdBytes))
{
    using (PasswordHash hash = new PasswordHash(false, pwdBytes, new Salt()))
        Assert.AreEqual(hash, pwd.CreateHash(hash.Salt));
}
VB.NET Copy Code
Dim pwdBytes As Byte() = Guid.NewGuid().ToByteArray()

Using pwd As New Password(False, pwdBytes)
    Using hash As PasswordHash = pwd.CreateHash()
        Assert.IsTrue(hash.VerifyPassword(pwdBytes))
    End Using
    Using hash As New PasswordHash(pwd)
        Assert.IsTrue(hash.VerifyPassword(pwdBytes))
    End Using
End Using

Using pwd As New Password(False, pwdBytes)
    Using hash As New PasswordHash(False, pwdBytes, New Salt())
        Assert.AreEqual(hash, pwd.CreateHash(hash.Salt))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(Password,Salt)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(Password,Salt)

bytes
salt

Glossary Item Box

Creates a salted hash from the given password and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bytes As Password, _
   ByVal salt As Salt _
)
C#
public PasswordHash(
   Password bytes,
   Salt salt
)

Parameters

bytes
salt

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Used By

PasswordHash Password.CreateHash(Salt)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(Boolean,Byte[],Salt)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(Boolean,Byte[],Salt)

clear
bytes
salt

Glossary Item Box

Creates the hash from the given bytes and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal clear As Boolean, _
   ByVal bytes() As Byte, _
   ByVal salt As Salt _
)
C#
public PasswordHash(
   bool clear,
   byte[] bytes,
   Salt salt
)

Parameters

clear
bytes
salt

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(Boolean,Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(Boolean,Byte[])

clear
bytes

Glossary Item Box

Creates the hash from the given bytes

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal clear As Boolean, _
   ByVal bytes() As Byte _
)
C#
public PasswordHash(
   bool clear,
   byte[] bytes
)

Parameters

clear
bytes

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(String,Salt)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(String,Salt)

data
salt

Glossary Item Box

Creates the hash from the given data and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal data As String, _
   ByVal salt As Salt _
)
C#
public PasswordHash(
   string data,
   Salt salt
)

Parameters

data
salt

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(String)

data

Glossary Item Box

Creates the hash from the given data and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal data As String _
)
C#
public PasswordHash(
   string data
)

Parameters

data

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(SecureString,Salt)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(SecureString,Salt)

data
salt

Glossary Item Box

Creates the hash from the given data and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal data As SecureString, _
   ByVal salt As Salt _
)
C#
public PasswordHash(
   SecureString data,
   Salt salt
)

Parameters

data
salt

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordHash Constructor(SecureString)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(SecureString)

data

Glossary Item Box

Creates the hash from the given data and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal data As SecureString _
)
C#
public PasswordHash(
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
PasswordHash Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordHash Class

Glossary Item Box

For a list of all members of this type, see PasswordHash members.

Public Methods

 | Name | Description
Public Method | CompareTo | Overridden. Compares the hash
Public Method | Dispose | Disposes of hash bytes
Public Method | Equals | Overloaded. Determines whether the specified System.Object is equal to the current System.Object. (Inherited from CSharpTest.Net.Bases.Equatable<PasswordHash>)
static (Shared in Visual Basic) | FromBytes | recreates a hash from the bytes returned by ToArray()
static (Shared in Visual Basic) | FromString | recreates a hash from a base-64 encoded string
Public Method | ToArray | returns the salted-hash bytes
Public Method | ToString | Returns the hash as a base-64 encoded string
Public Method | VerifyPassword | Overloaded. Returns true if the provided password matches this hash
Top

See Also

Reference

PasswordHash Class
CSharpTest.Net.Crypto Namespace
PasswordHash Password.CreateHash()
PasswordHash Password.CreateHash(Salt)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CompareTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : CompareTo Method

other

Glossary Item Box

Compares the hash

Syntax

Visual Basic (Declaration)
Public Overrides NotOverridable Function CompareTo( _
   ByVal other As PasswordHash _
) As Integer
C#
public override int CompareTo(
   PasswordHash other
)

Parameters

other

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Base Implementation in CompareTo

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : Dispose Method

Glossary Item Box

Disposes of hash bytes

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : FromBytes Method

hash

Glossary Item Box

recreates a hash from the bytes returned by ToArray()

Syntax

Visual Basic (Declaration)
Public Shared Function FromBytes( _
   ByVal hash() As Byte _
) As PasswordHash
C#
public static PasswordHash FromBytes(
   byte[] hash
)

Parameters

hash

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
using (PasswordHash pwd2 = PasswordHash.FromBytes(pwd1.ToArray()))
{
    Assert.AreEqual(pwd1, pwd2);
    Assert.AreEqual((256 / 8) + pwd1.Salt.Length, pwd2.Length);
    Assert.AreEqual(pwd1.Length, pwd2.Length);
    Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray());
    Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray());
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Using pwd2 As PasswordHash = PasswordHash.FromBytes(pwd1.ToArray())
        Assert.AreEqual(pwd1, pwd2)
        Assert.AreEqual((256 / 8) + pwd1.Salt.Length, pwd2.Length)
        Assert.AreEqual(pwd1.Length, pwd2.Length)
        Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray())
        Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray())
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members

Used By

PasswordHash PasswordHash.FromString(String)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromString Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : FromString Method

hash

Glossary Item Box

recreates a hash from a base-64 encoded string

Syntax

Visual Basic (Declaration)
Public Shared Function FromString( _
   ByVal hash As String _
) As PasswordHash
C#
public static PasswordHash FromString(
   string hash
)

Parameters

hash

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
using (PasswordHash pwd2 = PasswordHash.FromString(pwd1.ToString()))
{
    Assert.AreEqual(pwd1, pwd2);
    Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray());
    Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray());
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Using pwd2 As PasswordHash = PasswordHash.FromString(pwd1.ToString())
        Assert.AreEqual(pwd1, pwd2)
        Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray())
        Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray())
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : ToArray Method

Glossary Item Box

returns the salted-hash bytes

Syntax

Visual Basic (Declaration)
Public Function ToArray() As Byte()
C#
public byte[] ToArray()

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
{
    Assert.AreEqual(pwd1, pwd2);
    Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray());
    Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray());

    Assert.IsTrue(pwd1 == pwd2);
    Assert.IsTrue(pwd1 == pwd2);
    Assert.IsFalse(pwd1 != pwd2);
    Assert.IsTrue(pwd1.Equals(pwd2));
    Assert.IsTrue(pwd1.Equals((object)pwd2));
    Assert.AreEqual(0, pwd1.CompareTo(pwd2));
    Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
    Assert.AreEqual(pwd1.ToString(), pwd2.ToString());

    PasswordHash nil = null;
    Assert.IsFalse(pwd1 < nil);
    Assert.IsTrue(pwd1 > nil);
    Assert.AreEqual(1, pwd1.CompareTo(null));
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
        Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray())
        Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray())

        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsTrue(pwd1 = pwd2)
        Assert.IsFalse(pwd1 <> pwd2)
        Assert.IsTrue(pwd1.Equals(pwd2))
        Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
        Assert.AreEqual(0, pwd1.CompareTo(pwd2))
        Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
        Assert.AreEqual(pwd1.ToString(), pwd2.ToString())

        Dim nil As PasswordHash = Nothing
        Assert.IsFalse(pwd1 < nil)
        Assert.IsTrue(pwd1 > nil)
        Assert.AreEqual(1, pwd1.CompareTo(Nothing))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : ToString Method

Glossary Item Box

Returns the hash as a base-64 encoded string

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Base Implementation in ToString

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
VerifyPassword Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : VerifyPassword Method

Glossary Item Box

Returns true if the provided password matches this hash

Overload List

Overload | Description
VerifyPassword(Password) | Returns true if the provided password matches this hash
VerifyPassword(Stream) | Returns true if the provided password matches this hash
VerifyPassword(Byte[]) | Returns true if the provided password matches this hash
VerifyPassword(String) | Returns true if the provided password matches this hash

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members


%%PageItemTitle%%

[image]
CSharpTest.Net
VerifyPassword(Password) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > VerifyPassword Method : VerifyPassword(Password) Method

password

Glossary Item Box

Returns true if the provided password matches this hash

Syntax

Visual Basic (Declaration)
Public Overloads Function VerifyPassword( _
   ByVal password As Password _
) As Boolean
C#
public bool VerifyPassword(
   Password password
)

Parameters

password

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "));
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length-1)));
    Assert.IsFalse(pwd1.VerifyPassword(""));

    Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD));
    Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)));
    Assert.IsTrue(pwd1.VerifyPassword(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))));
    Assert.IsTrue(pwd1.VerifyPassword(new Password(TEST_PASSWORD)));
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "))
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length - 1)))
    Assert.IsFalse(pwd1.VerifyPassword(""))

    Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD))
    Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)))
    Assert.IsTrue(pwd1.VerifyPassword(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))))
    Assert.IsTrue(pwd1.VerifyPassword(New Password(TEST_PASSWORD)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List
Password

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
VerifyPassword(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > VerifyPassword Method : VerifyPassword(Stream) Method

password

Glossary Item Box

Returns true if the provided password matches this hash

Syntax

Visual Basic (Declaration)
Public Overloads Function VerifyPassword( _
   ByVal password As Stream _
) As Boolean
C#
public bool VerifyPassword(
   Stream password
)

Parameters

password

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "));
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length-1)));
    Assert.IsFalse(pwd1.VerifyPassword(""));

    Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD));
    Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)));
    Assert.IsTrue(pwd1.VerifyPassword(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))));
    Assert.IsTrue(pwd1.VerifyPassword(new Password(TEST_PASSWORD)));
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "))
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length - 1)))
    Assert.IsFalse(pwd1.VerifyPassword(""))

    Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD))
    Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)))
    Assert.IsTrue(pwd1.VerifyPassword(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))))
    Assert.IsTrue(pwd1.VerifyPassword(New Password(TEST_PASSWORD)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs

Used By

Boolean PasswordHash.VerifyPassword(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
VerifyPassword(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > VerifyPassword Method : VerifyPassword(Byte[]) Method

password

Glossary Item Box

Returns true if the provided password matches this hash

Syntax

Visual Basic (Declaration)
Public Overloads Function VerifyPassword( _
   ByVal password() As Byte _
) As Boolean
C#
public bool VerifyPassword(
   byte[] password
)

Parameters

password

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "));
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length-1)));
    Assert.IsFalse(pwd1.VerifyPassword(""));

    Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD));
    Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)));
    Assert.IsTrue(pwd1.VerifyPassword(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))));
    Assert.IsTrue(pwd1.VerifyPassword(new Password(TEST_PASSWORD)));
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "))
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length - 1)))
    Assert.IsFalse(pwd1.VerifyPassword(""))

    Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD))
    Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)))
    Assert.IsTrue(pwd1.VerifyPassword(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))))
    Assert.IsTrue(pwd1.VerifyPassword(New Password(TEST_PASSWORD)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs

Used By

Boolean PasswordHash.VerifyPassword(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
VerifyPassword(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > VerifyPassword Method : VerifyPassword(String) Method

password

Glossary Item Box

Returns true if the provided password matches this hash

Syntax

Visual Basic (Declaration)
Public Overloads Function VerifyPassword( _
   ByVal password As String _
) As Boolean
C#
public bool VerifyPassword(
   string password
)

Parameters

password

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "));
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length-1)));
    Assert.IsFalse(pwd1.VerifyPassword(""));

    Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD));
    Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)));
    Assert.IsTrue(pwd1.VerifyPassword(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))));
    Assert.IsTrue(pwd1.VerifyPassword(new Password(TEST_PASSWORD)));
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "))
    Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length - 1)))
    Assert.IsFalse(pwd1.VerifyPassword(""))

    Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD))
    Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)))
    Assert.IsTrue(pwd1.VerifyPassword(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))))
    Assert.IsTrue(pwd1.VerifyPassword(New Password(TEST_PASSWORD)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Overload List

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
PasswordHash Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordHash Class

Glossary Item Box

For a list of all members of this type, see PasswordHash members.

Public Properties

 | Name | Description
Public Property | Length | returns the salted-hash length in bytes
Public Property | Salt | returns the salt used to create this hash
Top

Protected Properties

 | Name | Description
Protected Property | HashCode | Overridden. Gets the hash
Top

See Also

Reference

PasswordHash Class
CSharpTest.Net.Crypto Namespace
PasswordHash Password.CreateHash()
PasswordHash Password.CreateHash(Salt)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashCode Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : HashCode Property

Glossary Item Box

Gets the hash

Syntax

Visual Basic (Declaration)
Protected Overrides NotOverridable ReadOnly Property HashCode As Integer
C#
protected override int HashCode {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Base Implementation in HashCode


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : Length Property

Glossary Item Box

returns the salted-hash length in bytes

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Length As Integer
C#
public int Length {get;}

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
using (PasswordHash pwd2 = PasswordHash.FromBytes(pwd1.ToArray()))
{
    Assert.AreEqual(pwd1, pwd2);
    Assert.AreEqual((256 / 8) + pwd1.Salt.Length, pwd2.Length);
    Assert.AreEqual(pwd1.Length, pwd2.Length);
    Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray());
    Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray());
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Using pwd2 As PasswordHash = PasswordHash.FromBytes(pwd1.ToArray())
        Assert.AreEqual(pwd1, pwd2)
        Assert.AreEqual((256 / 8) + pwd1.Salt.Length, pwd2.Length)
        Assert.AreEqual(pwd1.Length, pwd2.Length)
        Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray())
        Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray())
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : Salt Property

Glossary Item Box

returns the salt used to create this hash

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Salt As Salt
C#
public Salt Salt {get;}

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members
Salt

Used By

Boolean PasswordHash.VerifyPassword(Password)
Boolean PasswordHash.VerifyPassword(Stream)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
PasswordHash Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordHash Class

Glossary Item Box

For a list of all members of this type, see PasswordHash members.

Public Fields

 | Name | Description
Public Field | StandardIterations | Defines the derived hash iteration count used
Top

See Also

Reference

PasswordHash Class
CSharpTest.Net.Crypto Namespace
PasswordHash Password.CreateHash()
PasswordHash Password.CreateHash(Salt)

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StandardIterations Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : StandardIterations Field

Glossary Item Box

Defines the derived hash iteration count used

Syntax

Visual Basic (Declaration)
Public Const StandardIterations As Integer
C#
public const int StandardIterations

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordHash Class
PasswordHash Members

Source Code

Library/Crypto/PasswordHash.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordKey Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordKey Class

Glossary Item Box

Creates an in-memory object that can be used for salted password encryption without storing the password in memory (based on Rfc2898DeriveBytes, SHA1 hash of password is stored)

Object Model

PasswordKey ClassIPasswordDerivedBytes InterfaceSalt Class

Syntax

Visual Basic (Declaration)
Public Class PasswordKey
   Inherits CryptoKey
   Implements IEncryptDecrypt
C#
public class PasswordKey : CryptoKey, IEncryptDecrypt

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
byte[] bytes;
byte[] svalue = Encoding.ASCII.GetBytes("some text value");

using (PasswordKey pk = new PasswordKey(TEST_PASSWORD))
    bytes = pk.Encrypt(svalue);

using (PasswordKey pk = new PasswordKey(TEST_PASSWORD))
    bytes = pk.Decrypt(bytes);

Assert.AreEqual(svalue, bytes);
VB.NET Copy Code
Dim bytes As Byte()
Dim svalue As Byte() = Encoding.ASCII.GetBytes("some text value")

Using pk As New PasswordKey(TEST_PASSWORD)
    bytes = pk.Encrypt(svalue)
End Using

Using pk As New PasswordKey(TEST_PASSWORD)
    bytes = pk.Decrypt(bytes)
End Using

Assert.AreEqual(svalue, bytes)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.PasswordKey
CSharpTest.Net.Crypto.Password

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PasswordKey Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordKey Class

Glossary Item Box

The following tables list the members exposed by PasswordKey.

Public Constructors

 | Name | Description
Public Constructor | PasswordKey Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | DefaultIterations | Adjusts the number of repetitions used when deriving password bytes
Top

Public Properties

 | Name | Description
Public Property | IterationCount | Sets or Gets the iterations used with deriving the encryption key
Public Property | IV | Sets or Gets the IV used when deriving the encryption key
Public Property | Salt | Sets or Gets the salt used with deriving the encryption key
Top

Protected Properties

 | Name | Description
Protected Property | DerivedBytes | Returns the derived bytes algorithm for this instance or throws ObjectDisposedException
Top

Public Methods

 | Name | Description
Public Method | CreateKey | Overloaded. Returns the key generated with the current password and salt
Public Method | Decrypt | Overloaded. Overridden. Decrypts the stream with the current password and salt
Public Method | Dispose | Overloaded. Overridden. Removes the memory representation of this password and key
Public Method | Encrypt | Overloaded. Overridden. Encrypts the stream with the current password and salt
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Top

See Also

Reference

PasswordKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordKey Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : PasswordKey Constructor

Glossary Item Box

Overload List

Overload | Description
PasswordKey Constructor(IPasswordDerivedBytes,Salt) | Creates the password from the given bytes and salt
PasswordKey Constructor(Boolean,Byte[],Salt) | Creates the password from the given bytes and salt
PasswordKey Constructor(Boolean,Byte[]) | Creates the password from the given password bytes
PasswordKey Constructor(String) | Creates the password from the given password
PasswordKey Constructor(SecureString) | Creates the password from the given password

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordKey Constructor(IPasswordDerivedBytes,Salt)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > PasswordKey Constructor : PasswordKey Constructor(IPasswordDerivedBytes,Salt)

derivedBytes
salt

Glossary Item Box

Creates the password from the given bytes and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal derivedBytes As IPasswordDerivedBytes, _
   ByVal salt As Salt _
)
C#
public PasswordKey(
   IPasswordDerivedBytes derivedBytes,
   Salt salt
)

Parameters

derivedBytes
salt

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
int iter = 100;
Salt salt = new Salt();
byte[] passbytes = Password.Encoding.GetBytes(TEST_PASSWORD);
IPasswordDerivedBytes[] types = new IPasswordDerivedBytes[] {
    new PBKDF2(passbytes, salt, iter),
    new HashDerivedBytes<HMACMD5>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA1>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA256>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA384>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA512>(passbytes, salt, iter),
};

foreach (IPasswordDerivedBytes db in types)
{
    byte[] key;

    Stopwatch w = new Stopwatch();
    w.Start();
    for (int i = 0; i < 100; i++)
        key = new PasswordKey(db, salt).CreateKey().Key;
    w.Stop();

    Console.Error.WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.GetType().Name);
}
VB.NET Copy Code
Dim iter As Integer = 100
Dim salt As New Salt()
Dim passbytes As Byte() = Password.Encoding.GetBytes(TEST_PASSWORD)
Dim types As IPasswordDerivedBytes() = New IPasswordDerivedBytes() {New PBKDF2(passbytes, salt, iter), New HashDerivedBytes(Of HMACMD5)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA1)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA256)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA384)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA512)(passbytes, salt, iter)}

For Each db As IPasswordDerivedBytes In types
    Dim key As Byte()

    Dim w As New Stopwatch()
    w.Start()
    Dim i As Integer = 0
    While i < 100
        key = New PasswordKey(db, salt).CreateKey().Key
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    w.[Stop]()

    Console.[Error].WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.[GetType]().Name)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordKey Constructor(Boolean,Byte[],Salt)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > PasswordKey Constructor : PasswordKey Constructor(Boolean,Byte[],Salt)

clear
bytes
salt

Glossary Item Box

Creates the password from the given bytes and salt

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal clear As Boolean, _
   ByVal bytes() As Byte, _
   ByVal salt As Salt _
)
C#
public PasswordKey(
   bool clear,
   byte[] bytes,
   Salt salt
)

Parameters

clear
bytes
salt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordKey Constructor(Boolean,Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > PasswordKey Constructor : PasswordKey Constructor(Boolean,Byte[])

clear
bytes

Glossary Item Box

Creates the password from the given password bytes

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal clear As Boolean, _
   ByVal bytes() As Byte _
)
C#
public PasswordKey(
   bool clear,
   byte[] bytes
)

Parameters

clear
bytes

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
byte[] password = Encoding.UTF8.GetBytes(TEST_PASSWORD);
PasswordKey pk1 = new PasswordKey(true, password);
Assert.AreEqual(new byte[password.Length], password);

password = Encoding.UTF8.GetBytes(TEST_PASSWORD);
pk1 = new PasswordKey(false, password);
Assert.AreEqual(Encoding.UTF8.GetBytes(TEST_PASSWORD), password);
VB.NET Copy Code
Dim password As Byte() = Encoding.UTF8.GetBytes(TEST_PASSWORD)
Dim pk1 As New PasswordKey(True, password)
Assert.AreEqual(New Byte(password.Length) {}, password)

password = Encoding.UTF8.GetBytes(TEST_PASSWORD)
pk1 = New PasswordKey(False, password)
Assert.AreEqual(Encoding.UTF8.GetBytes(TEST_PASSWORD), password)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordKey Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > PasswordKey Constructor : PasswordKey Constructor(String)

data

Glossary Item Box

Creates the password from the given password

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal data As String _
)
C#
public PasswordKey(
   string data
)

Parameters

data

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
byte[] bytes;
byte[] svalue = Encoding.ASCII.GetBytes("some text value");

using (PasswordKey pk = new PasswordKey(TEST_PASSWORD))
    bytes = pk.Encrypt(svalue);

using (PasswordKey pk = new PasswordKey(TEST_PASSWORD))
    bytes = pk.Decrypt(bytes);

Assert.AreEqual(svalue, bytes);
VB.NET Copy Code
Dim bytes As Byte()
Dim svalue As Byte() = Encoding.ASCII.GetBytes("some text value")

Using pk As New PasswordKey(TEST_PASSWORD)
    bytes = pk.Encrypt(svalue)
End Using

Using pk As New PasswordKey(TEST_PASSWORD)
    bytes = pk.Decrypt(bytes)
End Using

Assert.AreEqual(svalue, bytes)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PasswordKey Constructor(SecureString)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > PasswordKey Constructor : PasswordKey Constructor(SecureString)

data

Glossary Item Box

Creates the password from the given password

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal data As SecureString _
)
C#
public PasswordKey(
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
PasswordKey pk1 = new PasswordKey(TEST_PASSWORD);
PasswordKey pk2 = new PasswordKey(SecureStringUtils.Create(TEST_PASSWORD));
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);

pk2.Salt = pk1.Salt;
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
pk1.CreateKey();
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);

pk1.Salt = new Salt();
Assert.AreNotEqual(pk1.Salt, pk2.Salt);
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey(pk1.Salt).Key);
pk2.Salt = pk1.Salt;
Assert.AreEqual(pk1.Salt, pk2.Salt);
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
VB.NET Copy Code
Dim pk1 As New PasswordKey(TEST_PASSWORD)
Dim pk2 As New PasswordKey(SecureStringUtils.Create(TEST_PASSWORD))
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

pk2.Salt = pk1.Salt
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)
pk1.CreateKey()
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

pk1.Salt = New Salt()
Assert.AreNotEqual(pk1.Salt, pk2.Salt)
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey(pk1.Salt).Key)
pk2.Salt = pk1.Salt
Assert.AreEqual(pk1.Salt, pk2.Salt)
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
PasswordKey Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordKey Class

Glossary Item Box

For a list of all members of this type, see PasswordKey members.

Public Methods

 | Name | Description
Public Method | CreateKey | Overloaded. Returns the key generated with the current password and salt
Public Method | Decrypt | Overloaded. Overridden. Decrypts the stream with the current password and salt
Public Method | Dispose | Overloaded. Overridden. Removes the memory representation of this password and key
Public Method | Encrypt | Overloaded. Overridden. Encrypts the stream with the current password and salt
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Top

See Also

Reference

PasswordKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateKey Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : CreateKey Method

Glossary Item Box

Returns the key generated with the current password and salt

Overload List

Overload | Description
CreateKey() | Returns the key generated with the current password and salt
CreateKey(Salt) | Returns the key generated with the current password and the provided salt
CreateKey(Salt,Byte[]) | Returns the key generated with the current password and the provided salt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateKey() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > CreateKey Method : CreateKey() Method

Glossary Item Box

Returns the key generated with the current password and salt

Syntax

Visual Basic (Declaration)
Public Overloads Function CreateKey() As AESCryptoKey
C#
public AESCryptoKey CreateKey()

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
PasswordKey pk1 = new PasswordKey(TEST_PASSWORD);
PasswordKey pk2 = new PasswordKey(TEST_PASSWORD);
pk2.Salt = pk1.Salt;
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
pk2.IterationCount /= 2;
Assert.AreEqual(pk1.Salt, pk2.Salt);
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
VB.NET Copy Code
Dim pk1 As New PasswordKey(TEST_PASSWORD)
Dim pk2 As New PasswordKey(TEST_PASSWORD)
pk2.Salt = pk1.Salt
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)
pk2.IterationCount /= 2
Assert.AreEqual(pk1.Salt, pk2.Salt)
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
AESCryptoKey

Source Code

Library/Crypto/PasswordKey.cs

Used By

Stream PasswordKey.Encrypt(Stream)
Byte[] PasswordKey.Encrypt(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateKey(Salt) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > CreateKey Method : CreateKey(Salt) Method

salt

Glossary Item Box

Returns the key generated with the current password and the provided salt

Syntax

Visual Basic (Declaration)
Public Overloads Function CreateKey( _
   ByVal salt As Salt _
) As AESCryptoKey
C#
public AESCryptoKey CreateKey(
   Salt salt
)

Parameters

salt

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
PasswordKey pk1 = new PasswordKey(TEST_PASSWORD);
PasswordKey pk2 = new PasswordKey(SecureStringUtils.Create(TEST_PASSWORD));
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);

pk2.Salt = pk1.Salt;
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
pk1.CreateKey();
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);

pk1.Salt = new Salt();
Assert.AreNotEqual(pk1.Salt, pk2.Salt);
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey(pk1.Salt).Key);
pk2.Salt = pk1.Salt;
Assert.AreEqual(pk1.Salt, pk2.Salt);
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
VB.NET Copy Code
Dim pk1 As New PasswordKey(TEST_PASSWORD)
Dim pk2 As New PasswordKey(SecureStringUtils.Create(TEST_PASSWORD))
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

pk2.Salt = pk1.Salt
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)
pk1.CreateKey()
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

pk1.Salt = New Salt()
Assert.AreNotEqual(pk1.Salt, pk2.Salt)
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey(pk1.Salt).Key)
pk2.Salt = pk1.Salt
Assert.AreEqual(pk1.Salt, pk2.Salt)
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Salt
AESCryptoKey

Source Code

Library/Crypto/PasswordKey.cs

Used By

Stream PasswordKey.Decrypt(Stream,Salt.Size)
Byte[] PasswordKey.Decrypt(Byte[],Salt.Size)


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateKey(Salt,Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > CreateKey Method : CreateKey(Salt,Byte[]) Method

salt
iv

Glossary Item Box

Returns the key generated with the current password and the provided salt

Syntax

Visual Basic (Declaration)
Public Overloads Function CreateKey( _
   ByVal salt As Salt, _
   ByVal iv() As Byte _
) As AESCryptoKey
C#
public AESCryptoKey CreateKey(
   Salt salt,
   byte[] iv
)

Parameters

salt
iv

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Salt
AESCryptoKey

Used By

AESCryptoKey PasswordKey.CreateKey()

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : Decrypt Method

Glossary Item Box

Decrypts the stream with the current password and salt

Overload List

Overload | Description
Decrypt(Stream) | Decrypts the stream with the current password and salt
Decrypt(Stream,Size) | Decrypts the stream with the current password and salt
Decrypt(Byte[]) | Decrypts the bytes with the current password and salt
Decrypt(Byte[],Size) | Decrypts the bytes with the current password and salt
Decrypt(String) | Decrypts the base-64 encoded bytes, decrypts the data and returns the string (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Decrypt(String,ByteEncoding) | Decrypts the base-64 encoded bytes, decrypts the data and returns the string (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Base Implementation in Decrypt


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > Decrypt Method : Decrypt(Stream) Method

stream

Glossary Item Box

Decrypts the stream with the current password and salt

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Decrypt( _
   ByVal stream As Stream _
) As Stream
C#
public override Stream Decrypt(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Base Implementation in Decrypt(Stream)

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Stream,Size) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > Decrypt Method : Decrypt(Stream,Size) Method

stream
szSaltSize

Glossary Item Box

Decrypts the stream with the current password and salt

Syntax

Visual Basic (Declaration)
Public Overloads Function Decrypt( _
   ByVal stream As Stream, _
   ByVal szSaltSize As Salt.Size _
) As Stream
C#
public Stream Decrypt(
   Stream stream,
   Salt.Size szSaltSize
)

Parameters

stream
szSaltSize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Salt.Size

Used By

Stream PasswordKey.Decrypt(Stream)

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > Decrypt Method : Decrypt(Byte[]) Method

blob

Glossary Item Box

Decrypts the bytes with the current password and salt

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Decrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
public override byte[] Decrypt(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Base Implementation in Decrypt(Byte[])

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Byte[],Size) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > Decrypt Method : Decrypt(Byte[],Size) Method

blob
szSaltSize

Glossary Item Box

Decrypts the bytes with the current password and salt

Syntax

Visual Basic (Declaration)
Public Overloads Function Decrypt( _
   ByVal blob() As Byte, _
   ByVal szSaltSize As Salt.Size _
) As Byte()
C#
public byte[] Decrypt(
   byte[] blob,
   Salt.Size szSaltSize
)

Parameters

blob
szSaltSize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Salt.Size

Used By

Byte[] PasswordKey.Decrypt(Byte[])

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : Dispose Method

Glossary Item Box

Removes the memory representation of this password and key

Overload List

Overload | Description
Dispose(Boolean) | Removes the memory representation of this password and key
Dispose() | Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Removes the memory representation of this password and key

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : Encrypt Method

Glossary Item Box

Encrypts the stream with the current password and salt

Overload List

Overload | Description
Encrypt(Stream) | Encrypts the stream with the current password and salt
Encrypt(Byte[]) | Encrypts the bytes with the current password and salt
Encrypt(String) | Encrypts the encoded text and returns the base-64 encoded result (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Encrypt(String,ByteEncoding) | Encrypts the encoded text and returns the base-64 encoded result (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Base Implementation in Encrypt


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > Encrypt Method : Encrypt(Stream) Method

stream

Glossary Item Box

Encrypts the stream with the current password and salt

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Encrypt( _
   ByVal stream As Stream _
) As Stream
C#
public override Stream Encrypt(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Base Implementation in Encrypt(Stream)

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class > Encrypt Method : Encrypt(Byte[]) Method

blob

Glossary Item Box

Encrypts the bytes with the current password and salt

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Encrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
public override byte[] Encrypt(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Overload List
Base Implementation in Encrypt(Byte[])

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
PasswordKey Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordKey Class

Glossary Item Box

For a list of all members of this type, see PasswordKey members.

Public Properties

 | Name | Description
Public Property | IterationCount | Sets or Gets the iterations used with deriving the encryption key
Public Property | IV | Sets or Gets the IV used when deriving the encryption key
Public Property | Salt | Sets or Gets the salt used with deriving the encryption key
Top

Protected Properties

 | Name | Description
Protected Property | DerivedBytes | Returns the derived bytes algorithm for this instance or throws ObjectDisposedException
Top

See Also

Reference

PasswordKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DerivedBytes Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : DerivedBytes Property

Glossary Item Box

Returns the derived bytes algorithm for this instance or throws ObjectDisposedException

Syntax

Visual Basic (Declaration)
Protected ReadOnly Property DerivedBytes As IPasswordDerivedBytes
C#
protected IPasswordDerivedBytes DerivedBytes {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
IterationCount Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : IterationCount Property

Glossary Item Box

Sets or Gets the iterations used with deriving the encryption key

Syntax

Visual Basic (Declaration)
Public Overridable Property IterationCount As Integer
C#
public virtual int IterationCount {get; set;}

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
PasswordKey pk1 = new PasswordKey(TEST_PASSWORD);
PasswordKey pk2 = new PasswordKey(TEST_PASSWORD);
pk2.Salt = pk1.Salt;
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
pk2.IterationCount /= 2;
Assert.AreEqual(pk1.Salt, pk2.Salt);
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
VB.NET Copy Code
Dim pk1 As New PasswordKey(TEST_PASSWORD)
Dim pk2 As New PasswordKey(TEST_PASSWORD)
pk2.Salt = pk1.Salt
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)
pk2.IterationCount /= 2
Assert.AreEqual(pk1.Salt, pk2.Salt)
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IV Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : IV Property

Glossary Item Box

Sets or Gets the IV used when deriving the encryption key

Syntax

Visual Basic (Declaration)
Public Overridable Property IV As Byte()
C#
public virtual byte[] IV {get; set;}

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
using (PasswordKey key = new PasswordKey("bla"))
{
    Assert.AreEqual(AESCryptoKey.ProcessDefaultIV, key.IV);
    byte[] newIv = Guid.NewGuid().ToByteArray();
    key.IV = newIv;

    Assert.AreEqual(newIv, key.IV);
    Assert.AreEqual(newIv, key.CreateKey().IV);
}
VB.NET Copy Code
Using key As New PasswordKey("bla")
    Assert.AreEqual(AESCryptoKey.ProcessDefaultIV, key.IV)
    Dim newIv As Byte() = Guid.NewGuid().ToByteArray()
    key.IV = newIv

    Assert.AreEqual(newIv, key.IV)
    Assert.AreEqual(newIv, key.CreateKey().IV)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members

Used By

AESCryptoKey PasswordKey.CreateKey()
AESCryptoKey PasswordKey.CreateKey(Salt)

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : Salt Property

Glossary Item Box

Sets or Gets the salt used with deriving the encryption key

Syntax

Visual Basic (Declaration)
Public Overridable Property Salt As Salt
C#
public virtual Salt Salt {get; set;}

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
PasswordKey pk1 = new PasswordKey(TEST_PASSWORD);
PasswordKey pk2 = new PasswordKey(TEST_PASSWORD);
pk2.Salt = pk1.Salt;
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
pk2.IterationCount /= 2;
Assert.AreEqual(pk1.Salt, pk2.Salt);
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key);
VB.NET Copy Code
Dim pk1 As New PasswordKey(TEST_PASSWORD)
Dim pk2 As New PasswordKey(TEST_PASSWORD)
pk2.Salt = pk1.Salt
Assert.AreEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)
pk2.IterationCount /= 2
Assert.AreEqual(pk1.Salt, pk2.Salt)
Assert.AreNotEqual(pk1.CreateKey().Key, pk2.CreateKey().Key)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members
Salt

Used By

Stream PasswordKey.Encrypt(Stream)
Stream PasswordKey.Decrypt(Stream)
Byte[] PasswordKey.Encrypt(Byte[])
Byte[] PasswordKey.Decrypt(Byte[])

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
PasswordKey Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PasswordKey Class

Glossary Item Box

For a list of all members of this type, see PasswordKey members.

Public Fields

 | Name | Description
Public Field | DefaultIterations | Adjusts the number of repetitions used when deriving password bytes
Top

See Also

Reference

PasswordKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultIterations Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordKey Class : DefaultIterations Field

Glossary Item Box

Adjusts the number of repetitions used when deriving password bytes

Syntax

Visual Basic (Declaration)
Public Const DefaultIterations As Integer
C#
public const int DefaultIterations

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PasswordKey Class
PasswordKey Members

Source Code

Library/Crypto/PasswordKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PBKDF2 Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PBKDF2 Class

Glossary Item Box

Provided an implementation of Rfc2898DeriveBytes accessable via the IPasswordDerivedBytes interface. One primary difference in GetBytes() ensures that the number of bytes generated are always rounded to hash size, thus GetBytes(4) + GetBytes(4) != GetBytes(8)

Syntax

Visual Basic (Declaration)
Public Class PBKDF2
   Inherits System.Security.Cryptography.Rfc2898DeriveBytes
   Implements IPasswordDerivedBytes
C#
public class PBKDF2 : System.Security.Cryptography.Rfc2898DeriveBytes, IPasswordDerivedBytes

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
int iter = 100;
Salt salt = new Salt();
byte[] passbytes = Password.Encoding.GetBytes(TEST_PASSWORD);
IPasswordDerivedBytes[] types = new IPasswordDerivedBytes[] {
    new PBKDF2(passbytes, salt, iter),
    new HashDerivedBytes<HMACMD5>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA1>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA256>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA384>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA512>(passbytes, salt, iter),
};

foreach (IPasswordDerivedBytes db in types)
{
    byte[] key;

    Stopwatch w = new Stopwatch();
    w.Start();
    for (int i = 0; i < 100; i++)
        key = new PasswordKey(db, salt).CreateKey().Key;
    w.Stop();

    Console.Error.WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.GetType().Name);
}
VB.NET Copy Code
Dim iter As Integer = 100
Dim salt As New Salt()
Dim passbytes As Byte() = Password.Encoding.GetBytes(TEST_PASSWORD)
Dim types As IPasswordDerivedBytes() = New IPasswordDerivedBytes() {New PBKDF2(passbytes, salt, iter), New HashDerivedBytes(Of HMACMD5)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA1)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA256)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA384)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA512)(passbytes, salt, iter)}

For Each db As IPasswordDerivedBytes In types
    Dim key As Byte()

    Dim w As New Stopwatch()
    w.Start()
    Dim i As Integer = 0
    While i < 100
        key = New PasswordKey(db, salt).CreateKey().Key
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    w.[Stop]()

    Console.[Error].WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.[GetType]().Name)
Next

Inheritance Hierarchy

System.Object
System.Security.Cryptography.DeriveBytes
System.Security.Cryptography.Rfc2898DeriveBytes
CSharpTest.Net.Crypto.PBKDF2

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PBKDF2 Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PBKDF2.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PBKDF2 Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PBKDF2 Class

Glossary Item Box

The following tables list the members exposed by PBKDF2.

Public Constructors

 | Name | Description
Public Constructor | PBKDF2 Constructor | Constructs the Rfc2898DeriveBytes implementation.
Top

Public Properties

 | Name | Description
Public Property | IterationCount | Gets or sets the number of iterations for the operation. (Inherited from System.Security.Cryptography.Rfc2898DeriveBytes)
Public Property | Salt | Gets or sets the key salt value for the operation. (Inherited from System.Security.Cryptography.Rfc2898DeriveBytes)
Top

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of the object
Public Method | GetBytes | Overridden. Overloaded, The base implementation is broken for length > 20, further the RFC doesnt support lenght > 20 and stipulates that the operation should fail.
Public Method | Reset | When overridden in a derived class, resets the state of the operation. (Inherited from System.Security.Cryptography.DeriveBytes)
Top

See Also

Reference

PBKDF2 Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PBKDF2.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PBKDF2 Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PBKDF2 Class : PBKDF2 Constructor

password
salt
iterations

Glossary Item Box

Constructs the Rfc2898DeriveBytes implementation.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal password() As Byte, _
   ByVal salt As Salt, _
   ByVal iterations As Integer _
)
C#
public PBKDF2(
   byte[] password,
   Salt salt,
   int iterations
)

Parameters

password
salt
iterations

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
int iter = 100;
Salt salt = new Salt();
byte[] passbytes = Password.Encoding.GetBytes(TEST_PASSWORD);
IPasswordDerivedBytes[] types = new IPasswordDerivedBytes[] {
    new PBKDF2(passbytes, salt, iter),
    new HashDerivedBytes<HMACMD5>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA1>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA256>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA384>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA512>(passbytes, salt, iter),
};

foreach (IPasswordDerivedBytes db in types)
{
    byte[] key;

    Stopwatch w = new Stopwatch();
    w.Start();
    for (int i = 0; i < 100; i++)
        key = new PasswordKey(db, salt).CreateKey().Key;
    w.Stop();

    Console.Error.WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.GetType().Name);
}
VB.NET Copy Code
Dim iter As Integer = 100
Dim salt As New Salt()
Dim passbytes As Byte() = Password.Encoding.GetBytes(TEST_PASSWORD)
Dim types As IPasswordDerivedBytes() = New IPasswordDerivedBytes() {New PBKDF2(passbytes, salt, iter), New HashDerivedBytes(Of HMACMD5)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA1)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA256)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA384)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA512)(passbytes, salt, iter)}

For Each db As IPasswordDerivedBytes In types
    Dim key As Byte()

    Dim w As New Stopwatch()
    w.Start()
    Dim i As Integer = 0
    While i < 100
        key = New PasswordKey(db, salt).CreateKey().Key
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    w.[Stop]()

    Console.[Error].WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.[GetType]().Name)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PBKDF2 Class
PBKDF2 Members

Source Code

Library/Crypto/PBKDF2.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
PBKDF2 Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PBKDF2 Class

Glossary Item Box

For a list of all members of this type, see PBKDF2 members.

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of the object
Public Method | GetBytes | Overridden. Overloaded, The base implementation is broken for length > 20, further the RFC doesnt support lenght > 20 and stipulates that the operation should fail.
Public Method | Reset | When overridden in a derived class, resets the state of the operation. (Inherited from System.Security.Cryptography.DeriveBytes)
Top

See Also

Reference

PBKDF2 Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PBKDF2.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PBKDF2 Class : Dispose Method

Glossary Item Box

Disposes of the object

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PBKDF2 Class
PBKDF2 Members

Source Code

Library/Crypto/PBKDF2.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PBKDF2 Class : GetBytes Method

cb

Glossary Item Box

Overloaded, The base implementation is broken for length > 20, further the RFC doesnt support lenght > 20 and stipulates that the operation should fail.

Syntax

Visual Basic (Declaration)
Public Overrides Function GetBytes( _
   ByVal cb As Integer _
) As Byte()
C#
public override byte[] GetBytes(
   int cb
)

Parameters

cb

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PBKDF2 Class
PBKDF2 Members
Base Implementation in GetBytes

Source Code

Library/Crypto/PBKDF2.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPrivateKey Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPrivateKey Class

Glossary Item Box

Provides a wrapper around encrypting/decrypting with public/private key pairs from Certificats or CSP

Object Model

RSAPrivateKey ClassRSAPublicKey Class

Syntax

Visual Basic (Declaration)
Public Class RSAPrivateKey
   Inherits RSAPublicKey
   Implements IEncryptDecrypt
C#
public class RSAPrivateKey : RSAPublicKey, IEncryptDecrypt

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] data = new byte[100];
new Random().NextBytes(data);

foreach (HashAlgorithm ha in new HashAlgorithm[] { MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create() })
{
    Hash hash = Hash.FromBytes(ha.ComputeHash(data));
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.GetType().FullName), hash.AlgorithmOID);

    using (RSAPrivateKey key = new RSAPrivateKey())
    {
        byte[] sig = key.SignHash(hash);

        using (RSAPublicKey pub = key.PublicKey)
        {
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
            data[0] = (byte)~data[0];
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
        }
    }
}
VB.NET Copy Code
Dim data As Byte() = New Byte(100) {}
New Random().NextBytes(data)

For Each ha As HashAlgorithm In New HashAlgorithm() {MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create()}
    Dim hash As Hash = Hash.FromBytes(ha.ComputeHash(data))
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.[GetType]().FullName), hash.AlgorithmOID)

    Using key As New RSAPrivateKey()
        Dim sig As Byte() = key.SignHash(hash)

        Using pub As RSAPublicKey = key.PublicKey
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
            data(0) = DirectCast(Not data(0), Byte)
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
        End Using
    End Using
Next

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.AsymmetricKey
CSharpTest.Net.Crypto.RSAPublicKey
CSharpTest.Net.Crypto.RSAPrivateKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RSAPrivateKey.cs

Used By

RSAPrivateKey RSAPrivateKey.FromParameters(RSAParameters)
RSAPrivateKey RSAPrivateKey.FromBytes(Byte[])
RSAPrivateKey RSAPrivateKey.FromStore(String)
RSAPrivateKey RSAPrivateKey.FromStore(CspParameters)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
RSAPrivateKey Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPrivateKey Class

Glossary Item Box

The following tables list the members exposed by RSAPrivateKey.

Public Constructors

 | Name | Description
Public Constructor | RSAPrivateKey Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | DefaultKeySize | The default key size in bits to use when constructing a new keypair
Public Field | MaxKeySize | The maximum allowed value for an RSA key
Public Field | MinKeySize | The minimum allowed value for an RSA key
Top

Public Properties

 | Name | Description
Public Property | IsPrivateKey | Returns True if this object is also an RSAPrivateKey (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Public Property | PublicKey | Returns only the public key of this public/private key pair
Top

Protected Properties

 | Name | Description
Protected Property | BlockSize | Provides the size, in bytes, of the maximum transform unit (Inherited from CSharpTest.Net.Crypto.AsymmetricKey)
Protected Property | RSAKey | Returns the key to use for encryption/decryption (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Protected Property | TransformSize | Proivdes the output size, in bytes, assuming an input of BlockSize (Inherited from CSharpTest.Net.Crypto.AsymmetricKey)
Top

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Decrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | DeleteFromStore | Removes the key from the Csp store if it was fetch with RSAPublicKey.FromStore(...) (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Encrypt | Overloaded. Encrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | ExportParameters | Returns the public/private key information (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
static (Shared in Visual Basic) | FromBytes | Creates the key from the information provided
static (Shared in Visual Basic) | FromParameters | Creates the key from the information provided
static (Shared in Visual Basic) | FromStore | Creates the key from the information provided
static (Shared in Visual Basic) | FromXml | Creates the key from the information provided
Public Method | SignHash | Signs the provided Hash code with the private key and returns the hash signature
Public Method | ToArray | Returns a CspBlob standard binary key definition (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Public Method | ToXml | Overloaded. Overridden. Returns the key information
Public Method | VerifyHash | Signs the provided Hash code with the private key and returns the hash signature (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Public Method | WriteToStore | Overloaded. Writes a copy of this key into the local Csp store for the current user (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Decrypts a raw data block as a set of bytes (Inherited from CSharpTest.Net.Crypto.AsymmetricKey)
Protected Method | EncryptBlock | Encrypts a raw data block as a set of bytes (Inherited from CSharpTest.Net.Crypto.AsymmetricKey)
Top

See Also

Reference

RSAPrivateKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RSAPrivateKey.cs

Used By

RSAPrivateKey RSAPrivateKey.FromParameters(RSAParameters)
RSAPrivateKey RSAPrivateKey.FromBytes(Byte[])
RSAPrivateKey RSAPrivateKey.FromStore(String)
RSAPrivateKey RSAPrivateKey.FromStore(CspParameters)


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPrivateKey Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : RSAPrivateKey Constructor

Glossary Item Box

Overload List

Overload | Description
RSAPrivateKey Constructor() | Create RSAPrivateKey with a new keypair of (DefaultKeySize) bit length
RSAPrivateKey Constructor(Int32) |
RSAPrivateKey Constructor(X509Certificate2) | Create RSAPrivateKey with the provided key
RSAPrivateKey Constructor(RSAParameters) | Create RSAPrivateKey with the provided key
RSAPrivateKey Constructor(RSACryptoServiceProvider) | Create RSAPrivateKey with the provided key

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPrivateKey Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class > RSAPrivateKey Constructor : RSAPrivateKey Constructor()

Glossary Item Box

Create RSAPrivateKey with a new keypair of (DefaultKeySize) bit length

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public RSAPrivateKey()

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] data = new byte[100];
new Random().NextBytes(data);

foreach (HashAlgorithm ha in new HashAlgorithm[] { MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create() })
{
    Hash hash = Hash.FromBytes(ha.ComputeHash(data));
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.GetType().FullName), hash.AlgorithmOID);

    using (RSAPrivateKey key = new RSAPrivateKey())
    {
        byte[] sig = key.SignHash(hash);

        using (RSAPublicKey pub = key.PublicKey)
        {
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
            data[0] = (byte)~data[0];
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
        }
    }
}
VB.NET Copy Code
Dim data As Byte() = New Byte(100) {}
New Random().NextBytes(data)

For Each ha As HashAlgorithm In New HashAlgorithm() {MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create()}
    Dim hash As Hash = Hash.FromBytes(ha.ComputeHash(data))
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.[GetType]().FullName), hash.AlgorithmOID)

    Using key As New RSAPrivateKey()
        Dim sig As Byte() = key.SignHash(hash)

        Using pub As RSAPublicKey = key.PublicKey
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
            data(0) = DirectCast(Not data(0), Byte)
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
        End Using
    End Using
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
Overload List

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPrivateKey Constructor(Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class > RSAPrivateKey Constructor : RSAPrivateKey Constructor(Int32)

keySize
the bit-size of the key to generate, 384 - 16384 in increments of 8

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keySize As Integer _
)
C#
public RSAPrivateKey(
   int keySize
)

Parameters

keySize
the bit-size of the key to generate, 384 - 16384 in increments of 8

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
Overload List

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPrivateKey Constructor(X509Certificate2)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class > RSAPrivateKey Constructor : RSAPrivateKey Constructor(X509Certificate2)

certificate

Glossary Item Box

Create RSAPrivateKey with the provided key

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal certificate As X509Certificate2 _
)
C#
public RSAPrivateKey(
   X509Certificate2 certificate
)

Parameters

certificate

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] rawdata = new byte[8001];
new Random().NextBytes(rawdata);

byte[] cypher;
using (RSAPublicKey publicKey = new RSAPublicKey(TestCertPublicKey()))
    cypher = publicKey.Encrypt(rawdata);

using (RSAPrivateKey privateKey = new RSAPrivateKey(TestCertPrivateKey()))
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher));
VB.NET Copy Code
Dim rawdata As Byte() = New Byte(8001) {}
New Random().NextBytes(rawdata)

Dim cypher As Byte()
Using publicKey As New RSAPublicKey(TestCertPublicKey())
    cypher = publicKey.Encrypt(rawdata)
End Using

Using privateKey As New RSAPrivateKey(TestCertPrivateKey())
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
Overload List

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPrivateKey Constructor(RSAParameters)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class > RSAPrivateKey Constructor : RSAPrivateKey Constructor(RSAParameters)

keyInfo

Glossary Item Box

Create RSAPrivateKey with the provided key

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keyInfo As RSAParameters _
)
C#
public RSAPrivateKey(
   RSAParameters keyInfo
)

Parameters

keyInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
Overload List

Used By

RSAPublicKey RSAPublicKey.FromParameters(RSAParameters)

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPrivateKey Constructor(RSACryptoServiceProvider)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class > RSAPrivateKey Constructor : RSAPrivateKey Constructor(RSACryptoServiceProvider)

keyInfo

Glossary Item Box

Create RSAPrivateKey with the provided key

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keyInfo As RSACryptoServiceProvider _
)
C#
public RSAPrivateKey(
   RSACryptoServiceProvider keyInfo
)

Parameters

keyInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
Overload List

Used By

RSAPublicKey RSAPublicKey.FromBytes(Byte[])
RSAPublicKey RSAPublicKey.FromStore(CspParameters)

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
RSAPrivateKey Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPrivateKey Class

Glossary Item Box

For a list of all members of this type, see RSAPrivateKey members.

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Decrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | DeleteFromStore | Removes the key from the Csp store if it was fetch with RSAPublicKey.FromStore(...) (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Encrypt | Overloaded. Encrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | ExportParameters | Returns the public/private key information (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
static (Shared in Visual Basic) | FromBytes | Creates the key from the information provided
static (Shared in Visual Basic) | FromParameters | Creates the key from the information provided
static (Shared in Visual Basic) | FromStore | Creates the key from the information provided
static (Shared in Visual Basic) | FromXml | Creates the key from the information provided
Public Method | SignHash | Signs the provided Hash code with the private key and returns the hash signature
Public Method | ToArray | Returns a CspBlob standard binary key definition (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Public Method | ToXml | Overloaded. Overridden. Returns the key information
Public Method | VerifyHash | Signs the provided Hash code with the private key and returns the hash signature (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Public Method | WriteToStore | Overloaded. Writes a copy of this key into the local Csp store for the current user (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Decrypts a raw data block as a set of bytes (Inherited from CSharpTest.Net.Crypto.AsymmetricKey)
Protected Method | EncryptBlock | Encrypts a raw data block as a set of bytes (Inherited from CSharpTest.Net.Crypto.AsymmetricKey)
Top

See Also

Reference

RSAPrivateKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RSAPrivateKey.cs

Used By

RSAPrivateKey RSAPrivateKey.FromParameters(RSAParameters)
RSAPrivateKey RSAPrivateKey.FromBytes(Byte[])
RSAPrivateKey RSAPrivateKey.FromStore(String)
RSAPrivateKey RSAPrivateKey.FromStore(CspParameters)


%%PageItemTitle%%

[image]
CSharpTest.Net
FromBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : FromBytes Method

bytes

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Shared Shadows Function FromBytes( _
   ByVal bytes() As Byte _
) As RSAPrivateKey
C#
public new static RSAPrivateKey FromBytes(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
RSAPrivateKey pk = new RSAPrivateKey();
string xml = pk.ToXml();

RSAPrivateKey copy = RSAPrivateKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(596, bytes.Length);

copy = RSAPrivateKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPrivateKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NET Copy Code
Dim pk As New RSAPrivateKey()
Dim xml As String = pk.ToXml()

Dim copy As RSAPrivateKey = RSAPrivateKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(596, bytes.Length)

copy = RSAPrivateKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPrivateKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromParameters Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : FromParameters Method

parameters

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Shared Shadows Function FromParameters( _
   ByVal parameters As RSAParameters _
) As RSAPrivateKey
C#
public new static RSAPrivateKey FromParameters(
   RSAParameters parameters
)

Parameters

parameters

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
RSAPrivateKey pk = new RSAPrivateKey();
string xml = pk.ToXml();

RSAPrivateKey copy = RSAPrivateKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(596, bytes.Length);

copy = RSAPrivateKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPrivateKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NET Copy Code
Dim pk As New RSAPrivateKey()
Dim xml As String = pk.ToXml()

Dim copy As RSAPrivateKey = RSAPrivateKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(596, bytes.Length)

copy = RSAPrivateKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPrivateKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members

Source Code

Library/Crypto/RSAPrivateKey.cs

Used By

RSAPrivateKey RSAPrivateKey.FromXml(XmlReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
FromStore Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : FromStore Method

name

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Shared Shadows Function FromStore( _
   ByVal name As String _
) As RSAPrivateKey
C#
public new static RSAPrivateKey FromStore(
   string name
)

Parameters

name

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
string keyname = this.GetType().FullName + ".TestKeyCreateAndDelete";
using (RSAPrivateKey key = new RSAPrivateKey())
{
    Assert.IsFalse(key.DeleteFromStore());

    key.WriteToStore(keyname);

    CspParameters cp = new CspParameters();
    cp.KeyContainerName = keyname;
    cp.Flags = CspProviderFlags.UseExistingKey;

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(cp))
        Assert.AreEqual(key.ToXml(), key2.ToXml());

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(keyname))
    {
        Assert.AreEqual(key.ToXml(), key2.ToXml());
        Assert.IsTrue(key2.DeleteFromStore());
        key2.Dispose();
    }
}
VB.NET Copy Code
Dim keyname As String = Me.[GetType]().FullName + ".TestKeyCreateAndDelete"
Using key As New RSAPrivateKey()
    Assert.IsFalse(key.DeleteFromStore())

    key.WriteToStore(keyname)

    Dim cp As New CspParameters()
    cp.KeyContainerName = keyname
    cp.Flags = CspProviderFlags.UseExistingKey

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(cp)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
    End Using

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(keyname)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
        Assert.IsTrue(key2.DeleteFromStore())
        key2.Dispose()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromXml Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : FromXml Method

xml

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Shared Shadows Function FromXml( _
   ByVal xml As String _
) As RSAPrivateKey
C#
public new static RSAPrivateKey FromXml(
   string xml
)

Parameters

xml

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
RSAPrivateKey pk = new RSAPrivateKey();
string xml = pk.ToXml();

RSAPrivateKey copy = RSAPrivateKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(596, bytes.Length);

copy = RSAPrivateKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPrivateKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NET Copy Code
Dim pk As New RSAPrivateKey()
Dim xml As String = pk.ToXml()

Dim copy As RSAPrivateKey = RSAPrivateKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(596, bytes.Length)

copy = RSAPrivateKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPrivateKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SignHash Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : SignHash Method

hashBytes

Glossary Item Box

Signs the provided Hash code with the private key and returns the hash signature

Syntax

Visual Basic (Declaration)
Public Function SignHash( _
   ByVal hashBytes As Hash _
) As Byte()
C#
public byte[] SignHash(
   Hash hashBytes
)

Parameters

hashBytes

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] data = new byte[100];
new Random().NextBytes(data);

foreach (HashAlgorithm ha in new HashAlgorithm[] { MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create() })
{
    Hash hash = Hash.FromBytes(ha.ComputeHash(data));
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.GetType().FullName), hash.AlgorithmOID);

    using (RSAPrivateKey key = new RSAPrivateKey())
    {
        byte[] sig = key.SignHash(hash);

        using (RSAPublicKey pub = key.PublicKey)
        {
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
            data[0] = (byte)~data[0];
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
        }
    }
}
VB.NET Copy Code
Dim data As Byte() = New Byte(100) {}
New Random().NextBytes(data)

For Each ha As HashAlgorithm In New HashAlgorithm() {MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create()}
    Dim hash As Hash = Hash.FromBytes(ha.ComputeHash(data))
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.[GetType]().FullName), hash.AlgorithmOID)

    Using key As New RSAPrivateKey()
        Dim sig As Byte() = key.SignHash(hash)

        Using pub As RSAPublicKey = key.PublicKey
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
            data(0) = DirectCast(Not data(0), Byte)
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
        End Using
    End Using
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
Hash

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToXml Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : ToXml Method

Glossary Item Box

Returns the key information

Overload List

Overload | Description
ToXml(XmlWriter) | Returns the key information
ToXml() | Returns the key information (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
Base Implementation in ToXml


%%PageItemTitle%%

[image]
CSharpTest.Net
ToXml(XmlWriter) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class > ToXml Method : ToXml(XmlWriter) Method

xml

Glossary Item Box

Returns the key information

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Sub ToXml( _
   ByVal xml As XmlWriter _
)
C#
public override void ToXml(
   XmlWriter xml
)

Parameters

xml

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
Overload List
Base Implementation in ToXml(XmlWriter)

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
RSAPrivateKey Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPrivateKey Class

Glossary Item Box

For a list of all members of this type, see RSAPrivateKey members.

Public Properties

 | Name | Description
Public Property | IsPrivateKey | Returns True if this object is also an RSAPrivateKey (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Public Property | PublicKey | Returns only the public key of this public/private key pair
Top

Protected Properties

 | Name | Description
Protected Property | BlockSize | Provides the size, in bytes, of the maximum transform unit (Inherited from CSharpTest.Net.Crypto.AsymmetricKey)
Protected Property | RSAKey | Returns the key to use for encryption/decryption (Inherited from CSharpTest.Net.Crypto.RSAPublicKey)
Protected Property | TransformSize | Proivdes the output size, in bytes, assuming an input of BlockSize (Inherited from CSharpTest.Net.Crypto.AsymmetricKey)
Top

See Also

Reference

RSAPrivateKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RSAPrivateKey.cs

Used By

RSAPrivateKey RSAPrivateKey.FromParameters(RSAParameters)
RSAPrivateKey RSAPrivateKey.FromBytes(Byte[])
RSAPrivateKey RSAPrivateKey.FromStore(String)
RSAPrivateKey RSAPrivateKey.FromStore(CspParameters)


%%PageItemTitle%%

[image]
CSharpTest.Net
PublicKey Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : PublicKey Property

Glossary Item Box

Returns only the public key of this public/private key pair

Syntax

Visual Basic (Declaration)
Public ReadOnly Property PublicKey As RSAPublicKey
C#
public RSAPublicKey PublicKey {get;}

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] data = new byte[100];
new Random().NextBytes(data);

foreach (HashAlgorithm ha in new HashAlgorithm[] { MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create() })
{
    Hash hash = Hash.FromBytes(ha.ComputeHash(data));
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.GetType().FullName), hash.AlgorithmOID);

    using (RSAPrivateKey key = new RSAPrivateKey())
    {
        byte[] sig = key.SignHash(hash);

        using (RSAPublicKey pub = key.PublicKey)
        {
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
            data[0] = (byte)~data[0];
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
        }
    }
}
VB.NET Copy Code
Dim data As Byte() = New Byte(100) {}
New Random().NextBytes(data)

For Each ha As HashAlgorithm In New HashAlgorithm() {MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create()}
    Dim hash As Hash = Hash.FromBytes(ha.ComputeHash(data))
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.[GetType]().FullName), hash.AlgorithmOID)

    Using key As New RSAPrivateKey()
        Dim sig As Byte() = key.SignHash(hash)

        Using pub As RSAPublicKey = key.PublicKey
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
            data(0) = DirectCast(Not data(0), Byte)
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
        End Using
    End Using
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members
RSAPublicKey

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
RSAPrivateKey Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPrivateKey Class

Glossary Item Box

For a list of all members of this type, see RSAPrivateKey members.

Public Fields

 | Name | Description
Public Field | DefaultKeySize | The default key size in bits to use when constructing a new keypair
Public Field | MaxKeySize | The maximum allowed value for an RSA key
Public Field | MinKeySize | The minimum allowed value for an RSA key
Top

See Also

Reference

RSAPrivateKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RSAPrivateKey.cs

Used By

RSAPrivateKey RSAPrivateKey.FromParameters(RSAParameters)
RSAPrivateKey RSAPrivateKey.FromBytes(Byte[])
RSAPrivateKey RSAPrivateKey.FromStore(String)
RSAPrivateKey RSAPrivateKey.FromStore(CspParameters)


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultKeySize Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : DefaultKeySize Field

Glossary Item Box

The default key size in bits to use when constructing a new keypair

Syntax

Visual Basic (Declaration)
Public Const DefaultKeySize As Integer
C#
public const int DefaultKeySize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxKeySize Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : MaxKeySize Field

Glossary Item Box

The maximum allowed value for an RSA key

Syntax

Visual Basic (Declaration)
Public Const MaxKeySize As Integer
C#
public const int MaxKeySize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MinKeySize Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPrivateKey Class : MinKeySize Field

Glossary Item Box

The minimum allowed value for an RSA key

Syntax

Visual Basic (Declaration)
Public Const MinKeySize As Integer
C#
public const int MinKeySize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPrivateKey Class
RSAPrivateKey Members

Source Code

Library/Crypto/RSAPrivateKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPublicKey Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPublicKey Class

Glossary Item Box

Provides a wrapper around encrypting with public keys from Certificats or CSP

Syntax

Visual Basic (Declaration)
Public Class RSAPublicKey
   Inherits AsymmetricKey
   Implements IEncryptDecrypt
C#
public class RSAPublicKey : AsymmetricKey, IEncryptDecrypt

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] rawdata = new byte[8001];
new Random().NextBytes(rawdata);

byte[] cypher;
using (RSAPublicKey publicKey = new RSAPublicKey(TestCertPublicKey()))
    cypher = publicKey.Encrypt(rawdata);

using (RSAPrivateKey privateKey = new RSAPrivateKey(TestCertPrivateKey()))
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher));
VB.NET Copy Code
Dim rawdata As Byte() = New Byte(8001) {}
New Random().NextBytes(rawdata)

Dim cypher As Byte()
Using publicKey As New RSAPublicKey(TestCertPublicKey())
    cypher = publicKey.Encrypt(rawdata)
End Using

Using privateKey As New RSAPrivateKey(TestCertPrivateKey())
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher))
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.AsymmetricKey
CSharpTest.Net.Crypto.RSAPublicKey
CSharpTest.Net.Crypto.RSAPrivateKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Members
CSharpTest.Net.Crypto Namespace
RSAPublicKey RSAPrivateKey.PublicKey

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
RSAPublicKey Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPublicKey Class

Glossary Item Box

The following tables list the members exposed by RSAPublicKey.

Public Constructors

 | Name | Description
Public Constructor | RSAPublicKey Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | IsPrivateKey | Returns True if this object is also an RSAPrivateKey
Top

Protected Properties

 | Name | Description
Protected Property | BlockSize | Overridden. For this type of padding, block size is (key byte length - 11) see http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.encrypt.aspx
Protected Property | RSAKey | Returns the key to use for encryption/decryption
Protected Property | TransformSize | Overridden. Output size
Top

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Decrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | DeleteFromStore | Removes the key from the Csp store if it was fetch with RSAPublicKey.FromStore(...)
Public Method | Dispose | Overloaded. Overridden. Clears the key
Public Method | Encrypt | Overloaded. Encrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | ExportParameters | Returns the public/private key information
static (Shared in Visual Basic) | FromBytes | Creates the key from the information provided
static (Shared in Visual Basic) | FromParameters | Creates the key from the information provided
static (Shared in Visual Basic) | FromStore | Overloaded. Creates the key from the information provided
static (Shared in Visual Basic) | FromXml | Overloaded. Creates the key from the information provided
Public Method | ToArray | Returns a CspBlob standard binary key definition
Public Method | ToXml | Overloaded. Returns the key information
Public Method | VerifyHash | Signs the provided Hash code with the private key and returns the hash signature
Public Method | WriteToStore | Overloaded. Writes a copy of this key into the local Csp store for the current user
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Overridden. Decrypts the given bytes
Protected Method | EncryptBlock | Overridden. Encrypts the given bytes
Top

See Also

Reference

RSAPublicKey Class
CSharpTest.Net.Crypto Namespace
RSAPublicKey RSAPrivateKey.PublicKey

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPublicKey Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : RSAPublicKey Constructor

Glossary Item Box

Overload List

Overload | Description
RSAPublicKey Constructor(X509Certificate2) | Create RSAPublicKey with the provided key
RSAPublicKey Constructor(RSAParameters) | Create RSAPublicKey with the provided key
RSAPublicKey Constructor(RSACryptoServiceProvider) | Create RSAPublicKey with the provided key

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPublicKey Constructor(X509Certificate2)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > RSAPublicKey Constructor : RSAPublicKey Constructor(X509Certificate2)

certificate

Glossary Item Box

Create RSAPublicKey with the provided key

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal certificate As X509Certificate2 _
)
C#
public RSAPublicKey(
   X509Certificate2 certificate
)

Parameters

certificate

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] rawdata = new byte[8001];
new Random().NextBytes(rawdata);

byte[] cypher;
using (RSAPublicKey publicKey = new RSAPublicKey(TestCertPublicKey()))
    cypher = publicKey.Encrypt(rawdata);

using (RSAPrivateKey privateKey = new RSAPrivateKey(TestCertPrivateKey()))
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher));
VB.NET Copy Code
Dim rawdata As Byte() = New Byte(8001) {}
New Random().NextBytes(rawdata)

Dim cypher As Byte()
Using publicKey As New RSAPublicKey(TestCertPublicKey())
    cypher = publicKey.Encrypt(rawdata)
End Using

Using privateKey As New RSAPrivateKey(TestCertPrivateKey())
    Assert.AreEqual(rawdata, privateKey.Decrypt(cypher))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPublicKey Constructor(RSAParameters)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > RSAPublicKey Constructor : RSAPublicKey Constructor(RSAParameters)

keyInfo

Glossary Item Box

Create RSAPublicKey with the provided key

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keyInfo As RSAParameters _
)
C#
public RSAPublicKey(
   RSAParameters keyInfo
)

Parameters

keyInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Used By

RSAPublicKey RSAPublicKey.FromParameters(RSAParameters)

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAPublicKey Constructor(RSACryptoServiceProvider)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > RSAPublicKey Constructor : RSAPublicKey Constructor(RSACryptoServiceProvider)

keyInfo

Glossary Item Box

Create RSAPublicKey with the provided key

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keyInfo As RSACryptoServiceProvider _
)
C#
public RSAPublicKey(
   RSACryptoServiceProvider keyInfo
)

Parameters

keyInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Used By

RSAPublicKey RSAPublicKey.FromBytes(Byte[])
RSAPublicKey RSAPublicKey.FromStore(CspParameters)

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
RSAPublicKey Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPublicKey Class

Glossary Item Box

For a list of all members of this type, see RSAPublicKey members.

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Decrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | DeleteFromStore | Removes the key from the Csp store if it was fetch with RSAPublicKey.FromStore(...)
Public Method | Dispose | Overloaded. Overridden. Clears the key
Public Method | Encrypt | Overloaded. Encrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | ExportParameters | Returns the public/private key information
static (Shared in Visual Basic) | FromBytes | Creates the key from the information provided
static (Shared in Visual Basic) | FromParameters | Creates the key from the information provided
static (Shared in Visual Basic) | FromStore | Overloaded. Creates the key from the information provided
static (Shared in Visual Basic) | FromXml | Overloaded. Creates the key from the information provided
Public Method | ToArray | Returns a CspBlob standard binary key definition
Public Method | ToXml | Overloaded. Returns the key information
Public Method | VerifyHash | Signs the provided Hash code with the private key and returns the hash signature
Public Method | WriteToStore | Overloaded. Writes a copy of this key into the local Csp store for the current user
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Overridden. Decrypts the given bytes
Protected Method | EncryptBlock | Overridden. Encrypts the given bytes
Top

See Also

Reference

RSAPublicKey Class
CSharpTest.Net.Crypto Namespace
RSAPublicKey RSAPrivateKey.PublicKey

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecryptBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : DecryptBlock Method

blob

Glossary Item Box

Decrypts the given bytes

Syntax

Visual Basic (Declaration)
Protected Overrides Function DecryptBlock( _
   ByVal blob() As Byte _
) As Byte()
C#
protected override byte[] DecryptBlock(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Base Implementation in DecryptBlock


%%PageItemTitle%%

[image]
CSharpTest.Net
DeleteFromStore Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : DeleteFromStore Method

Glossary Item Box

Removes the key from the Csp store if it was fetch with RSAPublicKey.FromStore(...)

Syntax

Visual Basic (Declaration)
Public Function DeleteFromStore() As Boolean
C#
public bool DeleteFromStore()

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
string keyname = this.GetType().FullName + ".TestKeyCreateAndDelete";
using (RSAPrivateKey key = new RSAPrivateKey())
{
    Assert.IsFalse(key.DeleteFromStore());

    key.WriteToStore(keyname);

    CspParameters cp = new CspParameters();
    cp.KeyContainerName = keyname;
    cp.Flags = CspProviderFlags.UseExistingKey;

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(cp))
        Assert.AreEqual(key.ToXml(), key2.ToXml());

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(keyname))
    {
        Assert.AreEqual(key.ToXml(), key2.ToXml());
        Assert.IsTrue(key2.DeleteFromStore());
        key2.Dispose();
    }
}
VB.NET Copy Code
Dim keyname As String = Me.[GetType]().FullName + ".TestKeyCreateAndDelete"
Using key As New RSAPrivateKey()
    Assert.IsFalse(key.DeleteFromStore())

    key.WriteToStore(keyname)

    Dim cp As New CspParameters()
    cp.KeyContainerName = keyname
    cp.Flags = CspProviderFlags.UseExistingKey

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(cp)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
    End Using

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(keyname)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
        Assert.IsTrue(key2.DeleteFromStore())
        key2.Dispose()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : Dispose Method

Glossary Item Box

Clears the key

Overload List

Overload | Description
Dispose(Boolean) | Clears the key
Dispose() | Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Clears the key

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
EncryptBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : EncryptBlock Method

blob

Glossary Item Box

Encrypts the given bytes

Syntax

Visual Basic (Declaration)
Protected Overrides Function EncryptBlock( _
   ByVal blob() As Byte _
) As Byte()
C#
protected override byte[] EncryptBlock(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Base Implementation in EncryptBlock


%%PageItemTitle%%

[image]
CSharpTest.Net
ExportParameters Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : ExportParameters Method

Glossary Item Box

Returns the public/private key information

Syntax

Visual Basic (Declaration)
Public Function ExportParameters() As RSAParameters
C#
public RSAParameters ExportParameters()

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
RSAPrivateKey pk = new RSAPrivateKey();
string xml = pk.ToXml();

RSAPrivateKey copy = RSAPrivateKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(596, bytes.Length);

copy = RSAPrivateKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPrivateKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NET Copy Code
Dim pk As New RSAPrivateKey()
Dim xml As String = pk.ToXml()

Dim copy As RSAPrivateKey = RSAPrivateKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(596, bytes.Length)

copy = RSAPrivateKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPrivateKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members

Source Code

Library/Crypto/RSAPublicKey.cs

Used By

RSAPublicKey.ToXml(XmlWriter)
RSAPrivateKey.ToXml(XmlWriter)


%%PageItemTitle%%

[image]
CSharpTest.Net
FromBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : FromBytes Method

bytes

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Shared Function FromBytes( _
   ByVal bytes() As Byte _
) As RSAPublicKey
C#
public static RSAPublicKey FromBytes(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
RSAPublicKey pk = new RSAPrivateKey().PublicKey;
string xml = pk.ToXml();

RSAPublicKey copy = RSAPublicKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(148, bytes.Length);

copy = RSAPublicKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPublicKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NET Copy Code
Dim pk As RSAPublicKey = New RSAPrivateKey().PublicKey
Dim xml As String = pk.ToXml()

Dim copy As RSAPublicKey = RSAPublicKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(148, bytes.Length)

copy = RSAPublicKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPublicKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members

Source Code

Library/Crypto/RSAPublicKey.cs

Used By

RSAPrivateKey RSAPrivateKey.FromBytes(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
FromParameters Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : FromParameters Method

parameters

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Shared Function FromParameters( _
   ByVal parameters As RSAParameters _
) As RSAPublicKey
C#
public static RSAPublicKey FromParameters(
   RSAParameters parameters
)

Parameters

parameters

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
RSAPublicKey pk = new RSAPrivateKey().PublicKey;
string xml = pk.ToXml();

RSAPublicKey copy = RSAPublicKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(148, bytes.Length);

copy = RSAPublicKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPublicKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NET Copy Code
Dim pk As RSAPublicKey = New RSAPrivateKey().PublicKey
Dim xml As String = pk.ToXml()

Dim copy As RSAPublicKey = RSAPublicKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(148, bytes.Length)

copy = RSAPublicKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPublicKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members

Source Code

Library/Crypto/RSAPublicKey.cs

Used By

RSAPublicKey RSAPublicKey.FromXml(XmlReader)
RSAPrivateKey RSAPrivateKey.FromParameters(RSAParameters)


%%PageItemTitle%%

[image]
CSharpTest.Net
FromStore Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : FromStore Method

Glossary Item Box

Creates the key from the information provided

Overload List

Overload | Description
FromStore(String) | Creates the key from the information provided
FromStore(CspParameters) | Creates the key from the information provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
FromStore(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > FromStore Method : FromStore(String) Method

name

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function FromStore( _
   ByVal name As String _
) As RSAPublicKey
C#
public static RSAPublicKey FromStore(
   string name
)

Parameters

name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Source Code

Library/Crypto/RSAPublicKey.cs

Used By

RSAPrivateKey RSAPrivateKey.FromStore(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
FromStore(CspParameters) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > FromStore Method : FromStore(CspParameters) Method

parameters

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function FromStore( _
   ByVal parameters As CspParameters _
) As RSAPublicKey
C#
public static RSAPublicKey FromStore(
   CspParameters parameters
)

Parameters

parameters

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Used By

RSAPublicKey RSAPublicKey.FromStore(String)
RSAPrivateKey RSAPrivateKey.FromStore(CspParameters)

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromXml Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : FromXml Method

Glossary Item Box

Creates the key from the information provided

Overload List

Overload | Description
FromXml(String) | Creates the key from the information provided
FromXml(XmlReader) | Creates the key from the information provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
FromXml(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > FromXml Method : FromXml(String) Method

xml

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function FromXml( _
   ByVal xml As String _
) As RSAPublicKey
C#
public static RSAPublicKey FromXml(
   string xml
)

Parameters

xml

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
RSAPublicKey pk = new RSAPrivateKey().PublicKey;
string xml = pk.ToXml();

RSAPublicKey copy = RSAPublicKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(148, bytes.Length);

copy = RSAPublicKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPublicKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NET Copy Code
Dim pk As RSAPublicKey = New RSAPrivateKey().PublicKey
Dim xml As String = pk.ToXml()

Dim copy As RSAPublicKey = RSAPublicKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(148, bytes.Length)

copy = RSAPublicKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPublicKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromXml(XmlReader) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > FromXml Method : FromXml(XmlReader) Method

xrdr

Glossary Item Box

Creates the key from the information provided

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function FromXml( _
   ByVal xrdr As XmlReader _
) As RSAPublicKey
C#
public static RSAPublicKey FromXml(
   XmlReader xrdr
)

Parameters

xrdr

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Used By

RSAPublicKey RSAPublicKey.FromXml(String)

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : ToArray Method

Glossary Item Box

Returns a CspBlob standard binary key definition

Syntax

Visual Basic (Declaration)
Public Function ToArray() As Byte()
C#
public byte[] ToArray()

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
RSAPrivateKey pk = new RSAPrivateKey();
string xml = pk.ToXml();

RSAPrivateKey copy = RSAPrivateKey.FromXml(xml);
Assert.AreEqual(xml, copy.ToXml());

byte[] bytes = pk.ToArray();
Assert.AreEqual(596, bytes.Length);

copy = RSAPrivateKey.FromBytes(bytes);
Assert.AreEqual(bytes, copy.ToArray());

copy = RSAPrivateKey.FromParameters(pk.ExportParameters());
Assert.AreEqual(bytes, copy.ToArray());
VB.NET Copy Code
Dim pk As New RSAPrivateKey()
Dim xml As String = pk.ToXml()

Dim copy As RSAPrivateKey = RSAPrivateKey.FromXml(xml)
Assert.AreEqual(xml, copy.ToXml())

Dim bytes As Byte() = pk.ToArray()
Assert.AreEqual(596, bytes.Length)

copy = RSAPrivateKey.FromBytes(bytes)
Assert.AreEqual(bytes, copy.ToArray())

copy = RSAPrivateKey.FromParameters(pk.ExportParameters())
Assert.AreEqual(bytes, copy.ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToXml Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : ToXml Method

Glossary Item Box

Returns the key information

Overload List

Overload | Description
ToXml(XmlWriter) | Returns the key information
ToXml() | Returns the key information

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ToXml(XmlWriter) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > ToXml Method : ToXml(XmlWriter) Method

xml

Glossary Item Box

Returns the key information

Syntax

Visual Basic (Declaration)
Public Overloads Overridable Sub ToXml( _
   ByVal xml As XmlWriter _
)
C#
public virtual void ToXml(
   XmlWriter xml
)

Parameters

xml

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Source Code

Library/Crypto/RSAPublicKey.cs

Used By

String RSAPublicKey.ToXml()


%%PageItemTitle%%

[image]
CSharpTest.Net
ToXml() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > ToXml Method : ToXml() Method

Glossary Item Box

Returns the key information

Syntax

Visual Basic (Declaration)
Public Overloads Function ToXml() As String
C#
public string ToXml()

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
string keyname = this.GetType().FullName + ".TestKeyCreateAndDelete";
using (RSAPrivateKey key = new RSAPrivateKey())
{
    Assert.IsFalse(key.DeleteFromStore());

    key.WriteToStore(keyname);

    CspParameters cp = new CspParameters();
    cp.KeyContainerName = keyname;
    cp.Flags = CspProviderFlags.UseExistingKey;

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(cp))
        Assert.AreEqual(key.ToXml(), key2.ToXml());

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(keyname))
    {
        Assert.AreEqual(key.ToXml(), key2.ToXml());
        Assert.IsTrue(key2.DeleteFromStore());
        key2.Dispose();
    }
}
VB.NET Copy Code
Dim keyname As String = Me.[GetType]().FullName + ".TestKeyCreateAndDelete"
Using key As New RSAPrivateKey()
    Assert.IsFalse(key.DeleteFromStore())

    key.WriteToStore(keyname)

    Dim cp As New CspParameters()
    cp.KeyContainerName = keyname
    cp.Flags = CspProviderFlags.UseExistingKey

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(cp)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
    End Using

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(keyname)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
        Assert.IsTrue(key2.DeleteFromStore())
        key2.Dispose()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
VerifyHash Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : VerifyHash Method

signature
hashBytes

Glossary Item Box

Signs the provided Hash code with the private key and returns the hash signature

Syntax

Visual Basic (Declaration)
Public Function VerifyHash( _
   ByVal signature() As Byte, _
   ByVal hashBytes As Hash _
) As Boolean
C#
public bool VerifyHash(
   byte[] signature,
   Hash hashBytes
)

Parameters

signature
hashBytes

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
byte[] data = new byte[100];
new Random().NextBytes(data);

foreach (HashAlgorithm ha in new HashAlgorithm[] { MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create() })
{
    Hash hash = Hash.FromBytes(ha.ComputeHash(data));
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.GetType().FullName), hash.AlgorithmOID);

    using (RSAPrivateKey key = new RSAPrivateKey())
    {
        byte[] sig = key.SignHash(hash);

        using (RSAPublicKey pub = key.PublicKey)
        {
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
            data[0] = (byte)~data[0];
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))));
        }
    }
}
VB.NET Copy Code
Dim data As Byte() = New Byte(100) {}
New Random().NextBytes(data)

For Each ha As HashAlgorithm In New HashAlgorithm() {MD5.Create(), SHA1.Create(), SHA256.Create(), SHA384.Create(), SHA512.Create()}
    Dim hash As Hash = Hash.FromBytes(ha.ComputeHash(data))
    Assert.AreEqual(CryptoConfig.MapNameToOID(ha.[GetType]().FullName), hash.AlgorithmOID)

    Using key As New RSAPrivateKey()
        Dim sig As Byte() = key.SignHash(hash)

        Using pub As RSAPublicKey = key.PublicKey
            Assert.IsTrue(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
            data(0) = DirectCast(Not data(0), Byte)
            Assert.IsFalse(pub.VerifyHash(sig, Hash.FromBytes(ha.ComputeHash(data))))
        End Using
    End Using
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Hash

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteToStore Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : WriteToStore Method

Glossary Item Box

Writes a copy of this key into the local Csp store for the current user

Overload List

Overload | Description
WriteToStore(String) | Writes a copy of this key into the local Csp store for the current user
WriteToStore(String,CspProviderFlags) | Writes a copy of this key into the local Csp store with the given options

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteToStore(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > WriteToStore Method : WriteToStore(String) Method

name

Glossary Item Box

Writes a copy of this key into the local Csp store for the current user

Syntax

Visual Basic (Declaration)
Public Overloads Sub WriteToStore( _
   ByVal name As String _
)
C#
public void WriteToStore(
   string name
)

Parameters

name

Example

Library/Library.Test/TestRSACrypto.cs

C# Copy Code
string keyname = this.GetType().FullName + ".TestKeyCreateAndDelete";
using (RSAPrivateKey key = new RSAPrivateKey())
{
    Assert.IsFalse(key.DeleteFromStore());

    key.WriteToStore(keyname);

    CspParameters cp = new CspParameters();
    cp.KeyContainerName = keyname;
    cp.Flags = CspProviderFlags.UseExistingKey;

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(cp))
        Assert.AreEqual(key.ToXml(), key2.ToXml());

    using (RSAPrivateKey key2 = RSAPrivateKey.FromStore(keyname))
    {
        Assert.AreEqual(key.ToXml(), key2.ToXml());
        Assert.IsTrue(key2.DeleteFromStore());
        key2.Dispose();
    }
}
VB.NET Copy Code
Dim keyname As String = Me.[GetType]().FullName + ".TestKeyCreateAndDelete"
Using key As New RSAPrivateKey()
    Assert.IsFalse(key.DeleteFromStore())

    key.WriteToStore(keyname)

    Dim cp As New CspParameters()
    cp.KeyContainerName = keyname
    cp.Flags = CspProviderFlags.UseExistingKey

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(cp)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
    End Using

    Using key2 As RSAPrivateKey = RSAPrivateKey.FromStore(keyname)
        Assert.AreEqual(key.ToXml(), key2.ToXml())
        Assert.IsTrue(key2.DeleteFromStore())
        key2.Dispose()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteToStore(String,CspProviderFlags) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class > WriteToStore Method : WriteToStore(String,CspProviderFlags) Method

name
flags

Glossary Item Box

Writes a copy of this key into the local Csp store with the given options

Syntax

Visual Basic (Declaration)
Public Overloads Sub WriteToStore( _
   ByVal name As String, _
   ByVal flags As CspProviderFlags _
)
C#
public void WriteToStore(
   string name,
   CspProviderFlags flags
)

Parameters

name
flags

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Overload List

Used By

RSAPublicKey.WriteToStore(String)

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
RSAPublicKey Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RSAPublicKey Class

Glossary Item Box

For a list of all members of this type, see RSAPublicKey members.

Public Properties

 | Name | Description
Public Property | IsPrivateKey | Returns True if this object is also an RSAPrivateKey
Top

Protected Properties

 | Name | Description
Protected Property | BlockSize | Overridden. For this type of padding, block size is (key byte length - 11) see http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.encrypt.aspx
Protected Property | RSAKey | Returns the key to use for encryption/decryption
Protected Property | TransformSize | Overridden. Output size
Top

See Also

Reference

RSAPublicKey Class
CSharpTest.Net.Crypto Namespace
RSAPublicKey RSAPrivateKey.PublicKey

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BlockSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : BlockSize Property

Glossary Item Box

For this type of padding, block size is (key byte length - 11) see http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.encrypt.aspx

Syntax

Visual Basic (Declaration)
Protected Overrides ReadOnly Property BlockSize As Integer
C#
protected override int BlockSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Base Implementation in BlockSize


%%PageItemTitle%%

[image]
CSharpTest.Net
IsPrivateKey Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : IsPrivateKey Property

Glossary Item Box

Returns True if this object is also an RSAPrivateKey

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsPrivateKey As Boolean
C#
public bool IsPrivateKey {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members

Used By

RSAParameters RSAPublicKey.ExportParameters()
Byte[] RSAPublicKey.ToArray()
RSAPublicKey.WriteToStore(String,CspProviderFlags)

Source Code

Library/Crypto/RSAPublicKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RSAKey Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : RSAKey Property

Glossary Item Box

Returns the key to use for encryption/decryption

Syntax

Visual Basic (Declaration)
Protected ReadOnly Property RSAKey As RSACryptoServiceProvider
C#
protected RSACryptoServiceProvider RSAKey {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TransformSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RSAPublicKey Class : TransformSize Property

Glossary Item Box

Output size

Syntax

Visual Basic (Declaration)
Protected Overrides ReadOnly Property TransformSize As Integer
C#
protected override int TransformSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RSAPublicKey Class
RSAPublicKey Members
Base Implementation in TransformSize


%%PageItemTitle%%

[image]
CSharpTest.Net
RtlProcessKey Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RtlProcessKey Class

Glossary Item Box

Provides the ability to encrypt and decrypt data accessable by the current process only, requires

Syntax

Visual Basic (Declaration)
Public Class RtlProcessKey
   Inherits AsymmetricKey
   Implements IEncryptDecrypt
C#
public class RtlProcessKey : AsymmetricKey, IEncryptDecrypt

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.AsymmetricKey
CSharpTest.Net.Crypto.RtlProcessKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RtlProcessKey Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RtlProcessKey.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
RtlProcessKey Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RtlProcessKey Class

Glossary Item Box

The following tables list the members exposed by RtlProcessKey.

Public Constructors

 | Name | Description
Public Constructor | RtlProcessKey Constructor |
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Encryptor | Returns a single instance of the encryptor, it's thread-safe.
Top

Protected Properties

 | Name | Description
Protected Property | BlockSize | Overridden. The size of an input block
Protected Property | TransformSize | Overridden. The size of an output block
Top

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Decrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Encrypt | Overloaded. Encrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Overridden. Decrypts the block of data
Protected Method | EncryptBlock | Overridden. Encrypts the block of data
Top

See Also

Reference

RtlProcessKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RtlProcessKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RtlProcessKey Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RtlProcessKey Class : RtlProcessKey Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public RtlProcessKey()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RtlProcessKey Class
RtlProcessKey Members

Source Code

Library/Crypto/RtlProcessKey.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
RtlProcessKey Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RtlProcessKey Class

Glossary Item Box

For a list of all members of this type, see RtlProcessKey members.

Public Methods

 | Name | Description
Public Method | Decrypt | Overloaded. Decrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Dispose | Overloaded. Clears any secure memory associated with this object (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Public Method | Encrypt | Overloaded. Encrypts the given bytes (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Top

Protected Methods

 | Name | Description
Protected Method | Assert<T> | Throws ObjectDisposedException if the object has been disposed (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | CryptographicException | Used to ensure generality in excpetions raised from cryptographic routines. (Inherited from CSharpTest.Net.Crypto.CryptoKey)
Protected Method | DecryptBlock | Overridden. Decrypts the block of data
Protected Method | EncryptBlock | Overridden. Encrypts the block of data
Top

See Also

Reference

RtlProcessKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RtlProcessKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecryptBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RtlProcessKey Class : DecryptBlock Method

blob

Glossary Item Box

Decrypts the block of data

Syntax

Visual Basic (Declaration)
Protected Overrides Function DecryptBlock( _
   ByVal blob() As Byte _
) As Byte()
C#
protected override byte[] DecryptBlock(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RtlProcessKey Class
RtlProcessKey Members
Base Implementation in DecryptBlock


%%PageItemTitle%%

[image]
CSharpTest.Net
EncryptBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RtlProcessKey Class : EncryptBlock Method

blob

Glossary Item Box

Encrypts the block of data

Syntax

Visual Basic (Declaration)
Protected Overrides Function EncryptBlock( _
   ByVal blob() As Byte _
) As Byte()
C#
protected override byte[] EncryptBlock(
   byte[] blob
)

Parameters

blob

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RtlProcessKey Class
RtlProcessKey Members
Base Implementation in EncryptBlock


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
RtlProcessKey Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RtlProcessKey Class

Glossary Item Box

For a list of all members of this type, see RtlProcessKey members.

Protected Properties

 | Name | Description
Protected Property | BlockSize | Overridden. The size of an input block
Protected Property | TransformSize | Overridden. The size of an output block
Top

See Also

Reference

RtlProcessKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RtlProcessKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BlockSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RtlProcessKey Class : BlockSize Property

Glossary Item Box

The size of an input block

Syntax

Visual Basic (Declaration)
Protected Overrides ReadOnly Property BlockSize As Integer
C#
protected override int BlockSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RtlProcessKey Class
RtlProcessKey Members
Base Implementation in BlockSize


%%PageItemTitle%%

[image]
CSharpTest.Net
TransformSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RtlProcessKey Class : TransformSize Property

Glossary Item Box

The size of an output block

Syntax

Visual Basic (Declaration)
Protected Overrides ReadOnly Property TransformSize As Integer
C#
protected override int TransformSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RtlProcessKey Class
RtlProcessKey Members
Base Implementation in TransformSize


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
RtlProcessKey Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : RtlProcessKey Class

Glossary Item Box

For a list of all members of this type, see RtlProcessKey members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Encryptor | Returns a single instance of the encryptor, it's thread-safe.
Top

See Also

Reference

RtlProcessKey Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/RtlProcessKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encryptor Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > RtlProcessKey Class : Encryptor Field

Glossary Item Box

Returns a single instance of the encryptor, it's thread-safe.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Encryptor As IEncryptDecrypt
C#
public static readonly IEncryptDecrypt Encryptor

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RtlProcessKey Class
RtlProcessKey Members

Source Code

Library/Crypto/RtlProcessKey.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Salt Class

Glossary Item Box

Represents a random sequence of bytes used to combine with hash and encryption values to provide an extra level of security.

Syntax

Visual Basic (Declaration)
Public Class Salt
   Inherits CSharpTest.Net.Bases.Equatable(Of Salt)
C#
public class Salt : CSharpTest.Net.Bases.Equatable<Salt>

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];

byte[] test1 = new SaltedData(s, testData).ToArray();
Assert.AreEqual(16, test1.Length);
byte[] test2 = IOStream.ReadAllBytes(new SaltedData(s, testData).ToStream());
Assert.AreEqual(16, test2.Length);
byte[] test3 = IOStream.ReadAllBytes(SaltedData.CombineStream(s, new MemoryStream(testData)));
Assert.AreEqual(16, test3.Length);

Assert.AreEqual(test1, test2);
Assert.AreEqual(test1, test3);
Assert.AreEqual(test2, test3);
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}

Dim test1 As Byte() = New SaltedData(s, testData).ToArray()
Assert.AreEqual(16, test1.Length)
Dim test2 As Byte() = IOStream.ReadAllBytes(New SaltedData(s, testData).ToStream())
Assert.AreEqual(16, test2.Length)
Dim test3 As Byte() = IOStream.ReadAllBytes(SaltedData.CombineStream(s, New MemoryStream(testData)))
Assert.AreEqual(16, test3.Length)

Assert.AreEqual(test1, test2)
Assert.AreEqual(test1, test3)
Assert.AreEqual(test2, test3)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Equatable<T>
CSharpTest.Net.Crypto.Salt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Members
CSharpTest.Net.Crypto Namespace
LocalHostKey LocalHostKey.WithSalt(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])
Salt PasswordKey.Salt
PasswordHash Password.CreateHash(Salt)
Salt PasswordHash.Salt
Stream SaltedData.CombineStream(Salt,Stream)
Salt SaltedData.Salt

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Salt Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Salt Class

Glossary Item Box

The following tables list the members exposed by Salt.

Public Constructors

 | Name | Description
Public Constructor | Salt Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | DefaultSize | The size of the salt if unspecified
Top

Public Properties

 | Name | Description
Public Property | BitSize | Returns the size of the salt in bits
Public Property | Length | returns the total length of the salt in bytes
Top

Protected Properties

 | Name | Description
Protected Property | HashCode | Overridden. Returns the hash code of the current salt
Top

Public Methods

 | Name | Description
Public Method | CopyTo | Copy the salt to the specified offset in the byte array
static (Shared in Visual Basic) | CreateBytes | Overloaded. Creates n bytes of data usable as a salt
Public Method | Equals | Overloaded. Overridden. Returns true if the two Salts are using the same data
static (Shared in Visual Basic) | FromBytes | Creates salt from the provided bytes or a hash of the bytes
static (Shared in Visual Basic) | FromString | Recreates a salt value from a string
Public Method | GetData | Overloaded. Returns the salt combined with a copy of the speicified data
Public Method | ToArray | Returns the salt as an array of bytes
Public Method | ToStream | Returns the salt as a stream
Public Method | ToString | Returns the base64 encoding of the salt
Top

See Also

Reference

Salt Class
CSharpTest.Net.Crypto Namespace
LocalHostKey LocalHostKey.WithSalt(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])
Salt PasswordKey.Salt
PasswordHash Password.CreateHash(Salt)
Salt PasswordHash.Salt
Stream SaltedData.CombineStream(Salt,Stream)
Salt SaltedData.Salt

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : Salt Constructor

Glossary Item Box

Overload List

Overload | Description
Salt Constructor() | Creates a new Salt of DefaultSize
Salt Constructor(Size) | Creates a new Salt of the specified size

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class > Salt Constructor : Salt Constructor()

Glossary Item Box

Creates a new Salt of DefaultSize

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public Salt()

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(40, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(40, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(tmp))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(new MemoryStream(tmp)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NET Copy Code
Dim s As New Salt()
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(40, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(40, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(tmp)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(New MemoryStream(tmp))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Overload List

Used By

PasswordHash Password.CreateHash()

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Constructor(Size)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class > Salt Constructor : Salt Constructor(Size)

szBits

Glossary Item Box

Creates a new Salt of the specified size

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal szBits As Salt.Size _
)
C#
public Salt(
   Salt.Size szBits
)

Parameters

szBits

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];

byte[] test1 = new SaltedData(s, testData).ToArray();
Assert.AreEqual(16, test1.Length);
byte[] test2 = IOStream.ReadAllBytes(new SaltedData(s, testData).ToStream());
Assert.AreEqual(16, test2.Length);
byte[] test3 = IOStream.ReadAllBytes(SaltedData.CombineStream(s, new MemoryStream(testData)));
Assert.AreEqual(16, test3.Length);

Assert.AreEqual(test1, test2);
Assert.AreEqual(test1, test3);
Assert.AreEqual(test2, test3);
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}

Dim test1 As Byte() = New SaltedData(s, testData).ToArray()
Assert.AreEqual(16, test1.Length)
Dim test2 As Byte() = IOStream.ReadAllBytes(New SaltedData(s, testData).ToStream())
Assert.AreEqual(16, test2.Length)
Dim test3 As Byte() = IOStream.ReadAllBytes(SaltedData.CombineStream(s, New MemoryStream(testData)))
Assert.AreEqual(16, test3.Length)

Assert.AreEqual(test1, test2)
Assert.AreEqual(test1, test3)
Assert.AreEqual(test2, test3)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Overload List

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Salt Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Salt Class

Glossary Item Box

For a list of all members of this type, see Salt members.

Public Methods

 | Name | Description
Public Method | CopyTo | Copy the salt to the specified offset in the byte array
static (Shared in Visual Basic) | CreateBytes | Overloaded. Creates n bytes of data usable as a salt
Public Method | Equals | Overloaded. Overridden. Returns true if the two Salts are using the same data
static (Shared in Visual Basic) | FromBytes | Creates salt from the provided bytes or a hash of the bytes
static (Shared in Visual Basic) | FromString | Recreates a salt value from a string
Public Method | GetData | Overloaded. Returns the salt combined with a copy of the speicified data
Public Method | ToArray | Returns the salt as an array of bytes
Public Method | ToStream | Returns the salt as a stream
Public Method | ToString | Returns the base64 encoding of the salt
Top

See Also

Reference

Salt Class
CSharpTest.Net.Crypto Namespace
LocalHostKey LocalHostKey.WithSalt(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])
Salt PasswordKey.Salt
PasswordHash Password.CreateHash(Salt)
Salt PasswordHash.Salt
Stream SaltedData.CombineStream(Salt,Stream)
Salt SaltedData.Salt

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : CopyTo Method

array
offset

Glossary Item Box

Copy the salt to the specified offset in the byte array

Syntax

Visual Basic (Declaration)
Public Sub CopyTo( _
   ByVal array() As Byte, _
   ByVal offset As Integer _
)
C#
public void CopyTo(
   byte[] array,
   int offset
)

Parameters

array
offset

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
byte[] bytes = new byte[s.Length];
s.CopyTo(bytes, 0);
Assert.AreEqual(s.ToArray(), bytes);
Assert.AreEqual(s.GetHashCode(), Salt.FromBytes(bytes).GetHashCode());

Salt strcpy = Salt.FromString(s.ToString());
Assert.AreEqual(s.ToArray(), strcpy.ToArray());
Assert.AreEqual(s.ToString(), strcpy.ToString());
Assert.AreEqual(s.GetHashCode(), strcpy.GetHashCode());
VB.NET Copy Code
Dim s As New Salt()
Dim bytes As Byte() = New Byte(s.Length) {}
s.CopyTo(bytes, 0)
Assert.AreEqual(s.ToArray(), bytes)
Assert.AreEqual(s.GetHashCode(), Salt.FromBytes(bytes).GetHashCode())

Dim strcpy As Salt = Salt.FromString(s.ToString())
Assert.AreEqual(s.ToArray(), strcpy.ToArray())
Assert.AreEqual(s.ToString(), strcpy.ToString())
Assert.AreEqual(s.GetHashCode(), strcpy.GetHashCode())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members

Source Code

Library/Crypto/Salt.cs

Used By

Byte[] SaltedData.ToArray()


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : CreateBytes Method

Glossary Item Box

Creates n bytes of data usable as a salt

Overload List

Overload | Description
CreateBytes(Size) | Creates n bytes of data usable as a salt
CreateBytes(Byte[]) | Creates n bytes of data usable as a salt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateBytes(Size) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class > CreateBytes Method : CreateBytes(Size) Method

szBits

Glossary Item Box

Creates n bytes of data usable as a salt

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function CreateBytes( _
   ByVal szBits As Salt.Size _
) As Byte()
C#
public static byte[] CreateBytes(
   Salt.Size szBits
)

Parameters

szBits

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
byte[] test = new byte[16];
Assert.AreEqual(new byte[16], test);
Salt.CreateBytes(test);
Assert.AreNotEqual(new byte[16], test);
Assert.AreNotEqual(Salt.CreateBytes(Salt.Size.b128), test);
VB.NET Copy Code
Dim test As Byte() = New Byte(16) {}
Assert.AreEqual(New Byte(16) {}, test)
Salt.CreateBytes(test)
Assert.AreNotEqual(New Byte(16) {}, test)
Assert.AreNotEqual(Salt.CreateBytes(Salt.Size.b128), test)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Overload List
Salt.Size

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateBytes(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class > CreateBytes Method : CreateBytes(Byte[]) Method

bits

Glossary Item Box

Creates n bytes of data usable as a salt

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub CreateBytes( _
   ByVal bits() As Byte _
)
C#
public static void CreateBytes(
   byte[] bits
)

Parameters

bits

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
byte[] test = new byte[16];
Assert.AreEqual(new byte[16], test);
Salt.CreateBytes(test);
Assert.AreNotEqual(new byte[16], test);
Assert.AreNotEqual(Salt.CreateBytes(Salt.Size.b128), test);
VB.NET Copy Code
Dim test As Byte() = New Byte(16) {}
Assert.AreEqual(New Byte(16) {}, test)
Salt.CreateBytes(test)
Assert.AreNotEqual(New Byte(16) {}, test)
Assert.AreNotEqual(Salt.CreateBytes(Salt.Size.b128), test)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Overload List

Used By

Byte[] Salt.CreateBytes(Salt.Size)

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : Equals Method

Glossary Item Box

Returns true if the two Salts are using the same data

Overload List

Overload | Description
Equals(Salt) | Returns true if the two Salts are using the same data

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Base Implementation in Equals


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Salt) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class > Equals Method : Equals(Salt) Method

other

Glossary Item Box

Returns true if the two Salts are using the same data

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Equals( _
   ByVal other As Salt _
) As Boolean
C#
public override bool Equals(
   Salt other
)

Parameters

other

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Overload List

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : FromBytes Method

bytes
An array of random bytes of 8, 16, 32, or 64 bytes long

Glossary Item Box

Creates salt from the provided bytes or a hash of the bytes

Syntax

Visual Basic (Declaration)
Public Shared Function FromBytes( _
   ByVal bytes() As Byte _
) As Salt
C#
public static Salt FromBytes(
   byte[] bytes
)

Parameters

bytes
An array of random bytes of 8, 16, 32, or 64 bytes long

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
byte[] testValid = Encoding.ASCII.GetBytes("12345678");
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize);
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray());
testValid = null;

//now test with an odd number of bytes, should always hash to Sha256
byte[] notValid = Encoding.ASCII.GetBytes("0123456789");
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize);
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray());

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize);
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray());
VB.NET Copy Code
Dim testValid As Byte() = Encoding.ASCII.GetBytes("12345678")
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize)
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray())
testValid = Nothing

'now test with an odd number of bytes, should always hash to Sha256
Dim notValid As Byte() = Encoding.ASCII.GetBytes("0123456789")
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize)
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray())

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize)
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromString Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : FromString Method

input

Glossary Item Box

Recreates a salt value from a string

Syntax

Visual Basic (Declaration)
Public Shared Function FromString( _
   ByVal input As String _
) As Salt
C#
public static Salt FromString(
   string input
)

Parameters

input

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
byte[] bytes = new byte[s.Length];
s.CopyTo(bytes, 0);
Assert.AreEqual(s.ToArray(), bytes);
Assert.AreEqual(s.GetHashCode(), Salt.FromBytes(bytes).GetHashCode());

Salt strcpy = Salt.FromString(s.ToString());
Assert.AreEqual(s.ToArray(), strcpy.ToArray());
Assert.AreEqual(s.ToString(), strcpy.ToString());
Assert.AreEqual(s.GetHashCode(), strcpy.GetHashCode());
VB.NET Copy Code
Dim s As New Salt()
Dim bytes As Byte() = New Byte(s.Length) {}
s.CopyTo(bytes, 0)
Assert.AreEqual(s.ToArray(), bytes)
Assert.AreEqual(s.GetHashCode(), Salt.FromBytes(bytes).GetHashCode())

Dim strcpy As Salt = Salt.FromString(s.ToString())
Assert.AreEqual(s.ToArray(), strcpy.ToArray())
Assert.AreEqual(s.ToString(), strcpy.ToString())
Assert.AreEqual(s.GetHashCode(), strcpy.GetHashCode())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetData Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : GetData Method

Glossary Item Box

Returns the salt combined with a copy of the speicified data

Overload List

Overload | Description
GetData(Byte[]) | Returns the salt combined with a copy of the speicified data
GetData(Stream) | Returns the salt combined with a copy of the speicified data as a stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetData(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class > GetData Method : GetData(Byte[]) Method

data

Glossary Item Box

Returns the salt combined with a copy of the speicified data

Syntax

Visual Basic (Declaration)
Public Overloads Function GetData( _
   ByVal data() As Byte _
) As SaltedData
C#
public SaltedData GetData(
   byte[] data
)

Parameters

data

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
byte[] bytes = new byte[1024];
new Random().NextBytes(bytes);

SaltedData sd = s.GetData(bytes);
Assert.AreEqual(s, sd.Salt);
Assert.AreEqual(bytes, sd.GetDataBytes());

sd = s.GetData(new MemoryStream(bytes));
Assert.AreEqual(s, sd.Salt);
Assert.AreEqual(bytes, sd.GetDataBytes());
VB.NET Copy Code
Dim s As New Salt()
Dim bytes As Byte() = New Byte(1024) {}
New Random().NextBytes(bytes)

Dim sd As SaltedData = s.GetData(bytes)
Assert.AreEqual(s, sd.Salt)
Assert.AreEqual(bytes, sd.GetDataBytes())

sd = s.GetData(New MemoryStream(bytes))
Assert.AreEqual(s, sd.Salt)
Assert.AreEqual(bytes, sd.GetDataBytes())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Overload List
SaltedData

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetData(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class > GetData Method : GetData(Stream) Method

data

Glossary Item Box

Returns the salt combined with a copy of the speicified data as a stream

Syntax

Visual Basic (Declaration)
Public Overloads Function GetData( _
   ByVal data As Stream _
) As SaltedData
C#
public SaltedData GetData(
   Stream data
)

Parameters

data

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
byte[] bytes = new byte[1024];
new Random().NextBytes(bytes);

SaltedData sd = s.GetData(bytes);
Assert.AreEqual(s, sd.Salt);
Assert.AreEqual(bytes, sd.GetDataBytes());

sd = s.GetData(new MemoryStream(bytes));
Assert.AreEqual(s, sd.Salt);
Assert.AreEqual(bytes, sd.GetDataBytes());
VB.NET Copy Code
Dim s As New Salt()
Dim bytes As Byte() = New Byte(1024) {}
New Random().NextBytes(bytes)

Dim sd As SaltedData = s.GetData(bytes)
Assert.AreEqual(s, sd.Salt)
Assert.AreEqual(bytes, sd.GetDataBytes())

sd = s.GetData(New MemoryStream(bytes))
Assert.AreEqual(s, sd.Salt)
Assert.AreEqual(bytes, sd.GetDataBytes())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Overload List
SaltedData

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : ToArray Method

Glossary Item Box

Returns the salt as an array of bytes

Syntax

Visual Basic (Declaration)
Public Function ToArray() As Byte()
C#
public byte[] ToArray()

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
byte[] testValid = Encoding.ASCII.GetBytes("12345678");
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize);
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray());
testValid = null;

//now test with an odd number of bytes, should always hash to Sha256
byte[] notValid = Encoding.ASCII.GetBytes("0123456789");
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize);
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray());

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize);
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray());
VB.NET Copy Code
Dim testValid As Byte() = Encoding.ASCII.GetBytes("12345678")
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize)
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray())
testValid = Nothing

'now test with an odd number of bytes, should always hash to Sha256
Dim notValid As Byte() = Encoding.ASCII.GetBytes("0123456789")
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize)
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray())

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize)
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members

Used By

AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])
Stream PasswordKey.Encrypt(Stream)

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToStream Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : ToStream Method

Glossary Item Box

Returns the salt as a stream

Syntax

Visual Basic (Declaration)
Public Function ToStream() As Stream
C#
public Stream ToStream()

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
Assert.AreEqual(s.ToArray(), IOStream.ReadAllBytes(s.ToStream()));
VB.NET Copy Code
Dim s As New Salt()
Assert.AreEqual(s.ToArray(), IOStream.ReadAllBytes(s.ToStream()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members

Source Code

Library/Crypto/Salt.cs

Used By

Stream SaltedData.CombineStream(Salt,Stream)


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : ToString Method

Glossary Item Box

Returns the base64 encoding of the salt

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Base Implementation in ToString

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Salt Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Salt Class

Glossary Item Box

For a list of all members of this type, see Salt members.

Public Properties

 | Name | Description
Public Property | BitSize | Returns the size of the salt in bits
Public Property | Length | returns the total length of the salt in bytes
Top

Protected Properties

 | Name | Description
Protected Property | HashCode | Overridden. Returns the hash code of the current salt
Top

See Also

Reference

Salt Class
CSharpTest.Net.Crypto Namespace
LocalHostKey LocalHostKey.WithSalt(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])
Salt PasswordKey.Salt
PasswordHash Password.CreateHash(Salt)
Salt PasswordHash.Salt
Stream SaltedData.CombineStream(Salt,Stream)
Salt SaltedData.Salt

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BitSize Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : BitSize Property

Glossary Item Box

Returns the size of the salt in bits

Syntax

Visual Basic (Declaration)
Public ReadOnly Property BitSize As Salt.Size
C#
public Salt.Size BitSize {get;}

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
byte[] testValid = Encoding.ASCII.GetBytes("12345678");
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize);
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray());
testValid = null;

//now test with an odd number of bytes, should always hash to Sha256
byte[] notValid = Encoding.ASCII.GetBytes("0123456789");
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize);
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray());

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize);
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray());
VB.NET Copy Code
Dim testValid As Byte() = Encoding.ASCII.GetBytes("12345678")
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize)
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray())
testValid = Nothing

'now test with an odd number of bytes, should always hash to Sha256
Dim notValid As Byte() = Encoding.ASCII.GetBytes("0123456789")
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize)
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray())

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize)
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Salt.Size

Used By

Stream PasswordKey.Decrypt(Stream)
Byte[] PasswordKey.Decrypt(Byte[])

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashCode Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : HashCode Property

Glossary Item Box

Returns the hash code of the current salt

Syntax

Visual Basic (Declaration)
Protected Overrides ReadOnly Property HashCode As Integer
C#
protected override int HashCode {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members
Base Implementation in HashCode


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : Length Property

Glossary Item Box

returns the total length of the salt in bytes

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Length As Integer
C#
public int Length {get;}

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
byte[] bytes = new byte[s.Length];
s.CopyTo(bytes, 0);
Assert.AreEqual(s.ToArray(), bytes);
Assert.AreEqual(s.GetHashCode(), Salt.FromBytes(bytes).GetHashCode());

Salt strcpy = Salt.FromString(s.ToString());
Assert.AreEqual(s.ToArray(), strcpy.ToArray());
Assert.AreEqual(s.ToString(), strcpy.ToString());
Assert.AreEqual(s.GetHashCode(), strcpy.GetHashCode());
VB.NET Copy Code
Dim s As New Salt()
Dim bytes As Byte() = New Byte(s.Length) {}
s.CopyTo(bytes, 0)
Assert.AreEqual(s.ToArray(), bytes)
Assert.AreEqual(s.GetHashCode(), Salt.FromBytes(bytes).GetHashCode())

Dim strcpy As Salt = Salt.FromString(s.ToString())
Assert.AreEqual(s.ToArray(), strcpy.ToArray())
Assert.AreEqual(s.ToString(), strcpy.ToString())
Assert.AreEqual(s.GetHashCode(), strcpy.GetHashCode())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members

Used By

Stream PasswordKey.Encrypt(Stream)
Boolean Salt.Equals(Salt)
Byte[] SaltedData.ToArray()

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
Salt Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Salt Class

Glossary Item Box

For a list of all members of this type, see Salt members.

Public Fields

 | Name | Description
Public Field | DefaultSize | The size of the salt if unspecified
Top

See Also

Reference

Salt Class
CSharpTest.Net.Crypto Namespace
LocalHostKey LocalHostKey.WithSalt(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])
Salt PasswordKey.Salt
PasswordHash Password.CreateHash(Salt)
Salt PasswordHash.Salt
Stream SaltedData.CombineStream(Salt,Stream)
Salt SaltedData.Salt

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultSize Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Salt Class : DefaultSize Field

Glossary Item Box

The size of the salt if unspecified

Syntax

Visual Basic (Declaration)
Public Const DefaultSize As Salt.Size
C#
public const Salt.Size DefaultSize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Salt Class
Salt Members

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SaltedData Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SaltedData Class

Glossary Item Box

Represents the combination of Salt and Data together

Object Model

SaltedData ClassSalt Class

Syntax

Visual Basic (Declaration)
Public Class SaltedData
C#
public class SaltedData

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];

byte[] test1 = new SaltedData(s, testData).ToArray();
Assert.AreEqual(16, test1.Length);
byte[] test2 = IOStream.ReadAllBytes(new SaltedData(s, testData).ToStream());
Assert.AreEqual(16, test2.Length);
byte[] test3 = IOStream.ReadAllBytes(SaltedData.CombineStream(s, new MemoryStream(testData)));
Assert.AreEqual(16, test3.Length);

Assert.AreEqual(test1, test2);
Assert.AreEqual(test1, test3);
Assert.AreEqual(test2, test3);
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}

Dim test1 As Byte() = New SaltedData(s, testData).ToArray()
Assert.AreEqual(16, test1.Length)
Dim test2 As Byte() = IOStream.ReadAllBytes(New SaltedData(s, testData).ToStream())
Assert.AreEqual(16, test2.Length)
Dim test3 As Byte() = IOStream.ReadAllBytes(SaltedData.CombineStream(s, New MemoryStream(testData)))
Assert.AreEqual(16, test3.Length)

Assert.AreEqual(test1, test2)
Assert.AreEqual(test1, test3)
Assert.AreEqual(test2, test3)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.SaltedData

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Members
CSharpTest.Net.Crypto Namespace
SaltedData Salt.GetData(Byte[])
SaltedData Salt.GetData(Stream)

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SaltedData Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SaltedData Class

Glossary Item Box

The following tables list the members exposed by SaltedData.

Public Constructors

 | Name | Description
Public Constructor | SaltedData Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Length | Returns the total length of Salt + Data
Public Property | Salt | Returns the Salt being used.
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | CombineStream | Returns a stream that combines the salt and data
Public Method | Dispose | Attempts to clear the data from memory
Public Method | GetDataBytes | Returns a copy of the data bytes
Public Method | GetDataStream | Returns a stream of just the data
Public Method | ToArray | Returns the Array of Salt and Data together
Public Method | ToStream | Returns the Salt and Data as a stream
Top

See Also

Reference

SaltedData Class
CSharpTest.Net.Crypto Namespace
SaltedData Salt.GetData(Byte[])
SaltedData Salt.GetData(Stream)

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SaltedData Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : SaltedData Constructor

Glossary Item Box

Overload List

Overload | Description
SaltedData Constructor(Stream) | Seperates the salt from the data provided
SaltedData Constructor(Byte[]) | Seperates the salt from the data provided
SaltedData Constructor(Byte[],Size) | Seperates the salt from the data provided
SaltedData Constructor(Salt,Stream) | Combines the salt with the data provided
SaltedData Constructor(Salt,Byte[]) | Combines the salt with the data provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SaltedData Constructor(Stream)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class > SaltedData Constructor : SaltedData Constructor(Stream)

saltedData

Glossary Item Box

Seperates the salt from the data provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal saltedData As Stream _
)
C#
public SaltedData(
   Stream saltedData
)

Parameters

saltedData

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(40, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(40, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(tmp))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(new MemoryStream(tmp)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NET Copy Code
Dim s As New Salt()
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(40, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(40, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(tmp)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(New MemoryStream(tmp))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members
Overload List

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SaltedData Constructor(Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class > SaltedData Constructor : SaltedData Constructor(Byte[])

saltedData

Glossary Item Box

Seperates the salt from the data provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal saltedData() As Byte _
)
C#
public SaltedData(
   byte[] saltedData
)

Parameters

saltedData

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt();
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(40, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(40, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(tmp))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(new MemoryStream(tmp)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NET Copy Code
Dim s As New Salt()
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(40, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(40, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(tmp)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(New MemoryStream(tmp))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members
Overload List

Used By

PasswordHash PasswordHash.FromBytes(Byte[])

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SaltedData Constructor(Byte[],Size)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class > SaltedData Constructor : SaltedData Constructor(Byte[],Size)

saltedData
szSalt

Glossary Item Box

Seperates the salt from the data provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal saltedData() As Byte, _
   ByVal szSalt As Salt.Size _
)
C#
public SaltedData(
   byte[] saltedData,
   Salt.Size szSalt
)

Parameters

saltedData
szSalt

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(16, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(16, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(s, new MemoryStream(testData)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(tmp, Salt.Size.b64))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(16, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(16, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(s, New MemoryStream(testData))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(tmp, Salt.Size.b64)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members
Overload List

Used By

Byte[] PasswordKey.Decrypt(Byte[],Salt.Size)

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SaltedData Constructor(Salt,Stream)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class > SaltedData Constructor : SaltedData Constructor(Salt,Stream)

salt
data

Glossary Item Box

Combines the salt with the data provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal salt As Salt, _
   ByVal data As Stream _
)
C#
public SaltedData(
   Salt salt,
   Stream data
)

Parameters

salt
data

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(16, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(16, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(s, new MemoryStream(testData)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(tmp, Salt.Size.b64))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(16, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(16, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(s, New MemoryStream(testData))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(tmp, Salt.Size.b64)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members
Overload List

Used By

SaltedData Salt.GetData(Stream)

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SaltedData Constructor(Salt,Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class > SaltedData Constructor : SaltedData Constructor(Salt,Byte[])

salt
data

Glossary Item Box

Combines the salt with the data provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal salt As Salt, _
   ByVal data() As Byte _
)
C#
public SaltedData(
   Salt salt,
   byte[] data
)

Parameters

salt
data

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];

byte[] test1 = new SaltedData(s, testData).ToArray();
Assert.AreEqual(16, test1.Length);
byte[] test2 = IOStream.ReadAllBytes(new SaltedData(s, testData).ToStream());
Assert.AreEqual(16, test2.Length);
byte[] test3 = IOStream.ReadAllBytes(SaltedData.CombineStream(s, new MemoryStream(testData)));
Assert.AreEqual(16, test3.Length);

Assert.AreEqual(test1, test2);
Assert.AreEqual(test1, test3);
Assert.AreEqual(test2, test3);
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}

Dim test1 As Byte() = New SaltedData(s, testData).ToArray()
Assert.AreEqual(16, test1.Length)
Dim test2 As Byte() = IOStream.ReadAllBytes(New SaltedData(s, testData).ToStream())
Assert.AreEqual(16, test2.Length)
Dim test3 As Byte() = IOStream.ReadAllBytes(SaltedData.CombineStream(s, New MemoryStream(testData)))
Assert.AreEqual(16, test3.Length)

Assert.AreEqual(test1, test2)
Assert.AreEqual(test1, test3)
Assert.AreEqual(test2, test3)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members
Overload List

Used By

Byte[] PasswordKey.Encrypt(Byte[])
SaltedData Salt.GetData(Byte[])

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SaltedData Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SaltedData Class

Glossary Item Box

For a list of all members of this type, see SaltedData members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | CombineStream | Returns a stream that combines the salt and data
Public Method | Dispose | Attempts to clear the data from memory
Public Method | GetDataBytes | Returns a copy of the data bytes
Public Method | GetDataStream | Returns a stream of just the data
Public Method | ToArray | Returns the Array of Salt and Data together
Public Method | ToStream | Returns the Salt and Data as a stream
Top

See Also

Reference

SaltedData Class
CSharpTest.Net.Crypto Namespace
SaltedData Salt.GetData(Byte[])
SaltedData Salt.GetData(Stream)

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CombineStream Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : CombineStream Method

salt
data

Glossary Item Box

Returns a stream that combines the salt and data

Syntax

Visual Basic (Declaration)
Public Shared Function CombineStream( _
   ByVal salt As Salt, _
   ByVal data As Stream _
) As Stream
C#
public static Stream CombineStream(
   Salt salt,
   Stream data
)

Parameters

salt
data

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];

byte[] test1 = new SaltedData(s, testData).ToArray();
Assert.AreEqual(16, test1.Length);
byte[] test2 = IOStream.ReadAllBytes(new SaltedData(s, testData).ToStream());
Assert.AreEqual(16, test2.Length);
byte[] test3 = IOStream.ReadAllBytes(SaltedData.CombineStream(s, new MemoryStream(testData)));
Assert.AreEqual(16, test3.Length);

Assert.AreEqual(test1, test2);
Assert.AreEqual(test1, test3);
Assert.AreEqual(test2, test3);
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}

Dim test1 As Byte() = New SaltedData(s, testData).ToArray()
Assert.AreEqual(16, test1.Length)
Dim test2 As Byte() = IOStream.ReadAllBytes(New SaltedData(s, testData).ToStream())
Assert.AreEqual(16, test2.Length)
Dim test3 As Byte() = IOStream.ReadAllBytes(SaltedData.CombineStream(s, New MemoryStream(testData)))
Assert.AreEqual(16, test3.Length)

Assert.AreEqual(test1, test2)
Assert.AreEqual(test1, test3)
Assert.AreEqual(test2, test3)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members
Salt

Used By

Stream SaltedData.ToStream()

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : Dispose Method

Glossary Item Box

Attempts to clear the data from memory

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members

Used By

PasswordHash.Dispose()

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetDataBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : GetDataBytes Method

Glossary Item Box

Returns a copy of the data bytes

Syntax

Visual Basic (Declaration)
Public Function GetDataBytes() As Byte()
C#
public byte[] GetDataBytes()

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(16, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(16, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(s, new MemoryStream(testData)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(tmp, Salt.Size.b64))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(16, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(16, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(s, New MemoryStream(testData))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(tmp, Salt.Size.b64)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members

Used By

Byte[] PasswordKey.Decrypt(Byte[],Salt.Size)

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetDataStream Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : GetDataStream Method

Glossary Item Box

Returns a stream of just the data

Syntax

Visual Basic (Declaration)
Public Function GetDataStream() As Stream
C#
public Stream GetDataStream()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members

Source Code

Library/Crypto/SaltedData.cs

Used By

Stream SaltedData.ToStream()


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : ToArray Method

Glossary Item Box

Returns the Array of Salt and Data together

Syntax

Visual Basic (Declaration)
Public Function ToArray() As Byte()
C#
public byte[] ToArray()

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];

byte[] test1 = new SaltedData(s, testData).ToArray();
Assert.AreEqual(16, test1.Length);
byte[] test2 = IOStream.ReadAllBytes(new SaltedData(s, testData).ToStream());
Assert.AreEqual(16, test2.Length);
byte[] test3 = IOStream.ReadAllBytes(SaltedData.CombineStream(s, new MemoryStream(testData)));
Assert.AreEqual(16, test3.Length);

Assert.AreEqual(test1, test2);
Assert.AreEqual(test1, test3);
Assert.AreEqual(test2, test3);
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}

Dim test1 As Byte() = New SaltedData(s, testData).ToArray()
Assert.AreEqual(16, test1.Length)
Dim test2 As Byte() = IOStream.ReadAllBytes(New SaltedData(s, testData).ToStream())
Assert.AreEqual(16, test2.Length)
Dim test3 As Byte() = IOStream.ReadAllBytes(SaltedData.CombineStream(s, New MemoryStream(testData)))
Assert.AreEqual(16, test3.Length)

Assert.AreEqual(test1, test2)
Assert.AreEqual(test1, test3)
Assert.AreEqual(test2, test3)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members

Used By

Byte[] PasswordKey.Encrypt(Byte[])
Int32 PasswordHash.CompareTo(PasswordHash)
Byte[] PasswordHash.ToArray()
String PasswordHash.ToString()

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToStream Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : ToStream Method

Glossary Item Box

Returns the Salt and Data as a stream

Syntax

Visual Basic (Declaration)
Public Function ToStream() As Stream
C#
public Stream ToStream()

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];

byte[] test1 = new SaltedData(s, testData).ToArray();
Assert.AreEqual(16, test1.Length);
byte[] test2 = IOStream.ReadAllBytes(new SaltedData(s, testData).ToStream());
Assert.AreEqual(16, test2.Length);
byte[] test3 = IOStream.ReadAllBytes(SaltedData.CombineStream(s, new MemoryStream(testData)));
Assert.AreEqual(16, test3.Length);

Assert.AreEqual(test1, test2);
Assert.AreEqual(test1, test3);
Assert.AreEqual(test2, test3);
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}

Dim test1 As Byte() = New SaltedData(s, testData).ToArray()
Assert.AreEqual(16, test1.Length)
Dim test2 As Byte() = IOStream.ReadAllBytes(New SaltedData(s, testData).ToStream())
Assert.AreEqual(16, test2.Length)
Dim test3 As Byte() = IOStream.ReadAllBytes(SaltedData.CombineStream(s, New MemoryStream(testData)))
Assert.AreEqual(16, test3.Length)

Assert.AreEqual(test1, test2)
Assert.AreEqual(test1, test3)
Assert.AreEqual(test2, test3)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SaltedData Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SaltedData Class

Glossary Item Box

For a list of all members of this type, see SaltedData members.

Public Properties

 | Name | Description
Public Property | Length | Returns the total length of Salt + Data
Public Property | Salt | Returns the Salt being used.
Top

See Also

Reference

SaltedData Class
CSharpTest.Net.Crypto Namespace
SaltedData Salt.GetData(Byte[])
SaltedData Salt.GetData(Stream)

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : Length Property

Glossary Item Box

Returns the total length of Salt + Data

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Length As Integer
C#
public int Length {get;}

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(16, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(16, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(s, new MemoryStream(testData)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(tmp, Salt.Size.b64))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(16, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(16, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(s, New MemoryStream(testData))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(tmp, Salt.Size.b64)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members

Used By

Byte[] SaltedData.ToArray()

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class : Salt Property

Glossary Item Box

Returns the Salt being used.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Salt As Salt
C#
public Salt Salt {get;}

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
Salt s = new Salt(Salt.Size.b64);
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(16, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(16, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(s, new MemoryStream(testData)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(tmp, Salt.Size.b64))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NET Copy Code
Dim s As New Salt(Salt.Size.b64)
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(16, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(16, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(s, New MemoryStream(testData))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(tmp, Salt.Size.b64)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SaltedData Class
SaltedData Members
Salt

Used By

Byte[] PasswordKey.Decrypt(Byte[],Salt.Size)
Byte[] SaltedData.ToArray()
Stream SaltedData.ToStream()

Source Code

Library/Crypto/SaltedData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureStringStream Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureStringStream Class

Glossary Item Box

Allows you to stream raw bytes from a secure string, use UTF16 to decode text

Syntax

Visual Basic (Declaration)
Public Class SecureStringStream
   Inherits CSharpTest.Net.IO.MarshallingStream
C#
public class SecureStringStream : CSharpTest.Net.IO.MarshallingStream

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.BaseStream
CSharpTest.Net.IO.MarshallingStream
CSharpTest.Net.Crypto.SecureStringStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringStream Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureStringStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureStringStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureStringStream Class

Glossary Item Box

The following tables list the members exposed by SecureStringStream.

Public Constructors

 | Name | Description
Public Constructor | SecureStringStream Constructor | Creates a stream from the provided SecureString's contents, use UTF16 to decode text
Top

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes of the decrypted string
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

SecureStringStream Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureStringStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureStringStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringStream Class : SecureStringStream Constructor

str

Glossary Item Box

Creates a stream from the provided SecureString's contents, use UTF16 to decode text

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal str As SecureString _
)
C#
public SecureStringStream(
   SecureString str
)

Parameters

str

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringStream Class
SecureStringStream Members

Source Code

Library/Crypto/SecureStringStream.cs

Used By

TextReader SecureStringUtils.ToTextReader(SecureString)
Stream SecureStringUtils.ToStream(SecureString)


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SecureStringStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureStringStream Class

Glossary Item Box

For a list of all members of this type, see SecureStringStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes of the decrypted string
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

SecureStringStream Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureStringStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringStream Class : Dispose Method

Glossary Item Box

Disposes of the decrypted string

Overload List

Overload | Description
Dispose(Boolean) | Disposes of the decrypted string
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringStream Class
SecureStringStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of the decrypted string

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringStream Class
SecureStringStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureStringUtils Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureStringUtils Class

Glossary Item Box

Various utility methods for access to secure strings. Lets be real about this before you go off, SecureString is NOT secure, it obfuscated. If your in the process you can access it's contents; however, if you looking at a crash dump or swap file then the SecureString provides value... just not much ;) So these methods are actually my attempt to get people to USE a SecureString or similar class (i.e. Password) rather than continuing to use plain text strings. Hopefully with the ease of access within the process we can provide better security without.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class SecureStringUtils
C#
public static class SecureStringUtils

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.SecureStringUtils

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureStringUtils Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureStringUtils Class

Glossary Item Box

The following tables list the members exposed by SecureStringUtils.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | AppendAll<T> | Adds the set of characters and makes the string readonly usage: SecureString s = new SecureString().AppendAll("This is a password");
static (Shared in Visual Basic) | CopyChars | Copies the specified range of characters from the secure string to the output character array.
static (Shared in Visual Basic) | Create | Overloaded. Creates a SecureString from an enumerable set of characters, like: Create("password string");
static (Shared in Visual Basic) | ToByteArray | Overloaded. Converts a System.Security.SecureString into an array of bytes using System.Text.Encoding.Unicode
static (Shared in Visual Basic) | ToCharArray | Returns the secure string as an array of characters
static (Shared in Visual Basic) | ToStream | Returns a stream of Unicode bytes from the give SecureString instance
static (Shared in Visual Basic) | ToTextReader | Returns a stream of Unicode bytes from the give SecureString instance
Top

See Also

Reference

SecureStringUtils Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SecureStringUtils Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureStringUtils Class

Glossary Item Box

For a list of all members of this type, see SecureStringUtils members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | AppendAll<T> | Adds the set of characters and makes the string readonly usage: SecureString s = new SecureString().AppendAll("This is a password");
static (Shared in Visual Basic) | CopyChars | Copies the specified range of characters from the secure string to the output character array.
static (Shared in Visual Basic) | Create | Overloaded. Creates a SecureString from an enumerable set of characters, like: Create("password string");
static (Shared in Visual Basic) | ToByteArray | Overloaded. Converts a System.Security.SecureString into an array of bytes using System.Text.Encoding.Unicode
static (Shared in Visual Basic) | ToCharArray | Returns the secure string as an array of characters
static (Shared in Visual Basic) | ToStream | Returns a stream of Unicode bytes from the give SecureString instance
static (Shared in Visual Basic) | ToTextReader | Returns a stream of Unicode bytes from the give SecureString instance
Top

See Also

Reference

SecureStringUtils Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
AppendAll<T> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class : AppendAll<T> Method

sstr
chEnum

Glossary Item Box

Adds the set of characters and makes the string readonly usage: SecureString s = new SecureString().AppendAll("This is a password");

Syntax

Visual Basic (Declaration)
Public Shared Function AppendAll(Of T As IEnumerable(Of Char))( _
   ByVal sstr As SecureString, _
   ByVal chEnum As T _
) As SecureString
C#
public static SecureString AppendAll<T>(
   SecureString sstr,
   T chEnum
)
where T: IEnumerable<char>

Parameters

sstr
chEnum

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyChars Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class : CopyChars Method

input
inputOffset
output
outputOffset
outputLength

Glossary Item Box

Copies the specified range of characters from the secure string to the output character array.

Syntax

Visual Basic (Declaration)
Public Shared Sub CopyChars( _
   ByVal input As SecureString, _
   ByVal inputOffset As Integer, _
   ByVal output() As Char, _
   ByVal outputOffset As Integer, _
   ByVal outputLength As Integer _
)
C#
public static void CopyChars(
   SecureString input,
   int inputOffset,
   char[] output,
   int outputOffset,
   int outputLength
)

Parameters

input
inputOffset
output
outputOffset
outputLength

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
foreach (SecureString ss in MakeStrings())
{
    char[] temp = new char[TEST_PASSWORD.Length];
    SecureStringUtils.CopyChars(ss, 0, temp, 0, temp.Length);
    Assert.AreEqual(TEST_PASSWORD, new String(temp));

    temp = new char[TEST_PASSWORD.Length];
    SecureStringUtils.CopyChars(ss, 4, temp, 4, temp.Length - 4);
    Assert.AreNotEqual(TEST_PASSWORD, new String(temp));
    SecureStringUtils.CopyChars(ss, 0, temp, 0, 4);
    Assert.AreEqual(TEST_PASSWORD, new String(temp));
}
VB.NET Copy Code
For Each ss As SecureString In MakeStrings()
    Dim temp As Char() = New Char(TEST_PASSWORD.Length) {}
    SecureStringUtils.CopyChars(ss, 0, temp, 0, temp.Length)
    Assert.AreEqual(TEST_PASSWORD, New [String](temp))

    temp = New Char(TEST_PASSWORD.Length) {}
    SecureStringUtils.CopyChars(ss, 4, temp, 4, temp.Length - 4)
    Assert.AreNotEqual(TEST_PASSWORD, New [String](temp))
    SecureStringUtils.CopyChars(ss, 0, temp, 0, 4)
    Assert.AreEqual(TEST_PASSWORD, New [String](temp))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members

Used By

Byte[] SecureStringUtils.ToByteArray(SecureString,Encoding)
Char[] SecureStringUtils.ToCharArray(SecureString)

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class : Create Method

Glossary Item Box

Creates a SecureString from an enumerable set of characters, like: Create("password string");

Overload List

Overload | Description
Create(IEnumerable<Char>) | Creates a SecureString from an enumerable set of characters, like: Create("password string");
Create(Stream) | Creates a SecureString from a stream of unicode characters
Create(Stream,Encoding) | Creates a SecureString from an stream of characters

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Create(IEnumerable<Char>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class > Create Method : Create(IEnumerable<Char>) Method

chEnum

Glossary Item Box

Creates a SecureString from an enumerable set of characters, like: Create("password string");

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Create( _
   ByVal chEnum As IEnumerable(Of Char) _
) As SecureString
C#
public static SecureString Create(
   IEnumerable<char> chEnum
)

Parameters

chEnum

Example

Library/Library.Test/TestPasswordHash.cs

C# Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
{
    //no salt provided
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD)))
        Assert.AreNotEqual(pwd1, pwd2);
    //identical salt
    using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);

    using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt))
        Assert.AreEqual(pwd1, pwd2);
    using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD))
    {
        using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt))
            Assert.AreEqual(pwd1, pwd2);
        using (PasswordHash pwd2 = new PasswordHash(sstr))
            Assert.AreNotEqual(pwd1, pwd2);
    }
}
VB.NET Copy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    'no salt provided
    Using pwd2 As New PasswordHash(TEST_PASSWORD)
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD))
        Assert.AreNotEqual(pwd1, pwd2)
    End Using
    'identical salt
    Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using

    Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt)
        Assert.AreEqual(pwd1, pwd2)
    End Using
    Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD)
        Using pwd2 As New PasswordHash(sstr, pwd1.Salt)
            Assert.AreEqual(pwd1, pwd2)
        End Using
        Using pwd2 As New PasswordHash(sstr)
            Assert.AreNotEqual(pwd1, pwd2)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members
Overload List

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create(Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class > Create Method : Create(Stream) Method

io

Glossary Item Box

Creates a SecureString from a stream of unicode characters

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Create( _
   ByVal io As Stream _
) As SecureString
C#
public static SecureString Create(
   Stream io
)

Parameters

io

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members
Overload List

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create(Stream,Encoding) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class > Create Method : Create(Stream,Encoding) Method

io
encoding

Glossary Item Box

Creates a SecureString from an stream of characters

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Create( _
   ByVal io As Stream, _
   ByVal encoding As Encoding _
) As SecureString
C#
public static SecureString Create(
   Stream io,
   Encoding encoding
)

Parameters

io
encoding

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members
Overload List

Used By

SecureString SecureStringUtils.Create(Stream)
SecureString Password.ToSecureString()

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToByteArray Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class : ToByteArray Method

Glossary Item Box

Converts a System.Security.SecureString into an array of bytes using System.Text.Encoding.Unicode

Overload List

Overload | Description
ToByteArray(SecureString) | Converts a System.Security.SecureString into an array of bytes using System.Text.Encoding.Unicode
ToByteArray(SecureString,Encoding) | Converts a System.Security.SecureString into an array of bytes using the Encoding specified

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ToByteArray(SecureString) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class > ToByteArray Method : ToByteArray(SecureString) Method

data

Glossary Item Box

Converts a System.Security.SecureString into an array of bytes using System.Text.Encoding.Unicode

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function ToByteArray( _
   ByVal data As SecureString _
) As Byte()
C#
public static byte[] ToByteArray(
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(Encoding.Unicode.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss));
    Assert.AreEqual(Encoding.UTF8.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss, Encoding.UTF8));
}
VB.NET Copy Code
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(Encoding.Unicode.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss))
    Assert.AreEqual(Encoding.UTF8.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss, Encoding.UTF8))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members
Overload List

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToByteArray(SecureString,Encoding) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class > ToByteArray Method : ToByteArray(SecureString,Encoding) Method

data
encoding

Glossary Item Box

Converts a System.Security.SecureString into an array of bytes using the Encoding specified

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function ToByteArray( _
   ByVal data As SecureString, _
   ByVal encoding As Encoding _
) As Byte()
C#
public static byte[] ToByteArray(
   SecureString data,
   Encoding encoding
)

Parameters

data
encoding

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(Encoding.Unicode.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss));
    Assert.AreEqual(Encoding.UTF8.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss, Encoding.UTF8));
}
VB.NET Copy Code
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(Encoding.Unicode.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss))
    Assert.AreEqual(Encoding.UTF8.GetBytes(TEST_PASSWORD), SecureStringUtils.ToByteArray(ss, Encoding.UTF8))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members
Overload List

Used By

Byte[] SecureStringUtils.ToByteArray(SecureString)

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToCharArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class : ToCharArray Method

data

Glossary Item Box

Returns the secure string as an array of characters

Syntax

Visual Basic (Declaration)
Public Shared Function ToCharArray( _
   ByVal data As SecureString _
) As Char()
C#
public static char[] ToCharArray(
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(TEST_PASSWORD, new String(SecureStringUtils.ToCharArray(ss)));
}
VB.NET Copy Code
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(TEST_PASSWORD, New [String](SecureStringUtils.ToCharArray(ss)))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToStream Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class : ToStream Method

data

Glossary Item Box

Returns a stream of Unicode bytes from the give SecureString instance

Syntax

Visual Basic (Declaration)
Public Shared Function ToStream( _
   ByVal data As SecureString _
) As Stream
C#
public static Stream ToStream(
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
byte[] expect = Encoding.Unicode.GetBytes(TEST_PASSWORD);
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(expect, IOStream.ReadAllBytes(SecureStringUtils.ToStream(ss)));
    Assert.AreEqual(TEST_PASSWORD, IOStream.ReadAllText(SecureStringUtils.ToStream(ss), Encoding.Unicode));
}
VB.NET Copy Code
Dim expect As Byte() = Encoding.Unicode.GetBytes(TEST_PASSWORD)
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(expect, IOStream.ReadAllBytes(SecureStringUtils.ToStream(ss)))
    Assert.AreEqual(TEST_PASSWORD, IOStream.ReadAllText(SecureStringUtils.ToStream(ss), Encoding.Unicode))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToTextReader Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringUtils Class : ToTextReader Method

data

Glossary Item Box

Returns a stream of Unicode bytes from the give SecureString instance

Syntax

Visual Basic (Declaration)
Public Shared Function ToTextReader( _
   ByVal data As SecureString _
) As TextReader
C#
public static TextReader ToTextReader(
   SecureString data
)

Parameters

data

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(TEST_PASSWORD, SecureStringUtils.ToTextReader(ss).ReadToEnd());

    StringBuilder sb = new StringBuilder();
    using (TextReader r = SecureStringUtils.ToTextReader(ss))
    {
        while (r.Peek() != -1)
        {
            sb.Append((char)r.Read());
            int i = r.Read();
            if (i != -1)
                sb.Append((char)i);
        }
    }
    Assert.AreEqual(TEST_PASSWORD, sb.ToString());

    char[] buffer = new char[TEST_PASSWORD.Length];
    using (TextReader r = new UnicodeReader(SecureStringUtils.ToStream(ss)))
    {
        for (int i = 0; i < buffer.Length; i++)
            Assert.AreEqual(1, r.ReadBlock(buffer, i, buffer.Length - i));
        Assert.AreEqual(0, r.ReadBlock(buffer, 0, buffer.Length));
    }
    Assert.AreEqual(TEST_PASSWORD, new string(buffer));
}
VB.NET Copy Code
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(TEST_PASSWORD, SecureStringUtils.ToTextReader(ss).ReadToEnd())

    Dim sb As New StringBuilder()
    Using r As TextReader = SecureStringUtils.ToTextReader(ss)
        While r.Peek() <> -1
            sb.Append(DirectCast(r.Read(), Char))
            Dim i As Integer = r.Read()
            If i <> -1 Then
                sb.Append(DirectCast(i, Char))
            End If
        End While
    End Using
    Assert.AreEqual(TEST_PASSWORD, sb.ToString())

    Dim buffer As Char() = New Char(TEST_PASSWORD.Length) {}
    Using r As TextReader = New UnicodeReader(SecureStringUtils.ToStream(ss))
        Dim i As Integer = 0
        While i < buffer.Length
            Assert.AreEqual(1, r.ReadBlock(buffer, i, buffer.Length - i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        Assert.AreEqual(0, r.ReadBlock(buffer, 0, buffer.Length))
    End Using
    Assert.AreEqual(TEST_PASSWORD, New String(buffer))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringUtils Class
SecureStringUtils Members

Source Code

Library/Crypto/SecureStringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer Class

Glossary Item Box

SecureTransfer is a static class that contains two user types, Sender and Receiver. Each provide one-half of a secure file transfer protocol. The security is based on pre-shared public keys used to sign all messages between the client and server. Additionally these keys are used durring the session negotiation to exchange a 256-bit session key. The session key is combined with a random salt for each message to produce an AES-256 cryptographic key. The file content is then tranfered with this session key.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class SecureTransfer
C#
public static class SecureTransfer

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.SecureTransfer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer Members
CSharpTest.Net.Crypto Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureTransfer Class Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer Class

Glossary Item Box

The following tables list the members exposed by SecureTransfer.

See Also

Reference

SecureTransfer Class
CSharpTest.Net.Crypto Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.BeginTransferEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.BeginTransferEventArgs Class

Glossary Item Box

Event args that provides details about the start of a transfer

Syntax

Visual Basic (Declaration)
Public Class SecureTransfer.BeginTransferEventArgs
   Inherits System.EventArgs
C#
public class SecureTransfer.BeginTransferEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs
CSharpTest.Net.Crypto.SecureTransfer.BytesReceivedEventArgs
CSharpTest.Net.Crypto.SecureTransfer.CompleteTransferEventArgs
CSharpTest.Net.Crypto.SecureTransfer.DownloadBytesEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.BeginTransferEventArgs Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureTransfer.BeginTransferEventArgs Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.BeginTransferEventArgs Class

Glossary Item Box

The following tables list the members exposed by SecureTransfer.BeginTransferEventArgs.

Public Properties

 | Name | Description
Public Property | Location | The client-provided name of the transfer
Public Property | TotalSize | The full length of the file being transferred
Public Property | TransferId | The client-provided unique identifier for this transfer
Top

See Also

Reference

SecureTransfer.BeginTransferEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SecureTransfer.BeginTransferEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.BeginTransferEventArgs Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.BeginTransferEventArgs members.

Public Properties

 | Name | Description
Public Property | Location | The client-provided name of the transfer
Public Property | TotalSize | The full length of the file being transferred
Public Property | TransferId | The client-provided unique identifier for this transfer
Top

See Also

Reference

SecureTransfer.BeginTransferEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Location Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.BeginTransferEventArgs Class : Location Property

Glossary Item Box

The client-provided name of the transfer

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Location As String
C#
public string Location {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.BeginTransferEventArgs Class
SecureTransfer.BeginTransferEventArgs Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TotalSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.BeginTransferEventArgs Class : TotalSize Property

Glossary Item Box

The full length of the file being transferred

Syntax

Visual Basic (Declaration)
Public ReadOnly Property TotalSize As Long
C#
public long TotalSize {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.BeginTransferEventArgs Class
SecureTransfer.BeginTransferEventArgs Members

Source Code

Library/Crypto/SecureTransferServer.cs

Used By

SecureTransfer.DownloadBytesEventArgs.SetBytes(Int64,Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
TransferId Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.BeginTransferEventArgs Class : TransferId Property

Glossary Item Box

The client-provided unique identifier for this transfer

Syntax

Visual Basic (Declaration)
Public ReadOnly Property TransferId As Guid
C#
public Guid TransferId {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.BeginTransferEventArgs Class
SecureTransfer.BeginTransferEventArgs Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.BytesReceivedEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.BytesReceivedEventArgs Class

Glossary Item Box

Event args that provides details about the contents of a transfer

Syntax

Visual Basic (Declaration)
Public Class SecureTransfer.BytesReceivedEventArgs
   Inherits SecureTransfer.BeginTransferEventArgs
C#
public class SecureTransfer.BytesReceivedEventArgs : SecureTransfer.BeginTransferEventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs
CSharpTest.Net.Crypto.SecureTransfer.BytesReceivedEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.BytesReceivedEventArgs Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureTransfer.BytesReceivedEventArgs Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.BytesReceivedEventArgs Class

Glossary Item Box

The following tables list the members exposed by SecureTransfer.BytesReceivedEventArgs.

Public Properties

 | Name | Description
Public Property | BytesReceived | The bytes that should be written at WriteOffset
Public Property | Location | The client-provided name of the transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TotalSize | The full length of the file being transferred (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TransferId | The client-provided unique identifier for this transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | WriteOffset | The offset at which BytesReceived should be written
Top

See Also

Reference

SecureTransfer.BytesReceivedEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SecureTransfer.BytesReceivedEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.BytesReceivedEventArgs Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.BytesReceivedEventArgs members.

Public Properties

 | Name | Description
Public Property | BytesReceived | The bytes that should be written at WriteOffset
Public Property | Location | The client-provided name of the transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TotalSize | The full length of the file being transferred (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TransferId | The client-provided unique identifier for this transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | WriteOffset | The offset at which BytesReceived should be written
Top

See Also

Reference

SecureTransfer.BytesReceivedEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BytesReceived Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.BytesReceivedEventArgs Class : BytesReceived Property

Glossary Item Box

The bytes that should be written at WriteOffset

Syntax

Visual Basic (Declaration)
Public ReadOnly Property BytesReceived As Byte()
C#
public byte[] BytesReceived {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.BytesReceivedEventArgs Class
SecureTransfer.BytesReceivedEventArgs Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteOffset Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.BytesReceivedEventArgs Class : WriteOffset Property

Glossary Item Box

The offset at which BytesReceived should be written

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WriteOffset As Long
C#
public long WriteOffset {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.BytesReceivedEventArgs Class
SecureTransfer.BytesReceivedEventArgs Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.Client Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Client Class

Glossary Item Box

Provides a file transfer handler for the client-side of file transfers.

Syntax

Visual Basic (Declaration)
Public Class SecureTransfer.Client
C#
public class SecureTransfer.Client

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.SecureTransfer.Client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureTransfer.Client Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Client Class

Glossary Item Box

The following tables list the members exposed by SecureTransfer.Client.

Public Constructors

 | Name | Description
Public Constructor | SecureTransfer.Client Constructor | Constructed to send one or more files to a remove server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated.
Top

Public Properties

 | Name | Description
Public Property | LimitThreads | The maximum number of concurrent calls to the server
Top

Public Methods

 | Name | Description
Public Method | Abort | Aborts the transfer
Public Method | Download | Overloaded. Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.
Public Method | Upload | Overloaded. Called to send a single file to the remove server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.
Top

Public Events

 | Name | Description
Public Event | ProgressChanged | Raised after each block of data is transferred to the server.
Top

See Also

Reference

SecureTransfer.Client Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.Client Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class : SecureTransfer.Client Constructor

privateKey
The private key for this client
serverKey
The public key of the server
sendMessage
A delegate to transfer data to the server and obtain a response

Glossary Item Box

Constructed to send one or more files to a remove server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal privateKey As RSAPrivateKey, _
   ByVal serverKey As RSAPublicKey, _
   ByVal sendMessage As SecureTransfer.Client.TransmitMessageAction _
)
C#
public SecureTransfer.Client(
   RSAPrivateKey privateKey,
   RSAPublicKey serverKey,
   SecureTransfer.Client.TransmitMessageAction sendMessage
)

Parameters

privateKey
The private key for this client
serverKey
The public key of the server
sendMessage
A delegate to transfer data to the server and obtain a response

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SecureTransfer.Client Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Client Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.Client members.

Public Methods

 | Name | Description
Public Method | Abort | Aborts the transfer
Public Method | Download | Overloaded. Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.
Public Method | Upload | Overloaded. Called to send a single file to the remove server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.
Top

See Also

Reference

SecureTransfer.Client Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Abort Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class : Abort Method

Glossary Item Box

Aborts the transfer

Syntax

Visual Basic (Declaration)
Public Sub Abort()
C#
public void Abort()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Download Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class : Download Method

Glossary Item Box

Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.

Overload List

Overload | Description
Download(String,Stream) | Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.
Download(String,String) | Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Download(String,Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class > Download Method : Download(String,Stream) Method

location
A string of up to 1024 bytes in length
output
Any writable stream that can seek

Glossary Item Box

Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.

Syntax

Visual Basic (Declaration)
Public Overloads Function Download( _
   ByVal location As String, _
   ByVal output As Stream _
) As Boolean
C#
public bool Download(
   string location,
   Stream output
)

Parameters

location
A string of up to 1024 bytes in length
output
Any writable stream that can seek

Return Value

True if the file was successfully received by the server

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members
Overload List

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Download(String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class > Download Method : Download(String,String) Method

location
A string of up to 1024 bytes in length
filename
The name of the file to write to

Glossary Item Box

Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.

Syntax

Visual Basic (Declaration)
Public Overloads Function Download( _
   ByVal location As String, _
   ByVal filename As String _
) As Boolean
C#
public bool Download(
   string location,
   string filename
)

Parameters

location
A string of up to 1024 bytes in length
filename
The name of the file to write to

Return Value

True if the file was successfully received by the server

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members
Overload List

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Upload Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class : Upload Method

Glossary Item Box

Called to send a single file to the remove server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.

Overload List

Overload | Description
Upload(String,String) | Called to send a single file to the remove server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.
Upload(String,Int64,Stream) | Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Upload(String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class > Upload Method : Upload(String,String) Method

location
A string of up to 1024 bytes in length
filePath
The file path of the file to transfer

Glossary Item Box

Called to send a single file to the remove server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.

Syntax

Visual Basic (Declaration)
Public Overloads Function Upload( _
   ByVal location As String, _
   ByVal filePath As String _
) As Boolean
C#
public bool Upload(
   string location,
   string filePath
)

Parameters

location
A string of up to 1024 bytes in length
filePath
The file path of the file to transfer

Return Value

True if the file was successfully received by the server

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members
Overload List

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Upload(String,Int64,Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class > Upload Method : Upload(String,Int64,Stream) Method

location
A string of up to 1024 bytes in length
length
The length in bytes to send from the stream
rawInput
The stream to read the data from

Glossary Item Box

Called to send a specific length of bytes to a server identified by serverKey. The transfer is a blocking call and returns on success or raises an exception. If Abort() is called durring the transfer, or if a ProgressChanged event handler raises the OperationCanceledException, the transfer is silently terminated and the method will return false.

Syntax

Visual Basic (Declaration)
Public Overloads Function Upload( _
   ByVal location As String, _
   ByVal length As Long, _
   ByVal rawInput As Stream _
) As Boolean
C#
public bool Upload(
   string location,
   long length,
   Stream rawInput
)

Parameters

location
A string of up to 1024 bytes in length
length
The length in bytes to send from the stream
rawInput
The stream to read the data from

Return Value

True if the file was successfully received by the server

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members
Overload List

Used By

Boolean SecureTransfer.Client.Upload(String,String)

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SecureTransfer.Client Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Client Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.Client members.

Public Properties

 | Name | Description
Public Property | LimitThreads | The maximum number of concurrent calls to the server
Top

See Also

Reference

SecureTransfer.Client Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LimitThreads Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class : LimitThreads Property

Glossary Item Box

The maximum number of concurrent calls to the server

Syntax

Visual Basic (Declaration)
Public Property LimitThreads As Integer
C#
public int LimitThreads {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members

Used By

Boolean SecureTransfer.Client.Upload(String,Int64,Stream)
Boolean SecureTransfer.Client.Download(String,String)


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
SecureTransfer.Client Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Client Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.Client members.

Public Events

 | Name | Description
Public Event | ProgressChanged | Raised after each block of data is transferred to the server.
Top

See Also

Reference

SecureTransfer.Client Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProgressChanged Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Client Class : ProgressChanged Event

Glossary Item Box

Raised after each block of data is transferred to the server.

Syntax

Visual Basic (Declaration)
Public Event ProgressChanged As ProgressChangedEventHandler
C#
public event ProgressChangedEventHandler ProgressChanged

Event Data

The event handler receives an argument of type ProgressChangedEventArgs containing data related to this event. The following ProgressChangedEventArgs properties provide information specific to this event.

Property | Description
ProgressPercentage |
UserState |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client Class
SecureTransfer.Client Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.CompleteTransferEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.CompleteTransferEventArgs Class

Glossary Item Box

Event args that provides details about the completion of a transfer

Object Model

SecureTransfer.CompleteTransferEventArgs ClassHash Class

Syntax

Visual Basic (Declaration)
Public Class SecureTransfer.CompleteTransferEventArgs
   Inherits SecureTransfer.BeginTransferEventArgs
C#
public class SecureTransfer.CompleteTransferEventArgs : SecureTransfer.BeginTransferEventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs
CSharpTest.Net.Crypto.SecureTransfer.CompleteTransferEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.CompleteTransferEventArgs Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureTransfer.CompleteTransferEventArgs Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.CompleteTransferEventArgs Class

Glossary Item Box

The following tables list the members exposed by SecureTransfer.CompleteTransferEventArgs.

Public Properties

 | Name | Description
Public Property | ContentHash | The SHA-256 hash of the entire content file transferred
Public Property | Location | The client-provided name of the transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TotalSize | The full length of the file being transferred (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TransferId | The client-provided unique identifier for this transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Top

See Also

Reference

SecureTransfer.CompleteTransferEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SecureTransfer.CompleteTransferEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.CompleteTransferEventArgs Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.CompleteTransferEventArgs members.

Public Properties

 | Name | Description
Public Property | ContentHash | The SHA-256 hash of the entire content file transferred
Public Property | Location | The client-provided name of the transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TotalSize | The full length of the file being transferred (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TransferId | The client-provided unique identifier for this transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Top

See Also

Reference

SecureTransfer.CompleteTransferEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentHash Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.CompleteTransferEventArgs Class : ContentHash Property

Glossary Item Box

The SHA-256 hash of the entire content file transferred

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContentHash As Hash
C#
public Hash ContentHash {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.CompleteTransferEventArgs Class
SecureTransfer.CompleteTransferEventArgs Members
Hash

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.DownloadBytesEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.DownloadBytesEventArgs Class

Glossary Item Box

Event args that provides details about the contents of a transfer

Syntax

Visual Basic (Declaration)
Public Class SecureTransfer.DownloadBytesEventArgs
   Inherits SecureTransfer.BeginTransferEventArgs
C#
public class SecureTransfer.DownloadBytesEventArgs : SecureTransfer.BeginTransferEventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs
CSharpTest.Net.Crypto.SecureTransfer.DownloadBytesEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.DownloadBytesEventArgs Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureTransfer.DownloadBytesEventArgs Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.DownloadBytesEventArgs Class

Glossary Item Box

The following tables list the members exposed by SecureTransfer.DownloadBytesEventArgs.

Public Properties

 | Name | Description
Public Property | Location | The client-provided name of the transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | ReadLength | The number of bytes to read
Public Property | ReadOffset | The offset at which the bytes should be read
Public Property | TotalSize | The full length of the file being transferred (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TransferId | The client-provided unique identifier for this transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Top

Public Methods

 | Name | Description
Public Method | SetBytes | Returns the number of bytes specified in ReadLenght from the offset of ReadOffset
Top

See Also

Reference

SecureTransfer.DownloadBytesEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SecureTransfer.DownloadBytesEventArgs Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.DownloadBytesEventArgs Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.DownloadBytesEventArgs members.

Public Methods

 | Name | Description
Public Method | SetBytes | Returns the number of bytes specified in ReadLenght from the offset of ReadOffset
Top

See Also

Reference

SecureTransfer.DownloadBytesEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.DownloadBytesEventArgs Class : SetBytes Method

totalSize
bytesRead

Glossary Item Box

Returns the number of bytes specified in ReadLenght from the offset of ReadOffset

Syntax

Visual Basic (Declaration)
Public Sub SetBytes( _
   ByVal totalSize As Long, _
   ByVal bytesRead() As Byte _
)
C#
public void SetBytes(
   long totalSize,
   byte[] bytesRead
)

Parameters

totalSize
bytesRead

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.DownloadBytesEventArgs Class
SecureTransfer.DownloadBytesEventArgs Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SecureTransfer.DownloadBytesEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.DownloadBytesEventArgs Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.DownloadBytesEventArgs members.

Public Properties

 | Name | Description
Public Property | Location | The client-provided name of the transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | ReadLength | The number of bytes to read
Public Property | ReadOffset | The offset at which the bytes should be read
Public Property | TotalSize | The full length of the file being transferred (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Public Property | TransferId | The client-provided unique identifier for this transfer (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs)
Top

See Also

Reference

SecureTransfer.DownloadBytesEventArgs Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadLength Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.DownloadBytesEventArgs Class : ReadLength Property

Glossary Item Box

The number of bytes to read

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ReadLength As Integer
C#
public int ReadLength {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.DownloadBytesEventArgs Class
SecureTransfer.DownloadBytesEventArgs Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadOffset Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.DownloadBytesEventArgs Class : ReadOffset Property

Glossary Item Box

The offset at which the bytes should be read

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ReadOffset As Long
C#
public long ReadOffset {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.DownloadBytesEventArgs Class
SecureTransfer.DownloadBytesEventArgs Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.Server Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Server Class

Glossary Item Box

Provides a file transfer handler for the server-side (receiver) of file transfers.

Syntax

Visual Basic (Declaration)
Public Class SecureTransfer.Server
C#
public class SecureTransfer.Server

Inheritance Hierarchy

System.Object
CSharpTest.Net.Crypto.SecureTransfer.Server

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SecureTransfer.Server Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Server Class

Glossary Item Box

The following tables list the members exposed by SecureTransfer.Server.

Public Constructors

 | Name | Description
Public Constructor | SecureTransfer.Server Constructor | Constructs/reconstructs the server-side receiver to process one or more messages. This class maintains all state in the INameValueStore so it may be destroyed between requests, or there may be multiple instances handling requests, provided that all instances have access to the underlying storage provided by the INameValueStore instance.
Top

Public Properties

 | Name | Description
Public Property | MaxInboundFileChunk | The maximum number of bytes from the file to send, the actual message size will be longer by 100 or so bytes + SHA256 signature length (privateKey.ExportParameters().Modulus.Length). To be certain a client does not exceed a specific size, allow for an addition 2500 bytes.
Public Property | MaxOutboundFileChunk | The maximum number of bytes from the file to send, the actual message size will be longer by 100 or so bytes + SHA256 signature length (privateKey.ExportParameters().Modulus.Length). To be certain a client does not exceed a specific size, allow for an addition 2500 bytes.
Public Property | NonceSize | The number of random bytes to use for a nonce
Top

Protected Properties

 | Name | Description
Protected Property | KeyBytes | The amount of random data returned from the server to generate a session key
Top

Public Methods

 | Name | Description
Public Method | Receive | Processes an inbound message and returns the result
Top

Protected Methods

 | Name | Description
Protected Method | Delete | removes all values for a give transfer
Protected Method | DeleteState | removes the value identified
Protected Method | HasState | returns true if the value exists
Protected Method | ReadState | returns the value identified
Protected Method | WriteState | stores the value identified
Top

Public Events

 | Name | Description
Public Event | BeginTransfer | Raised when a transfer begins
Public Event | BytesReceived | Raised when bytes are received
Public Event | CompleteTransfer | Raised when a transfer completes
Public Event | DownloadBytes | Raised durring a download request
Public Event | ErrorRaised | Raised when an error occurs
Top

See Also

Reference

SecureTransfer.Server Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.Server Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : SecureTransfer.Server Constructor

privateKey
The private key used for this server
clientKey
The public key of the client to allow
storage
The state storage used between requests

Glossary Item Box

Constructs/reconstructs the server-side receiver to process one or more messages. This class maintains all state in the INameValueStore so it may be destroyed between requests, or there may be multiple instances handling requests, provided that all instances have access to the underlying storage provided by the INameValueStore instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal privateKey As RSAPrivateKey, _
   ByVal clientKey As RSAPublicKey, _
   ByVal storage As INameValueStore _
)
C#
public SecureTransfer.Server(
   RSAPrivateKey privateKey,
   RSAPublicKey clientKey,
   INameValueStore storage
)

Parameters

privateKey
The private key used for this server
clientKey
The public key of the client to allow
storage
The state storage used between requests

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SecureTransfer.Server Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Server Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.Server members.

Public Methods

 | Name | Description
Public Method | Receive | Processes an inbound message and returns the result
Top

Protected Methods

 | Name | Description
Protected Method | Delete | removes all values for a give transfer
Protected Method | DeleteState | removes the value identified
Protected Method | HasState | returns true if the value exists
Protected Method | ReadState | returns the value identified
Protected Method | WriteState | stores the value identified
Top

See Also

Reference

SecureTransfer.Server Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : Delete Method

transferId

Glossary Item Box

removes all values for a give transfer

Syntax

Visual Basic (Declaration)
Protected Overridable Sub Delete( _
   ByVal transferId As Guid _
)
C#
protected virtual void Delete(
   Guid transferId
)

Parameters

transferId

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DeleteState Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : DeleteState Method

transferId
name

Glossary Item Box

removes the value identified

Syntax

Visual Basic (Declaration)
Protected Overridable Sub DeleteState( _
   ByVal transferId As Guid, _
   ByVal name As String _
)
C#
protected virtual void DeleteState(
   Guid transferId,
   string name
)

Parameters

transferId
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
HasState Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : HasState Method

transferId
name

Glossary Item Box

returns true if the value exists

Syntax

Visual Basic (Declaration)
Protected Overridable Function HasState( _
   ByVal transferId As Guid, _
   ByVal name As String _
) As Boolean
C#
protected virtual bool HasState(
   Guid transferId,
   string name
)

Parameters

transferId
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadState Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : ReadState Method

transferId
name

Glossary Item Box

returns the value identified

Syntax

Visual Basic (Declaration)
Protected Overridable Function ReadState( _
   ByVal transferId As Guid, _
   ByVal name As String _
) As String
C#
protected virtual string ReadState(
   Guid transferId,
   string name
)

Parameters

transferId
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Receive Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : Receive Method

data

Glossary Item Box

Processes an inbound message and returns the result

Syntax

Visual Basic (Declaration)
Public Function Receive( _
   ByVal data As Stream _
) As Stream
C#
public Stream Receive(
   Stream data
)

Parameters

data

Exceptions

Exception | Description
System.IO.InvalidDataException | Raised for any internal error

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteState Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : WriteState Method

transferId
name
value

Glossary Item Box

stores the value identified

Syntax

Visual Basic (Declaration)
Protected Overridable Sub WriteState( _
   ByVal transferId As Guid, _
   ByVal name As String, _
   ByVal value As String _
)
C#
protected virtual void WriteState(
   Guid transferId,
   string name,
   string value
)

Parameters

transferId
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SecureTransfer.Server Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Server Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.Server members.

Public Properties

 | Name | Description
Public Property | MaxInboundFileChunk | The maximum number of bytes from the file to send, the actual message size will be longer by 100 or so bytes + SHA256 signature length (privateKey.ExportParameters().Modulus.Length). To be certain a client does not exceed a specific size, allow for an addition 2500 bytes.
Public Property | MaxOutboundFileChunk | The maximum number of bytes from the file to send, the actual message size will be longer by 100 or so bytes + SHA256 signature length (privateKey.ExportParameters().Modulus.Length). To be certain a client does not exceed a specific size, allow for an addition 2500 bytes.
Public Property | NonceSize | The number of random bytes to use for a nonce
Top

Protected Properties

 | Name | Description
Protected Property | KeyBytes | The amount of random data returned from the server to generate a session key
Top

See Also

Reference

SecureTransfer.Server Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
KeyBytes Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : KeyBytes Property

Glossary Item Box

The amount of random data returned from the server to generate a session key

Syntax

Visual Basic (Declaration)
Protected Property KeyBytes As Integer
C#
protected int KeyBytes {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxInboundFileChunk Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : MaxInboundFileChunk Property

Glossary Item Box

The maximum number of bytes from the file to send, the actual message size will be longer by 100 or so bytes + SHA256 signature length (privateKey.ExportParameters().Modulus.Length). To be certain a client does not exceed a specific size, allow for an addition 2500 bytes.

Syntax

Visual Basic (Declaration)
Public Property MaxInboundFileChunk As Integer
C#
public int MaxInboundFileChunk {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxOutboundFileChunk Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : MaxOutboundFileChunk Property

Glossary Item Box

The maximum number of bytes from the file to send, the actual message size will be longer by 100 or so bytes + SHA256 signature length (privateKey.ExportParameters().Modulus.Length). To be certain a client does not exceed a specific size, allow for an addition 2500 bytes.

Syntax

Visual Basic (Declaration)
Public Property MaxOutboundFileChunk As Integer
C#
public int MaxOutboundFileChunk {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
NonceSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : NonceSize Property

Glossary Item Box

The number of random bytes to use for a nonce

Syntax

Visual Basic (Declaration)
Public Property NonceSize As Integer
C#
public int NonceSize {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
SecureTransfer.Server Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Server Class

Glossary Item Box

For a list of all members of this type, see SecureTransfer.Server members.

Public Events

 | Name | Description
Public Event | BeginTransfer | Raised when a transfer begins
Public Event | BytesReceived | Raised when bytes are received
Public Event | CompleteTransfer | Raised when a transfer completes
Public Event | DownloadBytes | Raised durring a download request
Public Event | ErrorRaised | Raised when an error occurs
Top

See Also

Reference

SecureTransfer.Server Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureTransferServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BeginTransfer Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : BeginTransfer Event

Glossary Item Box

Raised when a transfer begins

Syntax

Visual Basic (Declaration)
Public Event BeginTransfer As EventHandler(Of SecureTransfer.BeginTransferEventArgs)
C#
public event EventHandler<SecureTransfer.BeginTransferEventArgs> BeginTransfer

Event Data

The event handler receives an argument of type SecureTransfer.BeginTransferEventArgs containing data related to this event. The following SecureTransfer.BeginTransferEventArgs properties provide information specific to this event.

Property | Description
Location | The client-provided name of the transfer
TotalSize | The full length of the file being transferred
TransferId | The client-provided unique identifier for this transfer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BytesReceived Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : BytesReceived Event

Glossary Item Box

Raised when bytes are received

Syntax

Visual Basic (Declaration)
Public Event BytesReceived As EventHandler(Of SecureTransfer.BytesReceivedEventArgs)
C#
public event EventHandler<SecureTransfer.BytesReceivedEventArgs> BytesReceived

Event Data

The event handler receives an argument of type SecureTransfer.BytesReceivedEventArgs containing data related to this event. The following SecureTransfer.BytesReceivedEventArgs properties provide information specific to this event.

Property | Description
BytesReceived | The bytes that should be written at WriteOffset
Location (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The client-provided name of the transfer
TotalSize (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The full length of the file being transferred
TransferId (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The client-provided unique identifier for this transfer
WriteOffset | The offset at which BytesReceived should be written

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CompleteTransfer Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : CompleteTransfer Event

Glossary Item Box

Raised when a transfer completes

Syntax

Visual Basic (Declaration)
Public Event CompleteTransfer As EventHandler(Of SecureTransfer.CompleteTransferEventArgs)
C#
public event EventHandler<SecureTransfer.CompleteTransferEventArgs> CompleteTransfer

Event Data

The event handler receives an argument of type SecureTransfer.CompleteTransferEventArgs containing data related to this event. The following SecureTransfer.CompleteTransferEventArgs properties provide information specific to this event.

Property | Description
ContentHash | The SHA-256 hash of the entire content file transferred
Location (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The client-provided name of the transfer
TotalSize (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The full length of the file being transferred
TransferId (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The client-provided unique identifier for this transfer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DownloadBytes Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : DownloadBytes Event

Glossary Item Box

Raised durring a download request

Syntax

Visual Basic (Declaration)
Public Event DownloadBytes As EventHandler(Of SecureTransfer.DownloadBytesEventArgs)
C#
public event EventHandler<SecureTransfer.DownloadBytesEventArgs> DownloadBytes

Event Data

The event handler receives an argument of type SecureTransfer.DownloadBytesEventArgs containing data related to this event. The following SecureTransfer.DownloadBytesEventArgs properties provide information specific to this event.

Property | Description
Location (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The client-provided name of the transfer
ReadLength | The number of bytes to read
ReadOffset | The offset at which the bytes should be read
TotalSize (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The full length of the file being transferred
TransferId (Inherited from CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs) | The client-provided unique identifier for this transfer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ErrorRaised Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureTransfer.Server Class : ErrorRaised Event

Glossary Item Box

Raised when an error occurs

Syntax

Visual Basic (Declaration)
Public Event ErrorRaised As ErrorEventHandler
C#
public event ErrorEventHandler ErrorRaised

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Server Class
SecureTransfer.Server Members


%%PageItemTitle%%

[image]
CSharpTest.Net
UnicodeReader Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : UnicodeReader Class

Glossary Item Box

Bufferless stream reader for Unicode data

Syntax

Visual Basic (Declaration)
Public Class UnicodeReader
   Inherits System.IO.TextReader
C#
public class UnicodeReader : System.IO.TextReader

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(TEST_PASSWORD, SecureStringUtils.ToTextReader(ss).ReadToEnd());

    StringBuilder sb = new StringBuilder();
    using (TextReader r = SecureStringUtils.ToTextReader(ss))
    {
        while (r.Peek() != -1)
        {
            sb.Append((char)r.Read());
            int i = r.Read();
            if (i != -1)
                sb.Append((char)i);
        }
    }
    Assert.AreEqual(TEST_PASSWORD, sb.ToString());

    char[] buffer = new char[TEST_PASSWORD.Length];
    using (TextReader r = new UnicodeReader(SecureStringUtils.ToStream(ss)))
    {
        for (int i = 0; i < buffer.Length; i++)
            Assert.AreEqual(1, r.ReadBlock(buffer, i, buffer.Length - i));
        Assert.AreEqual(0, r.ReadBlock(buffer, 0, buffer.Length));
    }
    Assert.AreEqual(TEST_PASSWORD, new string(buffer));
}
VB.NET Copy Code
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(TEST_PASSWORD, SecureStringUtils.ToTextReader(ss).ReadToEnd())

    Dim sb As New StringBuilder()
    Using r As TextReader = SecureStringUtils.ToTextReader(ss)
        While r.Peek() <> -1
            sb.Append(DirectCast(r.Read(), Char))
            Dim i As Integer = r.Read()
            If i <> -1 Then
                sb.Append(DirectCast(i, Char))
            End If
        End While
    End Using
    Assert.AreEqual(TEST_PASSWORD, sb.ToString())

    Dim buffer As Char() = New Char(TEST_PASSWORD.Length) {}
    Using r As TextReader = New UnicodeReader(SecureStringUtils.ToStream(ss))
        Dim i As Integer = 0
        While i < buffer.Length
            Assert.AreEqual(1, r.ReadBlock(buffer, i, buffer.Length - i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        Assert.AreEqual(0, r.ReadBlock(buffer, 0, buffer.Length))
    End Using
    Assert.AreEqual(TEST_PASSWORD, New String(buffer))
Next

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.TextReader
CSharpTest.Net.Crypto.UnicodeReader

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
UnicodeReader Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : UnicodeReader Class

Glossary Item Box

The following tables list the members exposed by UnicodeReader.

Public Constructors

 | Name | Description
Public Constructor | UnicodeReader Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Close | Closes the System.IO.TextReader and releases any system resources associated with the TextReader. (Inherited from System.IO.TextReader)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes the underlying stream
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Peek | Overridden. Returns the next character
Public Method | Read | Overloaded. Overridden. Returns the next character
Public Method | ReadBlock | Overridden. Reads one character
Public Method | ReadLine | Reads a line of characters from the current stream and returns the data as a string. (Inherited from System.IO.TextReader)
Public Method | ReadToEnd | Reads all characters from the current position to the end of the TextReader and returns them as one string. (Inherited from System.IO.TextReader)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

UnicodeReader Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UnicodeReader Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class : UnicodeReader Constructor

Glossary Item Box

Overload List

Overload | Description
UnicodeReader Constructor(Stream) | Bufferless stream reader for Unicode data
UnicodeReader Constructor(Stream,Encoding) | Bufferless stream reader for Unicode data

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members


%%PageItemTitle%%

[image]
CSharpTest.Net
UnicodeReader Constructor(Stream)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class > UnicodeReader Constructor : UnicodeReader Constructor(Stream)

stream

Glossary Item Box

Bufferless stream reader for Unicode data

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream _
)
C#
public UnicodeReader(
   Stream stream
)

Parameters

stream

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(TEST_PASSWORD, SecureStringUtils.ToTextReader(ss).ReadToEnd());

    StringBuilder sb = new StringBuilder();
    using (TextReader r = SecureStringUtils.ToTextReader(ss))
    {
        while (r.Peek() != -1)
        {
            sb.Append((char)r.Read());
            int i = r.Read();
            if (i != -1)
                sb.Append((char)i);
        }
    }
    Assert.AreEqual(TEST_PASSWORD, sb.ToString());

    char[] buffer = new char[TEST_PASSWORD.Length];
    using (TextReader r = new UnicodeReader(SecureStringUtils.ToStream(ss)))
    {
        for (int i = 0; i < buffer.Length; i++)
            Assert.AreEqual(1, r.ReadBlock(buffer, i, buffer.Length - i));
        Assert.AreEqual(0, r.ReadBlock(buffer, 0, buffer.Length));
    }
    Assert.AreEqual(TEST_PASSWORD, new string(buffer));
}
VB.NET Copy Code
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(TEST_PASSWORD, SecureStringUtils.ToTextReader(ss).ReadToEnd())

    Dim sb As New StringBuilder()
    Using r As TextReader = SecureStringUtils.ToTextReader(ss)
        While r.Peek() <> -1
            sb.Append(DirectCast(r.Read(), Char))
            Dim i As Integer = r.Read()
            If i <> -1 Then
                sb.Append(DirectCast(i, Char))
            End If
        End While
    End Using
    Assert.AreEqual(TEST_PASSWORD, sb.ToString())

    Dim buffer As Char() = New Char(TEST_PASSWORD.Length) {}
    Using r As TextReader = New UnicodeReader(SecureStringUtils.ToStream(ss))
        Dim i As Integer = 0
        While i < buffer.Length
            Assert.AreEqual(1, r.ReadBlock(buffer, i, buffer.Length - i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        Assert.AreEqual(0, r.ReadBlock(buffer, 0, buffer.Length))
    End Using
    Assert.AreEqual(TEST_PASSWORD, New String(buffer))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Overload List

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UnicodeReader Constructor(Stream,Encoding)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class > UnicodeReader Constructor : UnicodeReader Constructor(Stream,Encoding)

stream
encoding

Glossary Item Box

Bufferless stream reader for Unicode data

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream, _
   ByVal encoding As Encoding _
)
C#
public UnicodeReader(
   Stream stream,
   Encoding encoding
)

Parameters

stream
encoding

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Overload List

Used By

TextReader SecureStringUtils.ToTextReader(SecureString)
TextReader Password.ReadText()

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
UnicodeReader Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : UnicodeReader Class

Glossary Item Box

For a list of all members of this type, see UnicodeReader members.

Public Methods

 | Name | Description
Public Method | Close | Closes the System.IO.TextReader and releases any system resources associated with the TextReader. (Inherited from System.IO.TextReader)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes the underlying stream
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Peek | Overridden. Returns the next character
Public Method | Read | Overloaded. Overridden. Returns the next character
Public Method | ReadBlock | Overridden. Reads one character
Public Method | ReadLine | Reads a line of characters from the current stream and returns the data as a string. (Inherited from System.IO.TextReader)
Public Method | ReadToEnd | Reads all characters from the current position to the end of the TextReader and returns them as one string. (Inherited from System.IO.TextReader)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

UnicodeReader Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class : Dispose Method

Glossary Item Box

Disposes the underlying stream

Overload List

Overload | Description
Dispose(Boolean) | Disposes the underlying stream
Dispose() | Releases all resources used by the System.IO.TextReader object. (Inherited from System.IO.TextReader)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes the underlying stream

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Peek Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class : Peek Method

Glossary Item Box

Returns the next character

Syntax

Visual Basic (Declaration)
Public Overrides Function Peek() As Integer
C#
public override int Peek()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Base Implementation in Peek

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class : Read Method

Glossary Item Box

Returns the next character

Overload List

Overload | Description
Read() | Returns the next character
Read(Char[],Int32,Int32) | Reads one character

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Base Implementation in Read


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class > Read Method : Read() Method

Glossary Item Box

Returns the next character

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Read() As Integer
C#
public override int Read()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Overload List
Base Implementation in Read()

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Char[],Int32,Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class > Read Method : Read(Char[],Int32,Int32) Method

buffer
index
count

Glossary Item Box

Reads one character

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Read( _
   ByVal buffer() As Char, _
   ByVal index As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int Read(
   char[] buffer,
   int index,
   int count
)

Parameters

buffer
index
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Overload List
Base Implementation in Read(Char[],Int32,Int32)

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadBlock Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > UnicodeReader Class : ReadBlock Method

buffer
index
count

Glossary Item Box

Reads one character

Syntax

Visual Basic (Declaration)
Public Overrides Function ReadBlock( _
   ByVal buffer() As Char, _
   ByVal index As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int ReadBlock(
   char[] buffer,
   int index,
   int count
)

Parameters

buffer
index
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UnicodeReader Class
UnicodeReader Members
Base Implementation in ReadBlock

Source Code

Library/Crypto/UnicodeReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WhirlpoolManaged Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : WhirlpoolManaged Class

Glossary Item Box

The Whirlpool hashing function. References The Whirlpool algorithm was developed by Paulo S. L. M. Barreto and Vincent Rijmen. See P.S.L.M. Barreto, V. Rijmen, ``The Whirlpool hashing function,'' NESSIE submission, 2000 (tweaked version, 2001), https://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/whirlpool.zip @author Paulo S.L.M. Barreto @author Vincent Rijmen. ============================================================================= .Net Coversion on May 2010 by Roger O Knapp http://csharptest.net Performance considerations: coult be improved by moving to unmanaged/unsafe implementations, currently SHA512 is about 10% faster. The code remains, as much as was possible, exactly as it appears in the example 'c' implementation available from the documentation package on http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html ============================================================================= @version 3.0 (2003.03.12) ============================================================================= Differences from version 2.1: - Suboptimal diffusion matrix replaced by cir(1, 1, 4, 1, 8, 5, 2, 9). ============================================================================= Differences from version 2.0: - Generation of ISO/IEC 10118-3 test vectors. - Bug fix: nonzero carry was ignored when tallying the data length (this bug apparently only manifested itself when feeding data in pieces rather than in a single chunk at once). - Support for MS Visual C++ 64-bit integer arithmetic. Differences from version 1.0: - Original S-box replaced by the tweaked, hardware-efficient version. ============================================================================= THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Syntax

Visual Basic (Declaration)
Public Class WhirlpoolManaged
   Inherits System.Security.Cryptography.HashAlgorithm
C#
public class WhirlpoolManaged : System.Security.Cryptography.HashAlgorithm

Example

Library/Library.Test/TestWhirlpoolHash.cs

C# Copy Code
byte[] speedInput = System.Text.Encoding.ASCII.GetBytes("12345678901234567890123456789012345678901234567890123456789012345678901234567890");

Stopwatch sw;

HashAlgorithm sha512 = SHA512.Create();
WhirlpoolManaged alg = new WhirlpoolManaged();

for (int rep = 3; rep > 0; rep--)
{
    sw = new Stopwatch();
    sw.Start();
    for (int i = 0; i < 100000; i++)
        sha512.ComputeHash(speedInput);
    sw.Stop();
    Console.WriteLine("100000 SHA512 in     {0}", sw.Elapsed);

    sw = new Stopwatch();
    sw.Start();
    for (int i = 0; i < 100000; i++)
        alg.ComputeHash(speedInput);
    sw.Stop();
    Console.WriteLine("100000 WhirlpoolT in {0}", sw.Elapsed);
}
VB.NET Copy Code
Dim speedInput As Byte() = System.Text.Encoding.ASCII.GetBytes("12345678901234567890123456789012345678901234567890123456789012345678901234567890")

Dim sw As Stopwatch

Dim sha512 As HashAlgorithm = SHA512.Create()
Dim alg As New WhirlpoolManaged()

Dim rep As Integer = 3
While rep > 0
    sw = New Stopwatch()
    sw.Start()
    Dim i As Integer = 0
    While i < 100000
        sha512.ComputeHash(speedInput)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    sw.[Stop]()
    Console.WriteLine("100000 SHA512 in     {0}", sw.Elapsed)

    sw = New Stopwatch()
    sw.Start()
    Dim i As Integer = 0
    While i < 100000
        alg.ComputeHash(speedInput)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    sw.[Stop]()
    Console.WriteLine("100000 WhirlpoolT in {0}", sw.Elapsed)
    System.Math.Max(System.Threading.Interlocked.Decrement(rep),rep + 1)
End While

Inheritance Hierarchy

System.Object
System.Security.Cryptography.HashAlgorithm
CSharpTest.Net.Crypto.WhirlpoolManaged

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WhirlpoolManaged Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/WhirlpoolManaged.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
WhirlpoolManaged Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : WhirlpoolManaged Class

Glossary Item Box

The following tables list the members exposed by WhirlpoolManaged.

Public Constructors

 | Name | Description
Public Constructor | WhirlpoolManaged Constructor |
Top

Protected Fields

 | Name | Description
Protected Field | HashSizeValue | Represents the size, in bits, of the computed hash code. (Inherited from System.Security.Cryptography.HashAlgorithm)
Protected Field | State | Represents the state of the hash computation. (Inherited from System.Security.Cryptography.HashAlgorithm)
Top

Public Properties

 | Name | Description
Public Property | CanReuseTransform | Gets a value indicating whether the current transform can be reused. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | CanTransformMultipleBlocks | When overridden in a derived class, gets a value indicating whether multiple blocks can be transformed. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | Hash | Gets the value of the computed hash code. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | HashSize | Gets the size, in bits, of the computed hash code. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | InputBlockSize | When overridden in a derived class, gets the input block size. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | OutputBlockSize | When overridden in a derived class, gets the output block size. (Inherited from System.Security.Cryptography.HashAlgorithm)
Top

Public Methods

 | Name | Description
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.HashAlgorithm class. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Method | ComputeHash | Overloaded. Computes the hash value for the specified System.IO.Stream object. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Method | Initialize | Overridden. Re-initializes the hash algorithm data structures.
Public Method | TransformBlock | Computes the hash value for the specified region of the input byte array and copies the specified region of the input byte array to the specified region of the output byte array. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Method | TransformFinalBlock | Computes the hash value for the specified region of the specified byte array. (Inherited from System.Security.Cryptography.HashAlgorithm)
Top

Protected Methods

 | Name | Description
Protected Method | Dispose | Releases the unmanaged resources used by the System.Security.Cryptography.HashAlgorithm and optionally releases the managed resources. (Inherited from System.Security.Cryptography.HashAlgorithm)
Protected Method | HashCore | Overridden. Adds the provided bytes to the hash
Protected Method | HashFinal | Overridden. Returns the resulting hash code
Top

See Also

Reference

WhirlpoolManaged Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/WhirlpoolManaged.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WhirlpoolManaged Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > WhirlpoolManaged Class : WhirlpoolManaged Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public WhirlpoolManaged()

Example

Library/Library.Test/TestWhirlpoolHash.cs

C# Copy Code
byte[] speedInput = System.Text.Encoding.ASCII.GetBytes("12345678901234567890123456789012345678901234567890123456789012345678901234567890");

Stopwatch sw;

HashAlgorithm sha512 = SHA512.Create();
WhirlpoolManaged alg = new WhirlpoolManaged();

for (int rep = 3; rep > 0; rep--)
{
    sw = new Stopwatch();
    sw.Start();
    for (int i = 0; i < 100000; i++)
        sha512.ComputeHash(speedInput);
    sw.Stop();
    Console.WriteLine("100000 SHA512 in     {0}", sw.Elapsed);

    sw = new Stopwatch();
    sw.Start();
    for (int i = 0; i < 100000; i++)
        alg.ComputeHash(speedInput);
    sw.Stop();
    Console.WriteLine("100000 WhirlpoolT in {0}", sw.Elapsed);
}
VB.NET Copy Code
Dim speedInput As Byte() = System.Text.Encoding.ASCII.GetBytes("12345678901234567890123456789012345678901234567890123456789012345678901234567890")

Dim sw As Stopwatch

Dim sha512 As HashAlgorithm = SHA512.Create()
Dim alg As New WhirlpoolManaged()

Dim rep As Integer = 3
While rep > 0
    sw = New Stopwatch()
    sw.Start()
    Dim i As Integer = 0
    While i < 100000
        sha512.ComputeHash(speedInput)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    sw.[Stop]()
    Console.WriteLine("100000 SHA512 in     {0}", sw.Elapsed)

    sw = New Stopwatch()
    sw.Start()
    Dim i As Integer = 0
    While i < 100000
        alg.ComputeHash(speedInput)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    sw.[Stop]()
    Console.WriteLine("100000 WhirlpoolT in {0}", sw.Elapsed)
    System.Math.Max(System.Threading.Interlocked.Decrement(rep),rep + 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WhirlpoolManaged Class
WhirlpoolManaged Members

Source Code

Library/Crypto/WhirlpoolManaged.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
WhirlpoolManaged Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : WhirlpoolManaged Class

Glossary Item Box

For a list of all members of this type, see WhirlpoolManaged members.

Public Methods

 | Name | Description
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.HashAlgorithm class. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Method | ComputeHash | Overloaded. Computes the hash value for the specified System.IO.Stream object. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Method | Initialize | Overridden. Re-initializes the hash algorithm data structures.
Public Method | TransformBlock | Computes the hash value for the specified region of the input byte array and copies the specified region of the input byte array to the specified region of the output byte array. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Method | TransformFinalBlock | Computes the hash value for the specified region of the specified byte array. (Inherited from System.Security.Cryptography.HashAlgorithm)
Top

Protected Methods

 | Name | Description
Protected Method | Dispose | Releases the unmanaged resources used by the System.Security.Cryptography.HashAlgorithm and optionally releases the managed resources. (Inherited from System.Security.Cryptography.HashAlgorithm)
Protected Method | HashCore | Overridden. Adds the provided bytes to the hash
Protected Method | HashFinal | Overridden. Returns the resulting hash code
Top

See Also

Reference

WhirlpoolManaged Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/WhirlpoolManaged.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HashCore Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > WhirlpoolManaged Class : HashCore Method

array
ibStart
cbSize

Glossary Item Box

Adds the provided bytes to the hash

Syntax

Visual Basic (Declaration)
Protected Overrides Sub HashCore( _
   ByVal array() As Byte, _
   ByVal ibStart As Integer, _
   ByVal cbSize As Integer _
)
C#
protected override void HashCore(
   byte[] array,
   int ibStart,
   int cbSize
)

Parameters

array
ibStart
cbSize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WhirlpoolManaged Class
WhirlpoolManaged Members
Base Implementation in HashCore


%%PageItemTitle%%

[image]
CSharpTest.Net
HashFinal Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > WhirlpoolManaged Class : HashFinal Method

Glossary Item Box

Returns the resulting hash code

Syntax

Visual Basic (Declaration)
Protected Overrides Function HashFinal() As Byte()
C#
protected override byte[] HashFinal()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WhirlpoolManaged Class
WhirlpoolManaged Members
Base Implementation in HashFinal


%%PageItemTitle%%

[image]
CSharpTest.Net
Initialize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > WhirlpoolManaged Class : Initialize Method

Glossary Item Box

Re-initializes the hash algorithm data structures.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Initialize()
C#
public override void Initialize()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WhirlpoolManaged Class
WhirlpoolManaged Members
Base Implementation in Initialize

Source Code

Library/Crypto/WhirlpoolManaged.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt.Size Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Salt.Size Enumeration

Glossary Item Box

Size of a salt-key in bits

Syntax

Visual Basic (Declaration)
Public Enum Salt.Size
   Inherits System.Enum
C#
public enum Salt.Size : System.Enum

Members

Member | Description
b1024 | 1024-bit, 128-byte salt value
b128 | 128-bit, 16-byte salt value
b256 | 256-bit, 32-byte salt value
b512 | 512-bit, 64-byte salt value
b64 | 64-bit, 8-byte salt value

Example

Library/Library.Test/TestSalt.cs

C# Copy Code
byte[] testValid = Encoding.ASCII.GetBytes("12345678");
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize);
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray());
testValid = null;

//now test with an odd number of bytes, should always hash to Sha256
byte[] notValid = Encoding.ASCII.GetBytes("0123456789");
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize);
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray());

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize);
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray());
VB.NET Copy Code
Dim testValid As Byte() = Encoding.ASCII.GetBytes("12345678")
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize)
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray())
testValid = Nothing

'now test with an odd number of bytes, should always hash to Sha256
Dim notValid As Byte() = Encoding.ASCII.GetBytes("0123456789")
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize)
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray())

Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize)
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray())

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Crypto.Salt.Size

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Crypto Namespace
Stream PasswordKey.Decrypt(Stream,Salt.Size)
Byte[] PasswordKey.Decrypt(Byte[],Salt.Size)
Byte[] Salt.CreateBytes(Salt.Size)
Salt.Size Salt.BitSize

Source Code

Library/Crypto/Salt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IEncryptDecrypt Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : IEncryptDecrypt Interface

Glossary Item Box

A simple interface for encrypting and decrypting strings, obtain an instance through the static Encryption inteface calss.

Syntax

Visual Basic (Declaration)
Public Interface IEncryptDecrypt
C#
public interface IEncryptDecrypt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IEncryptDecrypt Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : IEncryptDecrypt Interface

Glossary Item Box

The following tables list the members exposed by IEncryptDecrypt.

Public Methods

 | Name | Description
Method | Decrypt | Overloaded. Decrypts a stream of data
Method | Encrypt | Overloaded. Encrypts a stream of data
Top

See Also

Reference

IEncryptDecrypt Interface
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IEncryptDecrypt Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : IEncryptDecrypt Interface

Glossary Item Box

For a list of all members of this type, see IEncryptDecrypt members.

Public Methods

 | Name | Description
Method | Decrypt | Overloaded. Decrypts a stream of data
Method | Encrypt | Overloaded. Encrypts a stream of data
Top

See Also

Reference

IEncryptDecrypt Interface
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface : Decrypt Method

Glossary Item Box

Decrypts a stream of data

Overload List

Overload | Description
Decrypt(Stream) | Decrypts a stream of data
Decrypt(Byte[]) | Decrypts a raw data block as a set of bytes
Decrypt(String) | Decrypts a string from base-64 encoded text
Decrypt(String,ByteEncoding) | Decrypts a string from the specified encoding format

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Decrypt Method : Decrypt(Stream) Method

stream

Glossary Item Box

Decrypts a stream of data

Syntax

Visual Basic (Declaration)
Overloads Function Decrypt( _
   ByVal stream As Stream _
) As Stream
C#
Stream Decrypt(
   Stream stream
)

Parameters

stream

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members
Overload List

Source Code

Library/Crypto/IEncryptDecrypt.cs

Used By

Stream Password.ReadBytes()


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Decrypt Method : Decrypt(Byte[]) Method

blob

Glossary Item Box

Decrypts a raw data block as a set of bytes

Syntax

Visual Basic (Declaration)
Overloads Function Decrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
byte[] Decrypt(
   byte[] blob
)

Parameters

blob

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members
Overload List

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Decrypt Method : Decrypt(String) Method

text

Glossary Item Box

Decrypts a string from base-64 encoded text

Syntax

Visual Basic (Declaration)
Overloads Function Decrypt( _
   ByVal text As String _
) As String
C#
string Decrypt(
   string text
)

Parameters

text

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members
Overload List

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrypt(String,ByteEncoding) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Decrypt Method : Decrypt(String,ByteEncoding) Method

text
encoding

Glossary Item Box

Decrypts a string from the specified encoding format

Syntax

Visual Basic (Declaration)
Overloads Function Decrypt( _
   ByVal text As String, _
   ByVal encoding As ByteEncoding _
) As String
C#
string Decrypt(
   string text,
   ByteEncoding encoding
)

Parameters

text
encoding

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members
Overload List
ByteEncoding

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface : Encrypt Method

Glossary Item Box

Encrypts a stream of data

Overload List

Overload | Description
Encrypt(Stream) | Encrypts a stream of data
Encrypt(Byte[]) | Encrypts a raw data block as a set of bytes
Encrypt(String) | Encrypts a string and encodes the result in base-64 encoded text
Encrypt(String,ByteEncoding) | Encrypts a string and encodes the result in specified encoding format

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Encrypt Method : Encrypt(Stream) Method

stream

Glossary Item Box

Encrypts a stream of data

Syntax

Visual Basic (Declaration)
Overloads Function Encrypt( _
   ByVal stream As Stream _
) As Stream
C#
Stream Encrypt(
   Stream stream
)

Parameters

stream

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members
Overload List

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Encrypt Method : Encrypt(Byte[]) Method

blob

Glossary Item Box

Encrypts a raw data block as a set of bytes

Syntax

Visual Basic (Declaration)
Overloads Function Encrypt( _
   ByVal blob() As Byte _
) As Byte()
C#
byte[] Encrypt(
   byte[] blob
)

Parameters

blob

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members
Overload List

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Encrypt Method : Encrypt(String) Method

text

Glossary Item Box

Encrypts a string and encodes the result in base-64 encoded text

Syntax

Visual Basic (Declaration)
Overloads Function Encrypt( _
   ByVal text As String _
) As String
C#
string Encrypt(
   string text
)

Parameters

text

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members
Overload List

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Encrypt(String,ByteEncoding) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Encrypt Method : Encrypt(String,ByteEncoding) Method

text
encoding

Glossary Item Box

Encrypts a string and encodes the result in specified encoding format

Syntax

Visual Basic (Declaration)
Overloads Function Encrypt( _
   ByVal text As String, _
   ByVal encoding As ByteEncoding _
) As String
C#
string Encrypt(
   string text,
   ByteEncoding encoding
)

Parameters

text
encoding

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IEncryptDecrypt Interface
IEncryptDecrypt Members
Overload List
ByteEncoding

Source Code

Library/Crypto/IEncryptDecrypt.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IPasswordDerivedBytes Interface
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : IPasswordDerivedBytes Interface

Glossary Item Box

Provides an interface for abstracting the password derivation routine used for password key derivation

Syntax

Visual Basic (Declaration)
Public Interface IPasswordDerivedBytes
C#
public interface IPasswordDerivedBytes

Example

Library/Library.Test/TestPassword.cs

C# Copy Code
int iter = 100;
Salt salt = new Salt();
byte[] passbytes = Password.Encoding.GetBytes(TEST_PASSWORD);
IPasswordDerivedBytes[] types = new IPasswordDerivedBytes[] {
    new PBKDF2(passbytes, salt, iter),
    new HashDerivedBytes<HMACMD5>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA1>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA256>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA384>(passbytes, salt, iter),
    new HashDerivedBytes<HMACSHA512>(passbytes, salt, iter),
};

foreach (IPasswordDerivedBytes db in types)
{
    byte[] key;

    Stopwatch w = new Stopwatch();
    w.Start();
    for (int i = 0; i < 100; i++)
        key = new PasswordKey(db, salt).CreateKey().Key;
    w.Stop();

    Console.Error.WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.GetType().Name);
}
VB.NET Copy Code
Dim iter As Integer = 100
Dim salt As New Salt()
Dim passbytes As Byte() = Password.Encoding.GetBytes(TEST_PASSWORD)
Dim types As IPasswordDerivedBytes() = New IPasswordDerivedBytes() {New PBKDF2(passbytes, salt, iter), New HashDerivedBytes(Of HMACMD5)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA1)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA256)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA384)(passbytes, salt, iter), New HashDerivedBytes(Of HMACSHA512)(passbytes, salt, iter)}

For Each db As IPasswordDerivedBytes In types
    Dim key As Byte()

    Dim w As New Stopwatch()
    w.Start()
    Dim i As Integer = 0
    While i < 100
        key = New PasswordKey(db, salt).CreateKey().Key
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    w.[Stop]()

    Console.[Error].WriteLine("{0,10}  {1}", w.ElapsedMilliseconds, db.[GetType]().Name)
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IPasswordDerivedBytes Members
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/IPasswordDerivedBytes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IPasswordDerivedBytes Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : IPasswordDerivedBytes Interface

Glossary Item Box

The following tables list the members exposed by IPasswordDerivedBytes.

Public Properties

 | Name | Description
Property | IterationCount | Gets or sets the number of iterations for the operation.
Property | Salt | Gets or sets the key salt value for the operation.
Top

Public Methods

 | Name | Description
Method | GetBytes | Returns a pseudo-random key from a password, salt and iteration count.
Method | Reset | Resets the state of the operation.
Top

See Also

Reference

IPasswordDerivedBytes Interface
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/IPasswordDerivedBytes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IPasswordDerivedBytes Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : IPasswordDerivedBytes Interface

Glossary Item Box

For a list of all members of this type, see IPasswordDerivedBytes members.

Public Methods

 | Name | Description
Method | GetBytes | Returns a pseudo-random key from a password, salt and iteration count.
Method | Reset | Resets the state of the operation.
Top

See Also

Reference

IPasswordDerivedBytes Interface
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/IPasswordDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IPasswordDerivedBytes Interface : GetBytes Method

cb

Glossary Item Box

Returns a pseudo-random key from a password, salt and iteration count.

Syntax

Visual Basic (Declaration)
Function GetBytes( _
   ByVal cb As Integer _
) As Byte()
C#
byte[] GetBytes(
   int cb
)

Parameters

cb

Example

Library/Library.Test/TestHashDerivedBytes.cs

C# Copy Code
using (IPasswordDerivedBytes pd = DerivedBytes(TEST_PASSWORD))
{
    pd.IterationCount = 1000;
    byte[] sha1Hash = SHA1.Create().ComputeHash(Password.Encoding.GetBytes(TEST_PASSWORD));
    Rfc2898DeriveBytes pbytes = new Rfc2898DeriveBytes(sha1Hash, DefaultSalt.ToArray(), 1000);
    Assert.AreEqual(pd.GetBytes(20), pbytes.GetBytes(20));
    Assert.AreEqual(pd.GetBytes(35), pbytes.GetBytes(35));

    byte[] test1 = pd.GetBytes(40);
    byte[] test2 = pbytes.GetBytes(40);

    //'RFC' implementation resuses 5 bytes already generated with 'GetBytes(35)', if you call reset these behave the same
    Assert.AreNotEqual(test1, test2);

    Buffer.BlockCopy(test2, 5, test2, 0, 35); //strip the first five bytes
    Array.Resize(ref test1, 35);
    Array.Resize(ref test2, 35);

    Assert.AreEqual(test1, test2); //now they should be the same
}
VB.NET Copy Code
Using pd As IPasswordDerivedBytes = DerivedBytes(TEST_PASSWORD)
    pd.IterationCount = 1000
    Dim sha1Hash As Byte() = SHA1.Create().ComputeHash(Password.Encoding.GetBytes(TEST_PASSWORD))
    Dim pbytes As New Rfc2898DeriveBytes(sha1Hash, DefaultSalt.ToArray(), 1000)
    Assert.AreEqual(pd.GetBytes(20), pbytes.GetBytes(20))
    Assert.AreEqual(pd.GetBytes(35), pbytes.GetBytes(35))

    Dim test1 As Byte() = pd.GetBytes(40)
    Dim test2 As Byte() = pbytes.GetBytes(40)

    ''RFC' implementation resuses 5 bytes already generated with 'GetBytes(35)', if you call reset these behave the same
    Assert.AreNotEqual(test1, test2)

    Buffer.BlockCopy(test2, 5, test2, 0, 35)
    'strip the first five bytes
    Array.Resize(test1, 35)
    Array.Resize(test2, 35)

        'now they should be the same
    Assert.AreEqual(test1, test2)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IPasswordDerivedBytes Interface
IPasswordDerivedBytes Members

Source Code

Library/Crypto/IPasswordDerivedBytes.cs

Used By

AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
Reset Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IPasswordDerivedBytes Interface : Reset Method

Glossary Item Box

Resets the state of the operation.

Syntax

Visual Basic (Declaration)
Sub Reset()
C#
void Reset()

Example

Library/Library.Test/TestHashDerivedBytes.cs

C# Copy Code
using (IPasswordDerivedBytes pd = DerivedBytes(TEST_PASSWORD))
{
    pd.IterationCount = 10;
    byte[] bytes = pd.GetBytes(1000);
    Assert.AreNotEqual(bytes, pd.GetBytes(bytes.Length));
    pd.Reset();
    Assert.AreEqual(bytes, pd.GetBytes(bytes.Length));
}
VB.NET Copy Code
Using pd As IPasswordDerivedBytes = DerivedBytes(TEST_PASSWORD)
    pd.IterationCount = 10
    Dim bytes As Byte() = pd.GetBytes(1000)
    Assert.AreNotEqual(bytes, pd.GetBytes(bytes.Length))
    pd.Reset()
    Assert.AreEqual(bytes, pd.GetBytes(bytes.Length))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IPasswordDerivedBytes Interface
IPasswordDerivedBytes Members

Source Code

Library/Crypto/IPasswordDerivedBytes.cs

Used By

AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IPasswordDerivedBytes Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : IPasswordDerivedBytes Interface

Glossary Item Box

For a list of all members of this type, see IPasswordDerivedBytes members.

Public Properties

 | Name | Description
Property | IterationCount | Gets or sets the number of iterations for the operation.
Property | Salt | Gets or sets the key salt value for the operation.
Top

See Also

Reference

IPasswordDerivedBytes Interface
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/IPasswordDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IterationCount Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IPasswordDerivedBytes Interface : IterationCount Property

Glossary Item Box

Gets or sets the number of iterations for the operation.

Syntax

Visual Basic (Declaration)
Property IterationCount As Integer
C#
int IterationCount {get; set;}

Example

Library/Library.Test/TestHashDerivedBytes.cs

C# Copy Code
using (IPasswordDerivedBytes pd = DerivedBytes(TEST_PASSWORD))
{
    pd.IterationCount = 1000;
    byte[] sha1Hash = SHA1.Create().ComputeHash(Password.Encoding.GetBytes(TEST_PASSWORD));
    Rfc2898DeriveBytes pbytes = new Rfc2898DeriveBytes(sha1Hash, DefaultSalt.ToArray(), 1000);
    Assert.AreEqual(pd.GetBytes(20), pbytes.GetBytes(20));
    Assert.AreEqual(pd.GetBytes(35), pbytes.GetBytes(35));

    byte[] test1 = pd.GetBytes(40);
    byte[] test2 = pbytes.GetBytes(40);

    //'RFC' implementation resuses 5 bytes already generated with 'GetBytes(35)', if you call reset these behave the same
    Assert.AreNotEqual(test1, test2);

    Buffer.BlockCopy(test2, 5, test2, 0, 35); //strip the first five bytes
    Array.Resize(ref test1, 35);
    Array.Resize(ref test2, 35);

    Assert.AreEqual(test1, test2); //now they should be the same
}
VB.NET Copy Code
Using pd As IPasswordDerivedBytes = DerivedBytes(TEST_PASSWORD)
    pd.IterationCount = 1000
    Dim sha1Hash As Byte() = SHA1.Create().ComputeHash(Password.Encoding.GetBytes(TEST_PASSWORD))
    Dim pbytes As New Rfc2898DeriveBytes(sha1Hash, DefaultSalt.ToArray(), 1000)
    Assert.AreEqual(pd.GetBytes(20), pbytes.GetBytes(20))
    Assert.AreEqual(pd.GetBytes(35), pbytes.GetBytes(35))

    Dim test1 As Byte() = pd.GetBytes(40)
    Dim test2 As Byte() = pbytes.GetBytes(40)

    ''RFC' implementation resuses 5 bytes already generated with 'GetBytes(35)', if you call reset these behave the same
    Assert.AreNotEqual(test1, test2)

    Buffer.BlockCopy(test2, 5, test2, 0, 35)
    'strip the first five bytes
    Array.Resize(test1, 35)
    Array.Resize(test2, 35)

        'now they should be the same
    Assert.AreEqual(test1, test2)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IPasswordDerivedBytes Interface
IPasswordDerivedBytes Members

Source Code

Library/Crypto/IPasswordDerivedBytes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Salt Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IPasswordDerivedBytes Interface : Salt Property

Glossary Item Box

Gets or sets the key salt value for the operation.

Syntax

Visual Basic (Declaration)
Property Salt As Byte()
C#
byte[] Salt {get; set;}

Example

Library/Library.Test/TestHashDerivedBytes.cs

C# Copy Code
using (IPasswordDerivedBytes pd = DerivedBytes(TEST_PASSWORD))
{
    Assert.AreEqual(DefaultSalt.ToArray(), pd.Salt);
    byte[] bytes = pd.GetBytes(4);

    pd.Salt = new Salt().ToArray();
    Assert.AreNotEqual(bytes, pd.GetBytes(bytes.Length));
    Assert.AreNotEqual(DefaultSalt.ToArray(), pd.Salt);

    pd.Salt = DefaultSalt.ToArray();
    Assert.AreEqual(bytes, pd.GetBytes(bytes.Length));
    Assert.AreEqual(DefaultSalt.ToArray(), pd.Salt);
}
VB.NET Copy Code
Using pd As IPasswordDerivedBytes = DerivedBytes(TEST_PASSWORD)
    Assert.AreEqual(DefaultSalt.ToArray(), pd.Salt)
    Dim bytes As Byte() = pd.GetBytes(4)

    pd.Salt = New Salt().ToArray()
    Assert.AreNotEqual(bytes, pd.GetBytes(bytes.Length))
    Assert.AreNotEqual(DefaultSalt.ToArray(), pd.Salt)

    pd.Salt = DefaultSalt.ToArray()
    Assert.AreEqual(bytes, pd.GetBytes(bytes.Length))
    Assert.AreEqual(DefaultSalt.ToArray(), pd.Salt)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IPasswordDerivedBytes Interface
IPasswordDerivedBytes Members

Source Code

Library/Crypto/IPasswordDerivedBytes.cs

Used By

AESCryptoKey PasswordKey.CreateKey(Salt)
AESCryptoKey PasswordKey.CreateKey(Salt,Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureTransfer.Client.TransmitMessageAction Delegate
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureTransfer.Client.TransmitMessageAction Delegate

transferId
location
request

Glossary Item Box

Provides the transmission of a stream of bytes to the server/receiver and returns the result stream

Syntax

Visual Basic (Declaration)
Public Delegate Function SecureTransfer.Client.TransmitMessageAction( _
   ByVal transferId As Guid, _
   ByVal location As String, _
   ByVal request As Stream _
) As Stream
C#
public delegate Stream SecureTransfer.Client.TransmitMessageAction(
   Guid transferId,
   string location,
   Stream request
)

Parameters

transferId
location
request

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureTransfer.Client.TransmitMessageAction Members
CSharpTest.Net.Crypto Namespace


%%ItemTitle%%

CSharpTest.Net.Data Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Data Namespace

Glossary Item Box

Classes

 | Class | Description
Class | CsvReader | Provides an System.Data.IDataReader interface to CSV/Tab delimited text files.
Class | DbGuid.DbGuidComparer | Implementation of a comparer and equality comparer for DbGuid

Structures

 | Structure | Description
Structure | DbGuid | A Guid struct for creating sequentially advancing unique identifiers

Enumerations

 | Enumeration | Description
Enumeration | CsvOptions | Options that define formatting of the CSV file

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : CsvReader Class

Glossary Item Box

Provides an System.Data.IDataReader interface to CSV/Tab delimited text files.

Syntax

Visual Basic (Declaration)
Public Class CsvReader
C#
public class CsvReader

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Data.CsvReader

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Members
CSharpTest.Net.Data Namespace

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
CsvReader Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : CsvReader Class

Glossary Item Box

The following tables list the members exposed by CsvReader.

Public Constructors

 | Name | Description
Public Constructor | CsvReader Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Depth | Returns the depth (zero based) of the reader when using nested CSV parsers
Public Property | FieldCount | Returns the number of fields defined in this record
Public Property | IsClosed | Returns true if the reader has been closed
Public Property | Item | Overloaded. Returns the string content of the field by name
Public Property | RecordsAffected | Returns the current record number of the parser
Top

Public Methods

 | Name | Description
Public Method | Close | Closes the csv reader and disposes the underlying text reader
Public Method | Dispose | Disposes of the reader
Public Method | GetBoolean | Gets the value of the specified column as a Boolean.
Public Method | GetByte | Gets the 8-bit unsigned integer value of the specified column.
Public Method | GetBytes | Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset.
Public Method | GetChar | Gets the character value of the specified column.
Public Method | GetChars | Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset.
Public Method | GetData | Returns a CsvReader for the specified column ordinal.
Public Method | GetDateTime | Gets the date and time data value of the specified field.
Public Method | GetDecimal | Gets the fixed-position numeric value of the specified field.
Public Method | GetDouble | Gets the double-precision floating point number of the specified field.
Public Method | GetFieldType | Returns typeof(String)
Public Method | GetFloat | Gets the single-precision floating point number of the specified field.
Public Method | GetGuid | Returns the GUID value of the specified field.
Public Method | GetInt16 | Gets the 16-bit signed integer value of the specified field.
Public Method | GetInt32 | Gets the 32-bit signed integer value of the specified field.
Public Method | GetInt64 | Gets the 64-bit signed integer value of the specified field.
Public Method | GetName | Returns the name of the column by ordinal
Public Method | GetOrdinal | Returns the ordinal of the column by name
Public Method | GetSchemaTable | Returns a DataTable which defines the columns in this CSV file
Public Method | GetString | Overloaded. Gets the string value of the specified field.
Public Method | GetValue | Returns the string content of the field by ordinal
Public Method | GetValues | Overloaded. Returns an object[] containing all the strings for the current record.
Public Method | IsDBNull | Return whether the specified field is set to null.
Public Method | Read | Advances the System.Data.IDataReader to the next record.
static (Shared in Visual Basic) | ReadCsvLine | Provides a single-record parser of CSV content
Top

See Also

Reference

CsvReader Class
CSharpTest.Net.Data Namespace

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : CsvReader Constructor

Glossary Item Box

Overload List

Overload | Description
CsvReader Constructor(TextReader,CsvOptions,Char,IFormatProvider,Int32) | Constructs the CSV reader for the provided text reader
CsvReader Constructor(TextReader,CsvOptions,Char,IFormatProvider) | Constructs the CSV reader for the provided text reader
CsvReader Constructor(String) | Constructs the CSV reader for the provided text reader
CsvReader Constructor(String,CsvOptions) | Constructs the CSV reader for the provided text reader
CsvReader Constructor(String,CsvOptions,Char,IFormatProvider) | Constructs the CSV reader for the provided text reader
CsvReader Constructor(TextReader) | Constructs the CSV reader for the provided text reader
CsvReader Constructor(TextReader,CsvOptions) | Constructs the CSV reader for the provided text reader

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Constructor(TextReader,CsvOptions,Char,IFormatProvider,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > CsvReader Constructor : CsvReader Constructor(TextReader,CsvOptions,Char,IFormatProvider,Int32)

reader
The text reader to read from
options
Options for parsing the text
fieldDelim
The character used to delineate fields
formatter
The format provided used for interpreting numbers and dates
depth
Provides for nested CSV parsers

Glossary Item Box

Constructs the CSV reader for the provided text reader

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal reader As TextReader, _
   ByVal options As CsvOptions, _
   ByVal fieldDelim As Char, _
   ByVal formatter As IFormatProvider, _
   ByVal depth As Integer _
)
C#
protected CsvReader(
   TextReader reader,
   CsvOptions options,
   char fieldDelim,
   IFormatProvider formatter,
   int depth
)

Parameters

reader
The text reader to read from
options
Options for parsing the text
fieldDelim
The character used to delineate fields
formatter
The format provided used for interpreting numbers and dates
depth
Provides for nested CSV parsers

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Used By

IDataReader CsvReader.GetData(Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Constructor(TextReader,CsvOptions,Char,IFormatProvider)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > CsvReader Constructor : CsvReader Constructor(TextReader,CsvOptions,Char,IFormatProvider)

reader
The text reader to read from
options
Options for parsing the text
fieldDelim
The character used to delineate fields
formatter
The format provided used for interpreting numbers and dates

Glossary Item Box

Constructs the CSV reader for the provided text reader

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal reader As TextReader, _
   ByVal options As CsvOptions, _
   ByVal fieldDelim As Char, _
   ByVal formatter As IFormatProvider _
)
C#
public CsvReader(
   TextReader reader,
   CsvOptions options,
   char fieldDelim,
   IFormatProvider formatter
)

Parameters

reader
The text reader to read from
options
Options for parsing the text
fieldDelim
The character used to delineate fields
formatter
The format provided used for interpreting numbers and dates

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > CsvReader Constructor : CsvReader Constructor(String)

inputFile
The text file to read from

Glossary Item Box

Constructs the CSV reader for the provided text reader

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal inputFile As String _
)
C#
public CsvReader(
   string inputFile
)

Parameters

inputFile
The text file to read from

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    File.WriteAllText(temp.TempPath, CSV_DOC1);
    using (CsvReader r = new CsvReader(temp.TempPath))
    {
        Assert.AreEqual(3, r.FieldCount);
        int row = 0;
        while (r.Read())
        {
            for (int col = 0; col < 3; col++)
            {
                Assert.AreEqual(CSV_DOC1_VAL[row, col], r.GetString(col));
            }

            row++;
        }

        Assert.AreEqual(5, row);
        Assert.AreEqual(5, r.RecordsAffected);
    }
}
VB.NET Copy Code
Using temp As New TempFile()
    File.WriteAllText(temp.TempPath, CSV_DOC1)
    Using r As New CsvReader(temp.TempPath)
        Assert.AreEqual(3, r.FieldCount)
        Dim row As Integer = 0
        While r.Read()
            Dim col As Integer = 0
            While col < 3
                Assert.AreEqual(CSV_DOC1_VAL(row, col), r.GetString(col))
                System.Math.Max(System.Threading.Interlocked.Increment(col),col - 1)
            End While

            System.Math.Max(System.Threading.Interlocked.Increment(row),row - 1)
        End While

        Assert.AreEqual(5, row)
        Assert.AreEqual(5, r.RecordsAffected)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Constructor(String,CsvOptions)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > CsvReader Constructor : CsvReader Constructor(String,CsvOptions)

inputFile
The text file to read from
options
Options for parsing the text

Glossary Item Box

Constructs the CSV reader for the provided text reader

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal inputFile As String, _
   ByVal options As CsvOptions _
)
C#
public CsvReader(
   string inputFile,
   CsvOptions options
)

Parameters

inputFile
The text file to read from
options
Options for parsing the text

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Constructor(String,CsvOptions,Char,IFormatProvider)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > CsvReader Constructor : CsvReader Constructor(String,CsvOptions,Char,IFormatProvider)

inputFile
The text file to read from
options
Options for parsing the text
fieldDelim
The character used to delineate fields
formatter
The format provided used for interpreting numbers and dates

Glossary Item Box

Constructs the CSV reader for the provided text reader

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal inputFile As String, _
   ByVal options As CsvOptions, _
   ByVal fieldDelim As Char, _
   ByVal formatter As IFormatProvider _
)
C#
public CsvReader(
   string inputFile,
   CsvOptions options,
   char fieldDelim,
   IFormatProvider formatter
)

Parameters

inputFile
The text file to read from
options
Options for parsing the text
fieldDelim
The character used to delineate fields
formatter
The format provided used for interpreting numbers and dates

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Constructor(TextReader)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > CsvReader Constructor : CsvReader Constructor(TextReader)

reader
The text reader to read from

Glossary Item Box

Constructs the CSV reader for the provided text reader

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal reader As TextReader _
)
C#
public CsvReader(
   TextReader reader
)

Parameters

reader
The text reader to read from

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    r.Read();
    Assert.AreEqual("1a", r["f1"]);
    Assert.AreEqual("1b", r[1]);
    Assert.AreEqual("1c", r.GetString(2));
    Assert.AreEqual("1c", r.GetValues()[2]);
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    r.Read()
    Assert.AreEqual("1a", r("f1"))
    Assert.AreEqual("1b", r(1))
    Assert.AreEqual("1c", r.GetString(2))
    Assert.AreEqual("1c", r.GetValues()(2))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvReader Constructor(TextReader,CsvOptions)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > CsvReader Constructor : CsvReader Constructor(TextReader,CsvOptions)

reader
The text reader to read from
options
Options for parsing the text

Glossary Item Box

Constructs the CSV reader for the provided text reader

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal reader As TextReader, _
   ByVal options As CsvOptions _
)
C#
public CsvReader(
   TextReader reader,
   CsvOptions options
)

Parameters

reader
The text reader to read from
options
Options for parsing the text

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
CsvReader Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : CsvReader Class

Glossary Item Box

For a list of all members of this type, see CsvReader members.

Public Methods

 | Name | Description
Public Method | Close | Closes the csv reader and disposes the underlying text reader
Public Method | Dispose | Disposes of the reader
Public Method | GetBoolean | Gets the value of the specified column as a Boolean.
Public Method | GetByte | Gets the 8-bit unsigned integer value of the specified column.
Public Method | GetBytes | Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset.
Public Method | GetChar | Gets the character value of the specified column.
Public Method | GetChars | Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset.
Public Method | GetData | Returns a CsvReader for the specified column ordinal.
Public Method | GetDateTime | Gets the date and time data value of the specified field.
Public Method | GetDecimal | Gets the fixed-position numeric value of the specified field.
Public Method | GetDouble | Gets the double-precision floating point number of the specified field.
Public Method | GetFieldType | Returns typeof(String)
Public Method | GetFloat | Gets the single-precision floating point number of the specified field.
Public Method | GetGuid | Returns the GUID value of the specified field.
Public Method | GetInt16 | Gets the 16-bit signed integer value of the specified field.
Public Method | GetInt32 | Gets the 32-bit signed integer value of the specified field.
Public Method | GetInt64 | Gets the 64-bit signed integer value of the specified field.
Public Method | GetName | Returns the name of the column by ordinal
Public Method | GetOrdinal | Returns the ordinal of the column by name
Public Method | GetSchemaTable | Returns a DataTable which defines the columns in this CSV file
Public Method | GetString | Overloaded. Gets the string value of the specified field.
Public Method | GetValue | Returns the string content of the field by ordinal
Public Method | GetValues | Overloaded. Returns an object[] containing all the strings for the current record.
Public Method | IsDBNull | Return whether the specified field is set to null.
Public Method | Read | Advances the System.Data.IDataReader to the next record.
static (Shared in Visual Basic) | ReadCsvLine | Provides a single-record parser of CSV content
Top

See Also

Reference

CsvReader Class
CSharpTest.Net.Data Namespace

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : Close Method

Glossary Item Box

Closes the csv reader and disposes the underlying text reader

Syntax

Visual Basic (Declaration)
Public Sub Close()
C#
public void Close()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Used By

CsvReader.Dispose()

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : Dispose Method

Glossary Item Box

Disposes of the reader

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetBoolean Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetBoolean Method

i

Glossary Item Box

Gets the value of the specified column as a Boolean.

Syntax

Visual Basic (Declaration)
Public Function GetBoolean( _
   ByVal i As Integer _
) As Boolean
C#
public bool GetBoolean(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetByte Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetByte Method

i

Glossary Item Box

Gets the 8-bit unsigned integer value of the specified column.

Syntax

Visual Basic (Declaration)
Public Function GetByte( _
   ByVal i As Integer _
) As Byte
C#
public byte GetByte(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetBytes Method

i
fieldOffset
buffer
bufferoffset
length

Glossary Item Box

Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset.

Syntax

Visual Basic (Declaration)
Public Function GetBytes( _
   ByVal i As Integer, _
   ByVal fieldOffset As Long, _
   ByVal buffer() As Byte, _
   ByVal bufferoffset As Integer, _
   ByVal length As Integer _
) As Long
C#
public long GetBytes(
   int i,
   long fieldOffset,
   byte[] buffer,
   int bufferoffset,
   int length
)

Parameters

i
fieldOffset
buffer
bufferoffset
length

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetChar Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetChar Method

i

Glossary Item Box

Gets the character value of the specified column.

Syntax

Visual Basic (Declaration)
Public Function GetChar( _
   ByVal i As Integer _
) As Char
C#
public char GetChar(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetChars Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetChars Method

i
fieldoffset
buffer
bufferoffset
length

Glossary Item Box

Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset.

Syntax

Visual Basic (Declaration)
Public Function GetChars( _
   ByVal i As Integer, _
   ByVal fieldoffset As Long, _
   ByVal buffer() As Char, _
   ByVal bufferoffset As Integer, _
   ByVal length As Integer _
) As Long
C#
public long GetChars(
   int i,
   long fieldoffset,
   char[] buffer,
   int bufferoffset,
   int length
)

Parameters

i
fieldoffset
buffer
bufferoffset
length

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetData Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetData Method

i

Glossary Item Box

Returns a CsvReader for the specified column ordinal.

Syntax

Visual Basic (Declaration)
Public Function GetData( _
   ByVal i As Integer _
) As IDataReader
C#
public IDataReader GetData(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetDateTime Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetDateTime Method

i

Glossary Item Box

Gets the date and time data value of the specified field.

Syntax

Visual Basic (Declaration)
Public Function GetDateTime( _
   ByVal i As Integer _
) As Date
C#
public DateTime GetDateTime(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetDecimal Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetDecimal Method

i

Glossary Item Box

Gets the fixed-position numeric value of the specified field.

Syntax

Visual Basic (Declaration)
Public Function GetDecimal( _
   ByVal i As Integer _
) As Decimal
C#
public decimal GetDecimal(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetDouble Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetDouble Method

i

Glossary Item Box

Gets the double-precision floating point number of the specified field.

Syntax

Visual Basic (Declaration)
Public Function GetDouble( _
   ByVal i As Integer _
) As Double
C#
public double GetDouble(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetFieldType Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetFieldType Method

i

Glossary Item Box

Returns typeof(String)

Syntax

Visual Basic (Declaration)
Public Function GetFieldType( _
   ByVal i As Integer _
) As Type
C#
public Type GetFieldType(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(3, r.FieldCount);
    for (int i = 0; i < r.FieldCount; i++)
    {
        Assert.AreEqual(typeof(String), r.GetFieldType(i));
        Assert.AreEqual(typeof(String).Name, ((IDataReader)r).GetDataTypeName(i));
        Assert.AreEqual("f" + (i + 1).ToString(), r.GetName(i).ToString());
        Assert.AreEqual(i, r.GetOrdinal("f" + (i + 1).ToString()));
    }

    while (r.Read())
    { }

    Assert.IsFalse(r.IsClosed);
    Assert.IsFalse(((IDataReader)r).NextResult());
    Assert.IsTrue(r.IsClosed);
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(3, r.FieldCount)
    Dim i As Integer = 0
    While i < r.FieldCount
        Assert.AreEqual(GetType([String]), r.GetFieldType(i))
        Assert.AreEqual(GetType([String]).Name, (DirectCast(r, IDataReader)).GetDataTypeName(i))
        Assert.AreEqual("f" + (i + 1).ToString(), r.GetName(i).ToString())
        Assert.AreEqual(i, r.GetOrdinal("f" + (i + 1).ToString()))
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    While r.Read()
    End While

    Assert.IsFalse(r.IsClosed)
    Assert.IsFalse((DirectCast(r, IDataReader)).NextResult())
    Assert.IsTrue(r.IsClosed)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs

Used By

DataTable CsvReader.GetSchemaTable()


%%PageItemTitle%%

[image]
CSharpTest.Net
GetFloat Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetFloat Method

i

Glossary Item Box

Gets the single-precision floating point number of the specified field.

Syntax

Visual Basic (Declaration)
Public Function GetFloat( _
   ByVal i As Integer _
) As Single
C#
public float GetFloat(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetGuid Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetGuid Method

i

Glossary Item Box

Returns the GUID value of the specified field.

Syntax

Visual Basic (Declaration)
Public Function GetGuid( _
   ByVal i As Integer _
) As Guid
C#
public Guid GetGuid(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetInt16 Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetInt16 Method

i

Glossary Item Box

Gets the 16-bit signed integer value of the specified field.

Syntax

Visual Basic (Declaration)
Public Function GetInt16( _
   ByVal i As Integer _
) As Short
C#
public short GetInt16(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetInt32 Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetInt32 Method

i

Glossary Item Box

Gets the 32-bit signed integer value of the specified field.

Syntax

Visual Basic (Declaration)
Public Function GetInt32( _
   ByVal i As Integer _
) As Integer
C#
public int GetInt32(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetInt64 Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetInt64 Method

i

Glossary Item Box

Gets the 64-bit signed integer value of the specified field.

Syntax

Visual Basic (Declaration)
Public Function GetInt64( _
   ByVal i As Integer _
) As Long
C#
public long GetInt64(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetName Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetName Method

i

Glossary Item Box

Returns the name of the column by ordinal

Syntax

Visual Basic (Declaration)
Public Function GetName( _
   ByVal i As Integer _
) As String
C#
public string GetName(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(0, r.Depth);
    Assert.IsFalse(r.IsClosed);
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());

    //second row has an extra field
    Assert.AreEqual(4, r.FieldCount);
    Assert.AreEqual("3", r.GetName(3));
    Assert.AreEqual(3, r.GetOrdinal("3"));
    Assert.AreEqual("extra", r.GetValue(3));

    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.IsDBNull(0));
    Assert.AreEqual("3a", r.GetString("f1"));
    Assert.IsTrue(r.IsDBNull(1));
    Assert.IsTrue(r.IsDBNull(2));

    Assert.IsTrue(r.Read());
    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.Read());
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(0, r.Depth)
    Assert.IsFalse(r.IsClosed)
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())

    'second row has an extra field
    Assert.AreEqual(4, r.FieldCount)
    Assert.AreEqual("3", r.GetName(3))
    Assert.AreEqual(3, r.GetOrdinal("3"))
    Assert.AreEqual("extra", r.GetValue(3))

    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.IsDBNull(0))
    Assert.AreEqual("3a", r.GetString("f1"))
    Assert.IsTrue(r.IsDBNull(1))
    Assert.IsTrue(r.IsDBNull(2))

    Assert.IsTrue(r.Read())
    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.Read())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Used By

DataTable CsvReader.GetSchemaTable()

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetOrdinal Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetOrdinal Method

name

Glossary Item Box

Returns the ordinal of the column by name

Syntax

Visual Basic (Declaration)
Public Function GetOrdinal( _
   ByVal name As String _
) As Integer
C#
public int GetOrdinal(
   string name
)

Parameters

name

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(0, r.Depth);
    Assert.IsFalse(r.IsClosed);
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());

    //second row has an extra field
    Assert.AreEqual(4, r.FieldCount);
    Assert.AreEqual("3", r.GetName(3));
    Assert.AreEqual(3, r.GetOrdinal("3"));
    Assert.AreEqual("extra", r.GetValue(3));

    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.IsDBNull(0));
    Assert.AreEqual("3a", r.GetString("f1"));
    Assert.IsTrue(r.IsDBNull(1));
    Assert.IsTrue(r.IsDBNull(2));

    Assert.IsTrue(r.Read());
    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.Read());
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(0, r.Depth)
    Assert.IsFalse(r.IsClosed)
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())

    'second row has an extra field
    Assert.AreEqual(4, r.FieldCount)
    Assert.AreEqual("3", r.GetName(3))
    Assert.AreEqual(3, r.GetOrdinal("3"))
    Assert.AreEqual("extra", r.GetValue(3))

    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.IsDBNull(0))
    Assert.AreEqual("3a", r.GetString("f1"))
    Assert.IsTrue(r.IsDBNull(1))
    Assert.IsTrue(r.IsDBNull(2))

    Assert.IsTrue(r.Read())
    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.Read())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs

Used By

String CsvReader.GetString(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
GetSchemaTable Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetSchemaTable Method

Glossary Item Box

Returns a DataTable which defines the columns in this CSV file

Syntax

Visual Basic (Declaration)
Public Function GetSchemaTable() As DataTable
C#
public DataTable GetSchemaTable()

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
DataTable dt = new CsvReader(new StringReader(CSV_DOC1)).GetSchemaTable();

Assert.AreEqual(3, dt.Columns.Count);
Assert.AreEqual("f1", dt.Columns[0].ColumnName);
Assert.AreEqual(typeof(String), dt.Columns[0].DataType);
Assert.AreEqual("f2", dt.Columns[1].ColumnName);
Assert.AreEqual(typeof(String), dt.Columns[1].DataType);
Assert.AreEqual("f3", dt.Columns[2].ColumnName);
Assert.AreEqual(typeof(String), dt.Columns[2].DataType);
VB.NET Copy Code
Dim dt As DataTable = New CsvReader(New StringReader(CSV_DOC1)).GetSchemaTable()

Assert.AreEqual(3, dt.Columns.Count)
Assert.AreEqual("f1", dt.Columns(0).ColumnName)
Assert.AreEqual(GetType([String]), dt.Columns(0).DataType)
Assert.AreEqual("f2", dt.Columns(1).ColumnName)
Assert.AreEqual(GetType([String]), dt.Columns(1).DataType)
Assert.AreEqual("f3", dt.Columns(2).ColumnName)
Assert.AreEqual(GetType([String]), dt.Columns(2).DataType)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetString Method

Glossary Item Box

Gets the string value of the specified field.

Overload List

Overload | Description
GetString(String) | Gets the string value of the specified field.
GetString(Int32) | Gets the string value of the specified field.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetString(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > GetString Method : GetString(String) Method

name

Glossary Item Box

Gets the string value of the specified field.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetString( _
   ByVal name As String _
) As String
C#
public string GetString(
   string name
)

Parameters

name

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(0, r.Depth);
    Assert.IsFalse(r.IsClosed);
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());

    //second row has an extra field
    Assert.AreEqual(4, r.FieldCount);
    Assert.AreEqual("3", r.GetName(3));
    Assert.AreEqual(3, r.GetOrdinal("3"));
    Assert.AreEqual("extra", r.GetValue(3));

    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.IsDBNull(0));
    Assert.AreEqual("3a", r.GetString("f1"));
    Assert.IsTrue(r.IsDBNull(1));
    Assert.IsTrue(r.IsDBNull(2));

    Assert.IsTrue(r.Read());
    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.Read());
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(0, r.Depth)
    Assert.IsFalse(r.IsClosed)
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())

    'second row has an extra field
    Assert.AreEqual(4, r.FieldCount)
    Assert.AreEqual("3", r.GetName(3))
    Assert.AreEqual(3, r.GetOrdinal("3"))
    Assert.AreEqual("extra", r.GetValue(3))

    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.IsDBNull(0))
    Assert.AreEqual("3a", r.GetString("f1"))
    Assert.IsTrue(r.IsDBNull(1))
    Assert.IsTrue(r.IsDBNull(2))

    Assert.IsTrue(r.Read())
    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.Read())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetString(Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > GetString Method : GetString(Int32) Method

i

Glossary Item Box

Gets the string value of the specified field.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetString( _
   ByVal i As Integer _
) As String
C#
public string GetString(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    r.Read();
    Assert.AreEqual("1a", r["f1"]);
    Assert.AreEqual("1b", r[1]);
    Assert.AreEqual("1c", r.GetString(2));
    Assert.AreEqual("1c", r.GetValues()[2]);
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    r.Read()
    Assert.AreEqual("1a", r("f1"))
    Assert.AreEqual("1b", r(1))
    Assert.AreEqual("1c", r.GetString(2))
    Assert.AreEqual("1c", r.GetValues()(2))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs

Used By

Boolean CsvReader.GetBoolean(Int32)
Byte CsvReader.GetByte(Int32)
Int64 CsvReader.GetBytes(Int32,Int64,Byte[],Int32,Int32)
Char CsvReader.GetChar(Int32)
Int64 CsvReader.GetChars(Int32,Int64,Char[],Int32,Int32)
IDataReader CsvReader.GetData(Int32)
DateTime CsvReader.GetDateTime(Int32)
Decimal CsvReader.GetDecimal(Int32)
Double CsvReader.GetDouble(Int32)
Single CsvReader.GetFloat(Int32)
Guid CsvReader.GetGuid(Int32)
Int16 CsvReader.GetInt16(Int32)
Int32 CsvReader.GetInt32(Int32)
Int64 CsvReader.GetInt64(Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetValue Method

i

Glossary Item Box

Returns the string content of the field by ordinal

Syntax

Visual Basic (Declaration)
Public Function GetValue( _
   ByVal i As Integer _
) As Object
C#
public object GetValue(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(0, r.Depth);
    Assert.IsFalse(r.IsClosed);
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());

    //second row has an extra field
    Assert.AreEqual(4, r.FieldCount);
    Assert.AreEqual("3", r.GetName(3));
    Assert.AreEqual(3, r.GetOrdinal("3"));
    Assert.AreEqual("extra", r.GetValue(3));

    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.IsDBNull(0));
    Assert.AreEqual("3a", r.GetString("f1"));
    Assert.IsTrue(r.IsDBNull(1));
    Assert.IsTrue(r.IsDBNull(2));

    Assert.IsTrue(r.Read());
    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.Read());
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(0, r.Depth)
    Assert.IsFalse(r.IsClosed)
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())

    'second row has an extra field
    Assert.AreEqual(4, r.FieldCount)
    Assert.AreEqual("3", r.GetName(3))
    Assert.AreEqual(3, r.GetOrdinal("3"))
    Assert.AreEqual("extra", r.GetValue(3))

    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.IsDBNull(0))
    Assert.AreEqual("3a", r.GetString("f1"))
    Assert.IsTrue(r.IsDBNull(1))
    Assert.IsTrue(r.IsDBNull(2))

    Assert.IsTrue(r.Read())
    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.Read())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValues Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : GetValues Method

Glossary Item Box

Returns an object[] containing all the strings for the current record.

Overload List

Overload | Description
GetValues() | Returns an object[] containing all the strings for the current record.
GetValues(Object[]) | Fills an object[] with all the strings for the current record.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValues() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > GetValues Method : GetValues() Method

Glossary Item Box

Returns an object[] containing all the strings for the current record.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetValues() As Object()
C#
public object[] GetValues()

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    r.Read();
    Assert.AreEqual("1a", r["f1"]);
    Assert.AreEqual("1b", r[1]);
    Assert.AreEqual("1c", r.GetString(2));
    Assert.AreEqual("1c", r.GetValues()[2]);
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    r.Read()
    Assert.AreEqual("1a", r("f1"))
    Assert.AreEqual("1b", r(1))
    Assert.AreEqual("1c", r.GetString(2))
    Assert.AreEqual("1c", r.GetValues()(2))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValues(Object[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > GetValues Method : GetValues(Object[]) Method

values

Glossary Item Box

Fills an object[] with all the strings for the current record.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetValues( _
   ByVal values() As Object _
) As Integer
C#
public int GetValues(
   object[] values
)

Parameters

values

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Used By

Object[] CsvReader.GetValues()

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsDBNull Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : IsDBNull Method

i

Glossary Item Box

Return whether the specified field is set to null.

Syntax

Visual Basic (Declaration)
Public Function IsDBNull( _
   ByVal i As Integer _
) As Boolean
C#
public bool IsDBNull(
   int i
)

Parameters

i

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(0, r.Depth);
    Assert.IsFalse(r.IsClosed);
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());

    //second row has an extra field
    Assert.AreEqual(4, r.FieldCount);
    Assert.AreEqual("3", r.GetName(3));
    Assert.AreEqual(3, r.GetOrdinal("3"));
    Assert.AreEqual("extra", r.GetValue(3));

    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.IsDBNull(0));
    Assert.AreEqual("3a", r.GetString("f1"));
    Assert.IsTrue(r.IsDBNull(1));
    Assert.IsTrue(r.IsDBNull(2));

    Assert.IsTrue(r.Read());
    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.Read());
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(0, r.Depth)
    Assert.IsFalse(r.IsClosed)
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())

    'second row has an extra field
    Assert.AreEqual(4, r.FieldCount)
    Assert.AreEqual("3", r.GetName(3))
    Assert.AreEqual(3, r.GetOrdinal("3"))
    Assert.AreEqual("extra", r.GetValue(3))

    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.IsDBNull(0))
    Assert.AreEqual("3a", r.GetString("f1"))
    Assert.IsTrue(r.IsDBNull(1))
    Assert.IsTrue(r.IsDBNull(2))

    Assert.IsTrue(r.Read())
    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.Read())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : Read Method

Glossary Item Box

Advances the System.Data.IDataReader to the next record.

Syntax

Visual Basic (Declaration)
Public Function Read() As Boolean
C#
public bool Read()

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
string content = @"True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000";
using (CsvReader r = new CsvReader(new StringReader(content), CsvOptions.None))
{
    int field = 0;
    byte[] buf = new byte[10];
    char[] ch = new char[10];

    Assert.IsTrue(r.Read());
    Assert.AreEqual(true, r.GetBoolean(field++));
    Assert.AreEqual((byte)129, r.GetByte(field++));

    Assert.AreEqual(3L, r.GetBytes(field++, 0, buf, 0, buf.Length));
    Assert.AreEqual((byte)0xf0, buf[0]);
    Assert.AreEqual((byte)0xa1, buf[1]);
    Assert.AreEqual((byte)0x2b, buf[2]);
    Assert.AreEqual((byte)0, buf[3]);

    Assert.AreEqual('a', r.GetChar(field++));

    Assert.AreEqual(6, r.GetChars(field++, 0, ch, 0, ch.Length));
    Assert.AreEqual("string", new String(ch, 0, 6));

    using (IDataReader c = r.GetData(field++))
    {
        Assert.AreEqual(1, c.Depth);
        Assert.AreEqual(0, c.FieldCount);
        Assert.IsTrue(c.Read());
        Assert.AreEqual(3, c.FieldCount);
        Assert.AreEqual("a", c.GetString(0));
        Assert.AreEqual("b", c.GetString(1));
        Assert.AreEqual("c", c.GetString(2));
    }

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(field++));

    Assert.AreEqual((decimal)0.25, r.GetDecimal(field));
    Assert.AreEqual(0.25f, r.GetFloat(field));
    Assert.AreEqual(0.25, r.GetDouble(field++));

    Assert.AreEqual(new Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(field++));

    Assert.AreEqual((short)20000, r.GetInt16(field++));
    Assert.AreEqual(-2000000000, r.GetInt32(field++));
    Assert.AreEqual(2000000000000L, r.GetInt64(field++));
}
VB.NET Copy Code
Dim content As String = "True, 129, f0a12b, a, string, ""a,b,c"", 1993-06-26 2:00pm, 0.25, {74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB}, 20000, -2000000000, 2000000000000"
Using r As New CsvReader(New StringReader(content), CsvOptions.None)
    Dim field As Integer = 0
    Dim buf As Byte() = New Byte(10) {}
    Dim ch As Char() = New Char(10) {}

    Assert.IsTrue(r.Read())
    Assert.AreEqual(True, r.GetBoolean(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(DirectCast(129, Byte), r.GetByte(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(3L, r.GetBytes(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, buf, 0, buf.Length))
    Assert.AreEqual(DirectCast(&Hf0, Byte), buf(0))
    Assert.AreEqual(DirectCast(&Ha1, Byte), buf(1))
    Assert.AreEqual(DirectCast(&H2b, Byte), buf(2))
    Assert.AreEqual(DirectCast(0, Byte), buf(3))

    Assert.AreEqual("a"C, r.GetChar(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(6, r.GetChars(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1), 0, ch, 0, ch.Length))
    Assert.AreEqual("string", New [String](ch, 0, 6))

    Using c As IDataReader = r.GetData(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1))
        Assert.AreEqual(1, c.Depth)
        Assert.AreEqual(0, c.FieldCount)
        Assert.IsTrue(c.Read())
        Assert.AreEqual(3, c.FieldCount)
        Assert.AreEqual("a", c.GetString(0))
        Assert.AreEqual("b", c.GetString(1))
        Assert.AreEqual("c", c.GetString(2))
    End Using

    Assert.AreEqual(DateTime.Parse("1993-06-26 2:00pm"), r.GetDateTime(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(0.25, Decimal), r.GetDecimal(field))
    Assert.AreEqual(0.25F, r.GetFloat(field))
    Assert.AreEqual(0.25, r.GetDouble(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(New Guid("74A51B0C-21B1-42b4-BAE4-AE6480B8B8DB"), r.GetGuid(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))

    Assert.AreEqual(DirectCast(20000, Short), r.GetInt16(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(-2000000000, r.GetInt32(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
    Assert.AreEqual(2000000000000L, r.GetInt64(System.Math.Max(System.Threading.Interlocked.Increment(field),field - 1)))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadCsvLine Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : ReadCsvLine Method

reader
delim

Glossary Item Box

Provides a single-record parser of CSV content

Syntax

Visual Basic (Declaration)
Public Shared Function ReadCsvLine( _
   ByVal reader As TextReader, _
   ByVal delim As Char _
) As String()
C#
public static string[] ReadCsvLine(
   TextReader reader,
   char delim
)

Parameters

reader
delim

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs

Used By

Boolean CsvReader.Read()


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
CsvReader Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : CsvReader Class

Glossary Item Box

For a list of all members of this type, see CsvReader members.

Public Properties

 | Name | Description
Public Property | Depth | Returns the depth (zero based) of the reader when using nested CSV parsers
Public Property | FieldCount | Returns the number of fields defined in this record
Public Property | IsClosed | Returns true if the reader has been closed
Public Property | Item | Overloaded. Returns the string content of the field by name
Public Property | RecordsAffected | Returns the current record number of the parser
Top

See Also

Reference

CsvReader Class
CSharpTest.Net.Data Namespace

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Depth Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : Depth Property

Glossary Item Box

Returns the depth (zero based) of the reader when using nested CSV parsers

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Depth As Integer
C#
public int Depth {get;}

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(0, r.Depth);
    Assert.IsFalse(r.IsClosed);
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());

    //second row has an extra field
    Assert.AreEqual(4, r.FieldCount);
    Assert.AreEqual("3", r.GetName(3));
    Assert.AreEqual(3, r.GetOrdinal("3"));
    Assert.AreEqual("extra", r.GetValue(3));

    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.IsDBNull(0));
    Assert.AreEqual("3a", r.GetString("f1"));
    Assert.IsTrue(r.IsDBNull(1));
    Assert.IsTrue(r.IsDBNull(2));

    Assert.IsTrue(r.Read());
    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.Read());
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(0, r.Depth)
    Assert.IsFalse(r.IsClosed)
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())

    'second row has an extra field
    Assert.AreEqual(4, r.FieldCount)
    Assert.AreEqual("3", r.GetName(3))
    Assert.AreEqual(3, r.GetOrdinal("3"))
    Assert.AreEqual("extra", r.GetValue(3))

    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.IsDBNull(0))
    Assert.AreEqual("3a", r.GetString("f1"))
    Assert.IsTrue(r.IsDBNull(1))
    Assert.IsTrue(r.IsDBNull(2))

    Assert.IsTrue(r.Read())
    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.Read())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FieldCount Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : FieldCount Property

Glossary Item Box

Returns the number of fields defined in this record

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FieldCount As Integer
C#
public int FieldCount {get;}

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    File.WriteAllText(temp.TempPath, CSV_DOC1);
    using (CsvReader r = new CsvReader(temp.TempPath))
    {
        Assert.AreEqual(3, r.FieldCount);
        int row = 0;
        while (r.Read())
        {
            for (int col = 0; col < 3; col++)
            {
                Assert.AreEqual(CSV_DOC1_VAL[row, col], r.GetString(col));
            }

            row++;
        }

        Assert.AreEqual(5, row);
        Assert.AreEqual(5, r.RecordsAffected);
    }
}
VB.NET Copy Code
Using temp As New TempFile()
    File.WriteAllText(temp.TempPath, CSV_DOC1)
    Using r As New CsvReader(temp.TempPath)
        Assert.AreEqual(3, r.FieldCount)
        Dim row As Integer = 0
        While r.Read()
            Dim col As Integer = 0
            While col < 3
                Assert.AreEqual(CSV_DOC1_VAL(row, col), r.GetString(col))
                System.Math.Max(System.Threading.Interlocked.Increment(col),col - 1)
            End While

            System.Math.Max(System.Threading.Interlocked.Increment(row),row - 1)
        End While

        Assert.AreEqual(5, row)
        Assert.AreEqual(5, r.RecordsAffected)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Used By

DataTable CsvReader.GetSchemaTable()
String CsvReader.GetName(Int32)

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsClosed Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : IsClosed Property

Glossary Item Box

Returns true if the reader has been closed

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsClosed As Boolean
C#
public bool IsClosed {get;}

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (CsvReader r = new CsvReader(new StringReader(CSV_DOC1)))
{
    Assert.AreEqual(0, r.Depth);
    Assert.IsFalse(r.IsClosed);
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());
    Assert.AreEqual(3, r.FieldCount);
    Assert.IsTrue(r.Read());

    //second row has an extra field
    Assert.AreEqual(4, r.FieldCount);
    Assert.AreEqual("3", r.GetName(3));
    Assert.AreEqual(3, r.GetOrdinal("3"));
    Assert.AreEqual("extra", r.GetValue(3));

    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.IsDBNull(0));
    Assert.AreEqual("3a", r.GetString("f1"));
    Assert.IsTrue(r.IsDBNull(1));
    Assert.IsTrue(r.IsDBNull(2));

    Assert.IsTrue(r.Read());
    Assert.IsTrue(r.Read());
    Assert.IsFalse(r.Read());
}
VB.NET Copy Code
Using r As New CsvReader(New StringReader(CSV_DOC1))
    Assert.AreEqual(0, r.Depth)
    Assert.IsFalse(r.IsClosed)
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())
    Assert.AreEqual(3, r.FieldCount)
    Assert.IsTrue(r.Read())

    'second row has an extra field
    Assert.AreEqual(4, r.FieldCount)
    Assert.AreEqual("3", r.GetName(3))
    Assert.AreEqual(3, r.GetOrdinal("3"))
    Assert.AreEqual("extra", r.GetValue(3))

    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.IsDBNull(0))
    Assert.AreEqual("3a", r.GetString("f1"))
    Assert.IsTrue(r.IsDBNull(1))
    Assert.IsTrue(r.IsDBNull(2))

    Assert.IsTrue(r.Read())
    Assert.IsTrue(r.Read())
    Assert.IsFalse(r.Read())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : Item Property

Glossary Item Box

Returns the string content of the field by name

Overload List

Overload | Description
Item(String) | Returns the string content of the field by name
Item(Int32) | Returns the string content of the field by ordinal

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item(String) Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > Item Property : Item(String) Property

name

Glossary Item Box

Returns the string content of the field by name

Syntax

Visual Basic (Declaration)
Public Overloads ReadOnly Property Item( _
   ByVal name As String _
) As Object
C#
public object Item(
   string name
) {get;}

Parameters

name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item(Int32) Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class > Item Property : Item(Int32) Property

i

Glossary Item Box

Returns the string content of the field by ordinal

Syntax

Visual Basic (Declaration)
Public Overloads ReadOnly Property Item( _
   ByVal i As Integer _
) As Object
C#
public object Item(
   int i
) {get;}

Parameters

i

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members
Overload List

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RecordsAffected Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > CsvReader Class : RecordsAffected Property

Glossary Item Box

Returns the current record number of the parser

Syntax

Visual Basic (Declaration)
Public ReadOnly Property RecordsAffected As Integer
C#
public int RecordsAffected {get;}

Example

Library/Library.Test/TestCsvReader.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    File.WriteAllText(temp.TempPath, CSV_DOC1);
    using (CsvReader r = new CsvReader(temp.TempPath))
    {
        Assert.AreEqual(3, r.FieldCount);
        int row = 0;
        while (r.Read())
        {
            for (int col = 0; col < 3; col++)
            {
                Assert.AreEqual(CSV_DOC1_VAL[row, col], r.GetString(col));
            }

            row++;
        }

        Assert.AreEqual(5, row);
        Assert.AreEqual(5, r.RecordsAffected);
    }
}
VB.NET Copy Code
Using temp As New TempFile()
    File.WriteAllText(temp.TempPath, CSV_DOC1)
    Using r As New CsvReader(temp.TempPath)
        Assert.AreEqual(3, r.FieldCount)
        Dim row As Integer = 0
        While r.Read()
            Dim col As Integer = 0
            While col < 3
                Assert.AreEqual(CSV_DOC1_VAL(row, col), r.GetString(col))
                System.Math.Max(System.Threading.Interlocked.Increment(col),col - 1)
            End While

            System.Math.Max(System.Threading.Interlocked.Increment(row),row - 1)
        End While

        Assert.AreEqual(5, row)
        Assert.AreEqual(5, r.RecordsAffected)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CsvReader Class
CsvReader Members

Source Code

Library/Data/CsvReader.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid.DbGuidComparer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : DbGuid.DbGuidComparer Class

Glossary Item Box

Implementation of a comparer and equality comparer for DbGuid

Syntax

Visual Basic (Declaration)
Public NotInheritable Class DbGuid.DbGuidComparer
C#
public sealed class DbGuid.DbGuidComparer

Inheritance Hierarchy

System.Object
CSharpTest.Net.Data.DbGuid.DbGuidComparer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid.DbGuidComparer Members
CSharpTest.Net.Data Namespace

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DbGuid.DbGuidComparer Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : DbGuid.DbGuidComparer Class

Glossary Item Box

The following tables list the members exposed by DbGuid.DbGuidComparer.

Public Constructors

 | Name | Description
Public Constructor | DbGuid.DbGuidComparer Constructor |
Top

Public Methods

 | Name | Description
Public Method | Compare | Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
Public Method | Equals | Overloaded. Determines whether the specified objects are equal.
Public Method | GetHashCode | Overloaded. Returns a hash code for the specified object.
Top

See Also

Reference

DbGuid.DbGuidComparer Class
CSharpTest.Net.Data Namespace

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid.DbGuidComparer Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid.DbGuidComparer Class : DbGuid.DbGuidComparer Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public DbGuid.DbGuidComparer()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid.DbGuidComparer Class
DbGuid.DbGuidComparer Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DbGuid.DbGuidComparer Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : DbGuid.DbGuidComparer Class

Glossary Item Box

For a list of all members of this type, see DbGuid.DbGuidComparer members.

Public Methods

 | Name | Description
Public Method | Compare | Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
Public Method | Equals | Overloaded. Determines whether the specified objects are equal.
Public Method | GetHashCode | Overloaded. Returns a hash code for the specified object.
Top

See Also

Reference

DbGuid.DbGuidComparer Class
CSharpTest.Net.Data Namespace

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Compare Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid.DbGuidComparer Class : Compare Method

x
y

Glossary Item Box

Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

Syntax

Visual Basic (Declaration)
Public Function Compare( _
   ByVal x As DbGuid, _
   ByVal y As DbGuid _
) As Integer
C#
public int Compare(
   DbGuid x,
   DbGuid y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid.DbGuidComparer Class
DbGuid.DbGuidComparer Members
DbGuid

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid.DbGuidComparer Class : Equals Method

Glossary Item Box

Determines whether the specified objects are equal.

Overload List

Overload | Description
Equals(DbGuid,DbGuid) | Determines whether the specified objects are equal.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid.DbGuidComparer Class
DbGuid.DbGuidComparer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(DbGuid,DbGuid) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid.DbGuidComparer Class > Equals Method : Equals(DbGuid,DbGuid) Method

x
y

Glossary Item Box

Determines whether the specified objects are equal.

Syntax

Visual Basic (Declaration)
Public Overloads Function Equals( _
   ByVal x As DbGuid, _
   ByVal y As DbGuid _
) As Boolean
C#
public bool Equals(
   DbGuid x,
   DbGuid y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid.DbGuidComparer Class
DbGuid.DbGuidComparer Members
Overload List
DbGuid

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid.DbGuidComparer Class : GetHashCode Method

Glossary Item Box

Returns a hash code for the specified object.

Overload List

Overload | Description
GetHashCode(DbGuid) | Returns a hash code for the specified object.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid.DbGuidComparer Class
DbGuid.DbGuidComparer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode(DbGuid) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid.DbGuidComparer Class > GetHashCode Method : GetHashCode(DbGuid) Method

obj

Glossary Item Box

Returns a hash code for the specified object.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetHashCode( _
   ByVal obj As DbGuid _
) As Integer
C#
public int GetHashCode(
   DbGuid obj
)

Parameters

obj

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid.DbGuidComparer Class
DbGuid.DbGuidComparer Members
Overload List
DbGuid

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CsvOptions Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : CsvOptions Enumeration

Glossary Item Box

Options that define formatting of the CSV file

Syntax

Visual Basic (Declaration)
Public Enum CsvOptions
   Inherits System.Enum
C#
public enum CsvOptions : System.Enum

Members

Member | Description
HasFieldHeaders | The first line contains the names of the fields
None | No options defined

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Data.CsvOptions

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Data Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : DbGuid Structure

Glossary Item Box

A Guid struct for creating sequentially advancing unique identifiers

Syntax

Visual Basic (Declaration)
Public Structure DbGuid
   Inherits System.ValueType
C#
public struct DbGuid : System.ValueType

Remarks

Bits - usage 00-03 - Reserved, always 000 if generated with DbGuid.NewGuid() 03-52 - Represent bits 3-52 of the DateTime.UtcNow.Ticks value 52-80 - 25 bits of incrementing numeric value 64-66 - Guid type constant of 111, or 001 if IsSqlGuid is true 76-128- Randomly generated bytes

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
TestEquality(testA, testA, true);
TestEquality(testA, DbGuid.NewGuid(), false);
TestEquality(testA, new DbGuid(Guid.NewGuid()), false);
TestEquality(testA, testA.ToSqlGuid(), true);
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), true);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
TestEquality(testA, testA, True)
TestEquality(testA, DbGuid.NewGuid(), False)
TestEquality(testA, New DbGuid(Guid.NewGuid()), False)
TestEquality(testA, testA.ToSqlGuid(), True)
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), True)

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Data.DbGuid

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Members
CSharpTest.Net.Data Namespace
Int32 DbGuid.DbGuidComparer.Compare(DbGuid,DbGuid)
Boolean DbGuid.DbGuidComparer.Equals(DbGuid,DbGuid)

Source Code

Library/Data/DbGuid.cs

Used By

DbGuid DbGuid.ToSqlGuid()
DbGuid DbGuid.ToSequenceGuid()
Boolean DbGuid.Equals(Object)
Int32 DbGuid.DbGuidComparer.GetHashCode(DbGuid)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DbGuid Structure Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : DbGuid Structure

Glossary Item Box

The following tables list the members exposed by DbGuid.

Public Constructors

 | Name | Description
Public Constructor | DbGuid Constructor | Overloaded.
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | Returns a comparer for comparing equality or sorting DbGuid instances
static (Shared in Visual Basic) | Empty | Returns an empty DbGuid structure.
static (Shared in Visual Basic) | Serializer | Returns a serializer that can read/write a DbGuid to and from a stream.
Top

Public Properties

 | Name | Description
Public Property | High64 | Returns the first/high 64 bits as a long
Public Property | IsSqlGuid | Returns true if the DbGuid is the result of a call to ToSqlGuid.
Public Property | Low64 | Returns the second/low 64 bits as a long
Top

Public Methods

 | Name | Description
Public Method | CompareTo | Compares the current object with another object of the same type.
Public Method | Equals | Overloaded. Indicates whether this instance and a specified object are equal.
Public Method | GetHashCode | Returns the hash code for this instance.
static (Shared in Visual Basic) | NewGuid | Creates a (mostly) sequential DbGuid using 7 bytes of DateTime in UTC ticks, 3 bytes of a sequentially incremented random value, and 6 bytes of random data.
Public Method | ToByteArray | Overloaded. Big-endian byte array, not compatible with System.Guid.ToByteArray.
Public Method | ToDateTimeUtc | Returns the UTC DateTime the guid was created. Will not work with ToSqlGuid().
Public Method | ToGuid | Returns the value as a System.Guid type.
Public Method | ToSequenceGuid | Used to reverse the effects of ToSqlGuid() and obtain a guid who's ToByteArray result is sequential. If IsSqlGuid is already False this call has no effect and returns the same value.
Public Method | ToSqlGuid | Used to swap the first 8 bytes with the last 8 bytes for SQL-Server optimization. The inverse operation can be performed by calling ToSequenceGuid() on the result. If IsSqlGuid is already True this call has no effect and returns the same value.
Public Method | ToString | Overloaded. Returns the fully qualified type name of this instance.
Top

Public Operators

public Operator Equality | Compares the two objects for non-reference equality
public Operator Explicit Type Conversion | Converts a System.Guid to a DbGuid
public Operator Greater Than | Compares the two objects
public Operator Greater Than or Equal | Compares the two objects
public Operator Implicit Type Conversion | Converts the DbGuid to a System.Guid
public Operator Inequality | Compares the two objects for non-reference equality
public Operator Less Than | Compares the two objects
public Operator Less Than or Equal | Compares the two objects
Top

See Also

Reference

DbGuid Structure
CSharpTest.Net.Data Namespace
Int32 DbGuid.DbGuidComparer.Compare(DbGuid,DbGuid)
Boolean DbGuid.DbGuidComparer.Equals(DbGuid,DbGuid)

Source Code

Library/Data/DbGuid.cs

Used By

DbGuid DbGuid.ToSqlGuid()
DbGuid DbGuid.ToSequenceGuid()
Boolean DbGuid.Equals(Object)
Int32 DbGuid.DbGuidComparer.GetHashCode(DbGuid)


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : DbGuid Constructor

Glossary Item Box

Overload List

Overload | Description
DbGuid Constructor(Int64,Int64) | Constructs a DbGuid from two 64-bit values
DbGuid Constructor(Int32,Int16,Int16,Byte,Byte,Byte,Byte,Byte,Byte,Byte,Byte) | Constructs a DbGuid from the typical Guid values
DbGuid Constructor(Guid) | Creates a DbGuid from a System.Guid instance.
DbGuid Constructor(Byte[]) | Constructs a DbGuid from an array of 16 (or more) bytes.
DbGuid Constructor(Byte[],Int32) | Constructs a DbGuid from an array of 16 (or more) bytes beginning at the offset supplied.
DbGuid Constructor(Boolean,Byte[],Int32) | Constructs a DbGuid from an array of 16 (or more) bytes beginning at the offset supplied. System.Guid.ToByteArray is little-endian, DbGuid.ToByteArray is in big-endian format.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid Constructor(Int64,Int64)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > DbGuid Constructor : DbGuid Constructor(Int64,Int64)

a
b

Glossary Item Box

Constructs a DbGuid from two 64-bit values

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal a As Long, _
   ByVal b As Long _
)
C#
public DbGuid(
   long a,
   long b
)

Parameters

a
b

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(Guid.Empty));
Assert.AreEqual(Guid.Empty, new DbGuid().ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(0, 0));
Assert.AreEqual(0L, DbGuid.Empty.High64);
Assert.AreEqual(0L, DbGuid.Empty.Low64);
VB.NET Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(Guid.Empty))
Assert.AreEqual(Guid.Empty, New DbGuid().ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(0, 0))
Assert.AreEqual(0L, DbGuid.Empty.High64)
Assert.AreEqual(0L, DbGuid.Empty.Low64)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Used By

DbGuid DbGuid.ToSqlGuid()
DbGuid DbGuid.ToSequenceGuid()

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid Constructor(Int32,Int16,Int16,Byte,Byte,Byte,Byte,Byte,Byte,Byte,Byte)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > DbGuid Constructor : DbGuid Constructor(Int32,Int16,Int16,Byte,Byte,Byte,Byte,Byte,Byte,Byte,Byte)

a
b
c
d
e
f
g
h
i
j
k

Glossary Item Box

Constructs a DbGuid from the typical Guid values

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal a As Integer, _
   ByVal b As Short, _
   ByVal c As Short, _
   ByVal d As Byte, _
   ByVal e As Byte, _
   ByVal f As Byte, _
   ByVal g As Byte, _
   ByVal h As Byte, _
   ByVal i As Byte, _
   ByVal j As Byte, _
   ByVal k As Byte _
)
C#
public DbGuid(
   int a,
   short b,
   short c,
   byte d,
   byte e,
   byte f,
   byte g,
   byte h,
   byte i,
   byte j,
   byte k
)

Parameters

a
b
c
d
e
f
g
h
i
j
k

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = new DbGuid(0x01020304, 0x0506, 0x0708, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80);
Guid testB = new Guid(0x01020304, 0x0506, 0x0708, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80);
Assert.AreEqual(testB, testA.ToGuid());
VB.NET Copy Code
Dim testA As New DbGuid(&H1020304, &H506, &H708, &H10, &H20, &H30, _
    &H40, &H50, &H60, &H70, &H80)
Dim testB As New Guid(&H1020304, &H506, &H708, &H10, &H20, &H30, _
    &H40, &H50, &H60, &H70, &H80)
Assert.AreEqual(testB, testA.ToGuid())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid Constructor(Guid)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > DbGuid Constructor : DbGuid Constructor(Guid)

guid

Glossary Item Box

Creates a DbGuid from a System.Guid instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal guid As Guid _
)
C#
public DbGuid(
   Guid guid
)

Parameters

guid

Remarks

Unexpected results may occur if using System.Guid.NewGuid() to initialize this instance. Instead use DbGuid.NewGuid() to construct a new identifier. This is provided primarily for conversion and use with other systems (i.e. SqlServer, etc).

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
TestEquality(testA, testA, true);
TestEquality(testA, DbGuid.NewGuid(), false);
TestEquality(testA, new DbGuid(Guid.NewGuid()), false);
TestEquality(testA, testA.ToSqlGuid(), true);
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), true);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
TestEquality(testA, testA, True)
TestEquality(testA, DbGuid.NewGuid(), False)
TestEquality(testA, New DbGuid(Guid.NewGuid()), False)
TestEquality(testA, testA.ToSqlGuid(), True)
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), True)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid Constructor(Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > DbGuid Constructor : DbGuid Constructor(Byte[])

bytes

Glossary Item Box

Constructs a DbGuid from an array of 16 (or more) bytes.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bytes() As Byte _
)
C#
public DbGuid(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
byte[] bytes = testA.ToByteArray();
DbGuid testB = new DbGuid(bytes);
Assert.AreEqual(testA, testB);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
Dim bytes As Byte() = testA.ToByteArray()
Dim testB As New DbGuid(bytes)
Assert.AreEqual(testA, testB)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid Constructor(Byte[],Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > DbGuid Constructor : DbGuid Constructor(Byte[],Int32)

bytes
offset

Glossary Item Box

Constructs a DbGuid from an array of 16 (or more) bytes beginning at the offset supplied.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bytes() As Byte, _
   ByVal offset As Integer _
)
C#
public DbGuid(
   byte[] bytes,
   int offset
)

Parameters

bytes
offset

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
byte[] bytes = new byte[1024];
testA.ToByteArray(bytes, 512);
DbGuid testB = new DbGuid(bytes, 512);
Assert.AreEqual(testA, testB);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
Dim bytes As Byte() = New Byte(1024) {}
testA.ToByteArray(bytes, 512)
Dim testB As New DbGuid(bytes, 512)
Assert.AreEqual(testA, testB)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DbGuid Constructor(Boolean,Byte[],Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > DbGuid Constructor : DbGuid Constructor(Boolean,Byte[],Int32)

littleEndian
bytes
offset

Glossary Item Box

Constructs a DbGuid from an array of 16 (or more) bytes beginning at the offset supplied. System.Guid.ToByteArray is little-endian, DbGuid.ToByteArray is in big-endian format.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal littleEndian As Boolean, _
   ByVal bytes() As Byte, _
   ByVal offset As Integer _
)
C#
public DbGuid(
   bool littleEndian,
   byte[] bytes,
   int offset
)

Parameters

littleEndian
bytes
offset

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DbGuid Structure Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : DbGuid Structure

Glossary Item Box

For a list of all members of this type, see DbGuid members.

Public Methods

 | Name | Description
Public Method | CompareTo | Compares the current object with another object of the same type.
Public Method | Equals | Overloaded. Indicates whether this instance and a specified object are equal.
Public Method | GetHashCode | Returns the hash code for this instance.
static (Shared in Visual Basic) | NewGuid | Creates a (mostly) sequential DbGuid using 7 bytes of DateTime in UTC ticks, 3 bytes of a sequentially incremented random value, and 6 bytes of random data.
Public Method | ToByteArray | Overloaded. Big-endian byte array, not compatible with System.Guid.ToByteArray.
Public Method | ToDateTimeUtc | Returns the UTC DateTime the guid was created. Will not work with ToSqlGuid().
Public Method | ToGuid | Returns the value as a System.Guid type.
Public Method | ToSequenceGuid | Used to reverse the effects of ToSqlGuid() and obtain a guid who's ToByteArray result is sequential. If IsSqlGuid is already False this call has no effect and returns the same value.
Public Method | ToSqlGuid | Used to swap the first 8 bytes with the last 8 bytes for SQL-Server optimization. The inverse operation can be performed by calling ToSequenceGuid() on the result. If IsSqlGuid is already True this call has no effect and returns the same value.
Public Method | ToString | Overloaded. Returns the fully qualified type name of this instance.
Top

See Also

Reference

DbGuid Structure
CSharpTest.Net.Data Namespace
Int32 DbGuid.DbGuidComparer.Compare(DbGuid,DbGuid)
Boolean DbGuid.DbGuidComparer.Equals(DbGuid,DbGuid)

Source Code

Library/Data/DbGuid.cs

Used By

DbGuid DbGuid.ToSqlGuid()
DbGuid DbGuid.ToSequenceGuid()
Boolean DbGuid.Equals(Object)
Int32 DbGuid.DbGuidComparer.GetHashCode(DbGuid)


%%PageItemTitle%%

[image]
CSharpTest.Net
CompareTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : CompareTo Method

other

Glossary Item Box

Compares the current object with another object of the same type.

Syntax

Visual Basic (Declaration)
Public Function CompareTo( _
   ByVal other As DbGuid _
) As Integer
C#
public int CompareTo(
   DbGuid other
)

Parameters

other

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid last = DbGuid.NewGuid();
for (int i = 0; i < 10000; i++)
{
    DbGuid test = DbGuid.NewGuid();
    TestSequence(last, test);
    TestSequence(last, test.ToSqlGuid());
    TestSequence(last.ToSqlGuid(), test);
    TestSequence(last.ToSqlGuid(), test.ToSqlGuid());
    Assert.IsTrue(last.CompareTo(test) < 0);
    last = test;
}
VB.NET Copy Code
Dim last As DbGuid = DbGuid.NewGuid()
Dim i As Integer = 0
While i < 10000
    Dim test As DbGuid = DbGuid.NewGuid()
    TestSequence(last, test)
    TestSequence(last, test.ToSqlGuid())
    TestSequence(last.ToSqlGuid(), test)
    TestSequence(last.ToSqlGuid(), test.ToSqlGuid())
    Assert.IsTrue(last.CompareTo(test) < 0)
    last = test
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Used By

Boolean DbGuid.Equals(DbGuid)
Int32 DbGuid.DbGuidComparer.Compare(DbGuid,DbGuid)

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Equals Method

Glossary Item Box

Indicates whether this instance and a specified object are equal.

Overload List

Overload | Description
Equals(Object) | Indicates whether this instance and a specified object are equal.
Equals(DbGuid) | Indicates whether the current object is equal to another object of the same type.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Base Implementation in Equals


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > Equals Method : Equals(Object) Method

obj

Glossary Item Box

Indicates whether this instance and a specified object are equal.

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Equals( _
   ByVal obj As Object _
) As Boolean
C#
public override bool Equals(
   object obj
)

Parameters

obj

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List
Base Implementation in Equals(Object)

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(DbGuid) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > Equals Method : Equals(DbGuid) Method

other

Glossary Item Box

Indicates whether the current object is equal to another object of the same type.

Syntax

Visual Basic (Declaration)
Public Overloads Function Equals( _
   ByVal other As DbGuid _
) As Boolean
C#
public bool Equals(
   DbGuid other
)

Parameters

other

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Used By

Boolean DbGuid.Equals(Object)
Boolean DbGuid.DbGuidComparer.Equals(DbGuid,DbGuid)

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : GetHashCode Method

Glossary Item Box

Returns the hash code for this instance.

Syntax

Visual Basic (Declaration)
Public Overrides Function GetHashCode() As Integer
C#
public override int GetHashCode()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Base Implementation in GetHashCode

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NewGuid Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : NewGuid Method

Glossary Item Box

Creates a (mostly) sequential DbGuid using 7 bytes of DateTime in UTC ticks, 3 bytes of a sequentially incremented random value, and 6 bytes of random data.

Syntax

Visual Basic (Declaration)
Public Shared Function NewGuid() As DbGuid
C#
public static DbGuid NewGuid()

Remarks

I say this is *mostly* sequential, because sometime after 2^24 (16m) guids are generated, the 25-bit incrementing number will 'roll over'. When this occurs and multiple guids are generated within the 4ms time window during this event, then it is possible that some may be out of sequence until the 4ms window passes. This anomaly in the sequencing should have no practical impact on performance. The collision chance within AppDomain are essentially non-existent due to the use of the incremented value. Across domains or processes the collision chance requires that Guids are generated within a 4ms window, happen to have the same 25-bit incremented value, and generate the same random 6-byte sequence while using cryptographic-strength PRNG. It's important to know that sequential guids like this drastically reduce the entropy size of the random value. Therefore DbGuid is more likely to produce duplicates than a regular fully-randomized guid. If you want to do the math on the collision probability of the 73-bit random value see the wikipedia article on the birthday paradox: http://en.wikipedia.org/wiki/Birthday_problem Keep in mind you must factor in the 4ms time interval with which DbGuids are timestamped. I'm not a math genius or anything, but generating a duplicate DbGuid is going to be more probable than generating a duplicate random guid, and less probable than being eaten by a shark.

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
TestEquality(testA, testA, true);
TestEquality(testA, DbGuid.NewGuid(), false);
TestEquality(testA, new DbGuid(Guid.NewGuid()), false);
TestEquality(testA, testA.ToSqlGuid(), true);
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), true);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
TestEquality(testA, testA, True)
TestEquality(testA, DbGuid.NewGuid(), False)
TestEquality(testA, New DbGuid(Guid.NewGuid()), False)
TestEquality(testA, testA.ToSqlGuid(), True)
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), True)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToByteArray Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : ToByteArray Method

Glossary Item Box

Big-endian byte array, not compatible with System.Guid.ToByteArray.

Overload List

Overload | Description
ToByteArray() | Big-endian byte array, not compatible with System.Guid.ToByteArray.
ToByteArray(Byte[],Int32) | Copies the big-endian byte array to the offset supplied, not compatible with System.Guid.ToByteArray.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ToByteArray() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > ToByteArray Method : ToByteArray() Method

Glossary Item Box

Big-endian byte array, not compatible with System.Guid.ToByteArray.

Syntax

Visual Basic (Declaration)
Public Overloads Function ToByteArray() As Byte()
C#
public byte[] ToByteArray()

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
byte[] bytes = testA.ToByteArray();
DbGuid testB = new DbGuid(bytes);
Assert.AreEqual(testA, testB);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
Dim bytes As Byte() = testA.ToByteArray()
Dim testB As New DbGuid(bytes)
Assert.AreEqual(testA, testB)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToByteArray(Byte[],Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > ToByteArray Method : ToByteArray(Byte[],Int32) Method

bytes
offset

Glossary Item Box

Copies the big-endian byte array to the offset supplied, not compatible with System.Guid.ToByteArray.

Syntax

Visual Basic (Declaration)
Public Overloads Sub ToByteArray( _
   ByVal bytes() As Byte, _
   ByVal offset As Integer _
)
C#
public void ToByteArray(
   byte[] bytes,
   int offset
)

Parameters

bytes
offset

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
byte[] bytes = new byte[1024];
testA.ToByteArray(bytes, 512);
DbGuid testB = new DbGuid(bytes, 512);
Assert.AreEqual(testA, testB);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
Dim bytes As Byte() = New Byte(1024) {}
testA.ToByteArray(bytes, 512)
Dim testB As New DbGuid(bytes, 512)
Assert.AreEqual(testA, testB)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Used By

Byte[] DbGuid.ToByteArray()

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToDateTimeUtc Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : ToDateTimeUtc Method

Glossary Item Box

Returns the UTC DateTime the guid was created. Will not work with ToSqlGuid().

Syntax

Visual Basic (Declaration)
Public Function ToDateTimeUtc() As Date
C#
public DateTime ToDateTimeUtc()

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
// Note: DateTime precision is +/- 1ms
DateTime start = DateTime.UtcNow.AddMilliseconds(-1);
DbGuid test = DbGuid.NewGuid();
Assert.IsTrue(test.ToDateTimeUtc() > start, "expected {0} > {1}", test.ToDateTimeUtc(), start);
DateTime now = DateTime.UtcNow.AddMilliseconds(1);
Assert.IsTrue(test.ToDateTimeUtc() <= now, "expected {0} <= {1}", test.ToDateTimeUtc(), now);
VB.NET Copy Code
' Note: DateTime precision is +/- 1ms
Dim start As DateTime = DateTime.UtcNow.AddMilliseconds(-1)
Dim test As DbGuid = DbGuid.NewGuid()
Assert.IsTrue(test.ToDateTimeUtc() > start, "expected {0} > {1}", test.ToDateTimeUtc(), start)
Dim now As DateTime = DateTime.UtcNow.AddMilliseconds(1)
Assert.IsTrue(test.ToDateTimeUtc() <= now, "expected {0} <= {1}", test.ToDateTimeUtc(), now)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToGuid Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : ToGuid Method

Glossary Item Box

Returns the value as a System.Guid type.

Syntax

Visual Basic (Declaration)
Public Function ToGuid() As Guid
C#
public Guid ToGuid()

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(Guid.Empty));
Assert.AreEqual(Guid.Empty, new DbGuid().ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(0, 0));
Assert.AreEqual(0L, DbGuid.Empty.High64);
Assert.AreEqual(0L, DbGuid.Empty.Low64);
VB.NET Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(Guid.Empty))
Assert.AreEqual(Guid.Empty, New DbGuid().ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(0, 0))
Assert.AreEqual(0L, DbGuid.Empty.High64)
Assert.AreEqual(0L, DbGuid.Empty.Low64)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs

Used By

String DbGuid.ToString()
String DbGuid.ToString(String)
String DbGuid.ToString(String,IFormatProvider)


%%PageItemTitle%%

[image]
CSharpTest.Net
ToSequenceGuid Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : ToSequenceGuid Method

Glossary Item Box

Used to reverse the effects of ToSqlGuid() and obtain a guid who's ToByteArray result is sequential. If IsSqlGuid is already False this call has no effect and returns the same value.

Syntax

Visual Basic (Declaration)
Public Function ToSequenceGuid() As DbGuid
C#
public DbGuid ToSequenceGuid()

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
TestEquality(testA, testA, true);
TestEquality(testA, DbGuid.NewGuid(), false);
TestEquality(testA, new DbGuid(Guid.NewGuid()), false);
TestEquality(testA, testA.ToSqlGuid(), true);
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), true);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
TestEquality(testA, testA, True)
TestEquality(testA, DbGuid.NewGuid(), False)
TestEquality(testA, New DbGuid(Guid.NewGuid()), False)
TestEquality(testA, testA.ToSqlGuid(), True)
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), True)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs

Used By

String DbGuid.ToString()
String DbGuid.ToString(String)
String DbGuid.ToString(String,IFormatProvider)


%%PageItemTitle%%

[image]
CSharpTest.Net
ToSqlGuid Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : ToSqlGuid Method

Glossary Item Box

Used to swap the first 8 bytes with the last 8 bytes for SQL-Server optimization. The inverse operation can be performed by calling ToSequenceGuid() on the result. If IsSqlGuid is already True this call has no effect and returns the same value.

Syntax

Visual Basic (Declaration)
Public Function ToSqlGuid() As DbGuid
C#
public DbGuid ToSqlGuid()

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid testA = DbGuid.NewGuid();
TestEquality(testA, testA, true);
TestEquality(testA, DbGuid.NewGuid(), false);
TestEquality(testA, new DbGuid(Guid.NewGuid()), false);
TestEquality(testA, testA.ToSqlGuid(), true);
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), true);
VB.NET Copy Code
Dim testA As DbGuid = DbGuid.NewGuid()
TestEquality(testA, testA, True)
TestEquality(testA, DbGuid.NewGuid(), False)
TestEquality(testA, New DbGuid(Guid.NewGuid()), False)
TestEquality(testA, testA.ToSqlGuid(), True)
TestEquality(testA, testA.ToSqlGuid().ToSequenceGuid(), True)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : ToString Method

Glossary Item Box

Returns the fully qualified type name of this instance.

Overload List

Overload | Description
ToString() | Returns the fully qualified type name of this instance.
ToString(String) | Returns the fully qualified type name of this instance.
ToString(String,IFormatProvider) | Formats the value of the current instance using the specified format.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Base Implementation in ToString


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > ToString Method : ToString() Method

Glossary Item Box

Returns the fully qualified type name of this instance.

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List
Base Implementation in ToString

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > ToString Method : ToString(String) Method

format

Glossary Item Box

Returns the fully qualified type name of this instance.

Syntax

Visual Basic (Declaration)
Public Overloads Function ToString( _
   ByVal format As String _
) As String
C#
public string ToString(
   string format
)

Parameters

format

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
Guid test = Guid.NewGuid();
Assert.AreEqual(test.ToString(), new DbGuid(test).ToString());
Assert.AreEqual(test.ToString("N"), new DbGuid(test).ToString("N"));
Assert.AreEqual(test.ToString("B", CultureInfo.InvariantCulture), new DbGuid(test).ToString("B", CultureInfo.InvariantCulture));
VB.NET Copy Code
Dim test As Guid = Guid.NewGuid()
Assert.AreEqual(test.ToString(), New DbGuid(test).ToString())
Assert.AreEqual(test.ToString("N"), New DbGuid(test).ToString("N"))
Assert.AreEqual(test.ToString("B", CultureInfo.InvariantCulture), New DbGuid(test).ToString("B", CultureInfo.InvariantCulture))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString(String,IFormatProvider) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure > ToString Method : ToString(String,IFormatProvider) Method

format
formatProvider

Glossary Item Box

Formats the value of the current instance using the specified format.

Syntax

Visual Basic (Declaration)
Public Overloads Function ToString( _
   ByVal format As String, _
   ByVal formatProvider As IFormatProvider _
) As String
C#
public string ToString(
   string format,
   IFormatProvider formatProvider
)

Parameters

format
formatProvider

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
Guid test = Guid.NewGuid();
Assert.AreEqual(test.ToString(), new DbGuid(test).ToString());
Assert.AreEqual(test.ToString("N"), new DbGuid(test).ToString("N"));
Assert.AreEqual(test.ToString("B", CultureInfo.InvariantCulture), new DbGuid(test).ToString("B", CultureInfo.InvariantCulture));
VB.NET Copy Code
Dim test As Guid = Guid.NewGuid()
Assert.AreEqual(test.ToString(), New DbGuid(test).ToString())
Assert.AreEqual(test.ToString("N"), New DbGuid(test).ToString("N"))
Assert.AreEqual(test.ToString("B", CultureInfo.InvariantCulture), New DbGuid(test).ToString("B", CultureInfo.InvariantCulture))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members
Overload List

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DbGuid Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : DbGuid Structure

Glossary Item Box

For a list of all members of this type, see DbGuid members.

Public Properties

 | Name | Description
Public Property | High64 | Returns the first/high 64 bits as a long
Public Property | IsSqlGuid | Returns true if the DbGuid is the result of a call to ToSqlGuid.
Public Property | Low64 | Returns the second/low 64 bits as a long
Top

See Also

Reference

DbGuid Structure
CSharpTest.Net.Data Namespace
Int32 DbGuid.DbGuidComparer.Compare(DbGuid,DbGuid)
Boolean DbGuid.DbGuidComparer.Equals(DbGuid,DbGuid)

Source Code

Library/Data/DbGuid.cs

Used By

DbGuid DbGuid.ToSqlGuid()
DbGuid DbGuid.ToSequenceGuid()
Boolean DbGuid.Equals(Object)
Int32 DbGuid.DbGuidComparer.GetHashCode(DbGuid)


%%PageItemTitle%%

[image]
CSharpTest.Net
High64 Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : High64 Property

Glossary Item Box

Returns the first/high 64 bits as a long

Syntax

Visual Basic (Declaration)
Public ReadOnly Property High64 As Long
C#
public long High64 {get;}

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(Guid.Empty));
Assert.AreEqual(Guid.Empty, new DbGuid().ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(0, 0));
Assert.AreEqual(0L, DbGuid.Empty.High64);
Assert.AreEqual(0L, DbGuid.Empty.Low64);
VB.NET Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(Guid.Empty))
Assert.AreEqual(Guid.Empty, New DbGuid().ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(0, 0))
Assert.AreEqual(0L, DbGuid.Empty.High64)
Assert.AreEqual(0L, DbGuid.Empty.Low64)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsSqlGuid Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : IsSqlGuid Property

Glossary Item Box

Returns true if the DbGuid is the result of a call to ToSqlGuid.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsSqlGuid As Boolean
C#
public bool IsSqlGuid {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Used By

DateTime DbGuid.ToDateTimeUtc()
DbGuid DbGuid.ToSqlGuid()
DbGuid DbGuid.ToSequenceGuid()
Int32 DbGuid.CompareTo(DbGuid)

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Low64 Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Low64 Property

Glossary Item Box

Returns the second/low 64 bits as a long

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Low64 As Long
C#
public long Low64 {get;}

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(Guid.Empty));
Assert.AreEqual(Guid.Empty, new DbGuid().ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(0, 0));
Assert.AreEqual(0L, DbGuid.Empty.High64);
Assert.AreEqual(0L, DbGuid.Empty.Low64);
VB.NET Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(Guid.Empty))
Assert.AreEqual(Guid.Empty, New DbGuid().ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(0, 0))
Assert.AreEqual(0L, DbGuid.Empty.High64)
Assert.AreEqual(0L, DbGuid.Empty.Low64)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
DbGuid Structure Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace : DbGuid Structure

Glossary Item Box

For a list of all members of this type, see DbGuid members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | Returns a comparer for comparing equality or sorting DbGuid instances
static (Shared in Visual Basic) | Empty | Returns an empty DbGuid structure.
static (Shared in Visual Basic) | Serializer | Returns a serializer that can read/write a DbGuid to and from a stream.
Top

See Also

Reference

DbGuid Structure
CSharpTest.Net.Data Namespace
Int32 DbGuid.DbGuidComparer.Compare(DbGuid,DbGuid)
Boolean DbGuid.DbGuidComparer.Equals(DbGuid,DbGuid)

Source Code

Library/Data/DbGuid.cs

Used By

DbGuid DbGuid.ToSqlGuid()
DbGuid DbGuid.ToSequenceGuid()
Boolean DbGuid.Equals(Object)
Int32 DbGuid.DbGuidComparer.GetHashCode(DbGuid)


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Comparer Field

Glossary Item Box

Returns a comparer for comparing equality or sorting DbGuid instances

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Comparer As DbGuid.DbGuidComparer
C#
public static readonly DbGuid.DbGuidComparer Comparer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Empty Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Empty Field

Glossary Item Box

Returns an empty DbGuid structure.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Empty As DbGuid
C#
public static readonly DbGuid Empty

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(Guid.Empty));
Assert.AreEqual(Guid.Empty, new DbGuid().ToGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid());
Assert.AreEqual(DbGuid.Empty, new DbGuid(0, 0));
Assert.AreEqual(0L, DbGuid.Empty.High64);
Assert.AreEqual(0L, DbGuid.Empty.Low64);
VB.NET Copy Code
Assert.AreEqual(Guid.Empty, DbGuid.Empty.ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(Guid.Empty))
Assert.AreEqual(Guid.Empty, New DbGuid().ToGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid())
Assert.AreEqual(DbGuid.Empty, New DbGuid(0, 0))
Assert.AreEqual(0L, DbGuid.Empty.High64)
Assert.AreEqual(0L, DbGuid.Empty.Low64)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Serializer Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Serializer Field

Glossary Item Box

Returns a serializer that can read/write a DbGuid to and from a stream.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Serializer As ISerializer(Of DbGuid)
C#
public static readonly ISerializer<DbGuid> Serializer

Example

Library/Library.Test/TestDbGuid.cs

C# Copy Code
DbGuid[] ids = new DbGuid[16];
MemoryStream stream = new MemoryStream();
for (int i = 0; i < ids.Length; i++)
{
    ids[i] = DbGuid.NewGuid();
    DbGuid.Serializer.WriteTo(ids[i], stream);
}
stream.Position = 0;
for (int i = 0; i < ids.Length; i++)
{
    DbGuid test = DbGuid.Serializer.ReadFrom(stream);
    Assert.AreEqual(ids[i], test);
}
Assert.AreEqual(-1, stream.ReadByte());
VB.NET Copy Code
Dim ids As DbGuid() = New DbGuid(16) {}
Dim stream As New MemoryStream()
Dim i As Integer = 0
While i < ids.Length
    ids(i) = DbGuid.NewGuid()
    DbGuid.Serializer.WriteTo(ids(i), stream)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
stream.Position = 0
Dim i As Integer = 0
While i < ids.Length
    Dim test As DbGuid = DbGuid.Serializer.ReadFrom(stream)
    Assert.AreEqual(ids(i), test)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Assert.AreEqual(-1, stream.ReadByte())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Equality Operator

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Operator =( _
   ByVal x As DbGuid, _
   ByVal y As DbGuid _
) As Boolean
C#
public bool operator ==(
   DbGuid x,
   DbGuid y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Explicit Type Conversion Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Explicit Type Conversion Operator

value

Glossary Item Box

Converts a System.Guid to a DbGuid

Syntax

Visual Basic (Declaration)
Public Operator Narrowing CType( _
   ByVal value As Guid _
) As DbGuid
C#
public DbGuid operator explicit(
   Guid value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Greater Than Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Greater Than Operator

x
y

Glossary Item Box

Compares the two objects

Syntax

Visual Basic (Declaration)
Public Operator >( _
   ByVal x As DbGuid, _
   ByVal y As DbGuid _
) As Boolean
C#
public bool operator >(
   DbGuid x,
   DbGuid y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Greater Than or Equal Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Greater Than or Equal Operator

x
y

Glossary Item Box

Compares the two objects

Syntax

Visual Basic (Declaration)
Public Operator >=( _
   ByVal x As DbGuid, _
   ByVal y As DbGuid _
) As Boolean
C#
public bool operator >=(
   DbGuid x,
   DbGuid y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Implicit Type Conversion Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Implicit Type Conversion Operator

value

Glossary Item Box

Converts the DbGuid to a System.Guid

Syntax

Visual Basic (Declaration)
Public Operator Widening CType( _
   ByVal value As DbGuid _
) As Guid
C#
public Guid operator implicit(
   DbGuid value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Inequality Operator

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration)
Public Operator <>( _
   ByVal x As DbGuid, _
   ByVal y As DbGuid _
) As Boolean
C#
public bool operator !=(
   DbGuid x,
   DbGuid y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Less Than Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Less Than Operator

x
y

Glossary Item Box

Compares the two objects

Syntax

Visual Basic (Declaration)
Public Operator <( _
   ByVal x As DbGuid, _
   ByVal y As DbGuid _
) As Boolean
C#
public bool operator <(
   DbGuid x,
   DbGuid y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Less Than or Equal Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Less Than or Equal Operator

x
y

Glossary Item Box

Compares the two objects

Syntax

Visual Basic (Declaration)
Public Operator <=( _
   ByVal x As DbGuid, _
   ByVal y As DbGuid _
) As Boolean
C#
public bool operator <=(
   DbGuid x,
   DbGuid y
)

Parameters

x
y

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DbGuid Structure
DbGuid Members

Source Code

Library/Data/DbGuid.cs


%%ItemTitle%%

CSharpTest.Net.Delegates Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Delegates Namespace

Glossary Item Box

Classes

 | Class | Description
Class | EventHandlerForActiveControl<TEventArgs> | This derivation of EventHandlerForControl<TEventArgs> will simply ignore the call if the control's handle is not at the time the delegate is invoked.
Class | EventHandlerForControl<TEventArgs> | Provies a wrapper type around event handlers for a control that are safe to be used from events on another thread. If the control is not valid at the time the delegate is called an exception of type ObjectDisposedExcpetion will be raised.
Class | ForcedEventHandlerForControl<TEventArgs> | This derivation of EventHandlerForControl<TEventArgs> will directly call the delegate on the current thread if the control's handle is not valid rather than raising the ObjectDisposedExcpetion.
Class | TimeoutAction | Provides scheduling a single-fire event at some duration into the future. The operation is performed once either when the duration expires, or when this object is disposed or collected.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

TEventArgs
[image]
CSharpTest.Net
EventHandlerForActiveControl<TEventArgs> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForActiveControl<TEventArgs> Class

Glossary Item Box

This derivation of EventHandlerForControl<TEventArgs> will simply ignore the call if the control's handle is not at the time the delegate is invoked.

Syntax

Visual Basic (Declaration)
Public Class EventHandlerForActiveControl(Of TEventArgs As EventArgs)
   Inherits EventHandlerForControl(Of TEventArgs)
C#
public class EventHandlerForActiveControl<TEventArgs> : EventHandlerForControl<TEventArgs>
where TEventArgs: EventArgs

Type Parameters

TEventArgs

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
EventHandlerForActiveControl<VerifiedReceiptEventArgs> handler;
handler = new EventHandlerForActiveControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler = new EventHandlerForActiveControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(handler.EventHandler));
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
_form.Shown += delegate(object s, EventArgs e) { System.Threading.Thread.Sleep(100); _form.Close(); };
_thread.Start();
int total = 0, countOnThread = 0, countOffThread = 0;
try
{
    for (total = 1; total < 1000000; total++)
    {
        handler.EventHandler(null, args.Reset());
        if (args.OnThread)
        {
            Assert.IsTrue(args.Received);
            countOnThread++;
        }
        else
        {
            Assert.IsFalse(args.Received);
            countOffThread++;
        }
        //Assert.IsTrue(args.OnThread);
        //Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        if (_form.IsDisposed)
            break;
    }
    Assert.AreEqual(total, countOnThread + countOffThread);
    Assert.IsTrue(_form.IsDisposed);
    Assert.AreNotEqual(0, countOnThread);
    Assert.AreNotEqual(0, countOffThread);
}
catch (Exception e)
{
    Console.Error.WriteLine(e.ToString());
    throw;
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)
handler = New EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler = New EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(handler.EventHandler))
Dim args As New VerifiedReceiptEventArgs()
_form.Shown += Function(s As Object, e As EventArgs) Do
    System.Threading.Thread.Sleep(100)
    _form.Close()
End Function
_thread.Start()
Dim total As Integer = 0, countOnThread As Integer = 0, countOffThread As Integer = 0
Try
    total = 1
    While total < 1000000
        handler.EventHandler(Nothing, args.Reset())
        If args.OnThread Then
            Assert.IsTrue(args.Received)
            System.Math.Max(System.Threading.Interlocked.Increment(countOnThread),countOnThread - 1)
        Else
            Assert.IsFalse(args.Received)
            System.Math.Max(System.Threading.Interlocked.Increment(countOffThread),countOffThread - 1)
        End If
        'Assert.IsTrue(args.OnThread);
        'Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        If _form.IsDisposed Then
            Exit While
        End If
        System.Math.Max(System.Threading.Interlocked.Increment(total),total - 1)
    End While
    Assert.AreEqual(total, countOnThread + countOffThread)
    Assert.IsTrue(_form.IsDisposed)
    Assert.AreNotEqual(0, countOnThread)
    Assert.AreNotEqual(0, countOffThread)
Catch e As Exception
    Console.[Error].WriteLine(e.ToString())
    Throw
Finally
    _thread.Join()
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>
CSharpTest.Net.Delegates.EventHandlerForActiveControl<TEventArgs>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForActiveControl<TEventArgs> Members
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
EventHandlerForActiveControl<TEventArgs> Class Members
See Also Fields Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForActiveControl<TEventArgs> Class

Glossary Item Box

The following tables list the members exposed by EventHandlerForActiveControl<TEventArgs>.

Public Constructors

 | Name | Description
Public Constructor | EventHandlerForActiveControl<TEventArgs> Constructor | Overloaded.
Top

Protected Fields

 | Name | Description
Protected Field | _control | The control who's thread we will use for the invoke (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Protected Field | _delegate | The delegate to invoke on the control (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Top

Public Methods

 | Name | Description
Public Method | EventHandler | Handles the 'magic' of safely invoking the delegate on the control without producing a dead-lock. (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Top

Protected Methods

 | Name | Description
Protected Method | OnControlDisposed | Overridden. Handle the case when the control is not valid
Top

See Also

Reference

EventHandlerForActiveControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventHandlerForActiveControl<TEventArgs> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForActiveControl<TEventArgs> Class : EventHandlerForActiveControl<TEventArgs> Constructor

Glossary Item Box

Overload List

Overload | Description
EventHandlerForActiveControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>) | Constructs an EventHandler for the specified method on the given control instance.
EventHandlerForActiveControl<TEventArgs> Constructor(Control,Delegate) | Constructs an EventHandler for the specified method on the given control instance.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForActiveControl<TEventArgs> Class
EventHandlerForActiveControl<TEventArgs> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
EventHandlerForActiveControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForActiveControl<TEventArgs> Class > EventHandlerForActiveControl<TEventArgs> Constructor : EventHandlerForActiveControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>)

control
handler

Glossary Item Box

Constructs an EventHandler for the specified method on the given control instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal control As Control, _
   ByVal handler As EventHandler(Of TEventArgs) _
)
C#
public EventHandlerForActiveControl<TEventArgs>(
   Control control,
   EventHandler<TEventArgs> handler
)

Parameters

control
handler

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
EventHandlerForActiveControl<VerifiedReceiptEventArgs> handler;
handler = new EventHandlerForActiveControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler = new EventHandlerForActiveControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(handler.EventHandler));
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
_form.Shown += delegate(object s, EventArgs e) { System.Threading.Thread.Sleep(100); _form.Close(); };
_thread.Start();
int total = 0, countOnThread = 0, countOffThread = 0;
try
{
    for (total = 1; total < 1000000; total++)
    {
        handler.EventHandler(null, args.Reset());
        if (args.OnThread)
        {
            Assert.IsTrue(args.Received);
            countOnThread++;
        }
        else
        {
            Assert.IsFalse(args.Received);
            countOffThread++;
        }
        //Assert.IsTrue(args.OnThread);
        //Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        if (_form.IsDisposed)
            break;
    }
    Assert.AreEqual(total, countOnThread + countOffThread);
    Assert.IsTrue(_form.IsDisposed);
    Assert.AreNotEqual(0, countOnThread);
    Assert.AreNotEqual(0, countOffThread);
}
catch (Exception e)
{
    Console.Error.WriteLine(e.ToString());
    throw;
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)
handler = New EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler = New EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(handler.EventHandler))
Dim args As New VerifiedReceiptEventArgs()
_form.Shown += Function(s As Object, e As EventArgs) Do
    System.Threading.Thread.Sleep(100)
    _form.Close()
End Function
_thread.Start()
Dim total As Integer = 0, countOnThread As Integer = 0, countOffThread As Integer = 0
Try
    total = 1
    While total < 1000000
        handler.EventHandler(Nothing, args.Reset())
        If args.OnThread Then
            Assert.IsTrue(args.Received)
            System.Math.Max(System.Threading.Interlocked.Increment(countOnThread),countOnThread - 1)
        Else
            Assert.IsFalse(args.Received)
            System.Math.Max(System.Threading.Interlocked.Increment(countOffThread),countOffThread - 1)
        End If
        'Assert.IsTrue(args.OnThread);
        'Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        If _form.IsDisposed Then
            Exit While
        End If
        System.Math.Max(System.Threading.Interlocked.Increment(total),total - 1)
    End While
    Assert.AreEqual(total, countOnThread + countOffThread)
    Assert.IsTrue(_form.IsDisposed)
    Assert.AreNotEqual(0, countOnThread)
    Assert.AreNotEqual(0, countOffThread)
Catch e As Exception
    Console.[Error].WriteLine(e.ToString())
    Throw
Finally
    _thread.Join()
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForActiveControl<TEventArgs> Class
EventHandlerForActiveControl<TEventArgs> Members
Overload List

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventHandlerForActiveControl<TEventArgs> Constructor(Control,Delegate)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForActiveControl<TEventArgs> Class > EventHandlerForActiveControl<TEventArgs> Constructor : EventHandlerForActiveControl<TEventArgs> Constructor(Control,Delegate)

control
handler

Glossary Item Box

Constructs an EventHandler for the specified method on the given control instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal control As Control, _
   ByVal handler As Delegate _
)
C#
public EventHandlerForActiveControl<TEventArgs>(
   Control control,
   Delegate handler
)

Parameters

control
handler

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
EventHandlerForActiveControl<VerifiedReceiptEventArgs> handler;
handler = new EventHandlerForActiveControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler = new EventHandlerForActiveControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(handler.EventHandler));
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
_form.Shown += delegate(object s, EventArgs e) { System.Threading.Thread.Sleep(100); _form.Close(); };
_thread.Start();
int total = 0, countOnThread = 0, countOffThread = 0;
try
{
    for (total = 1; total < 1000000; total++)
    {
        handler.EventHandler(null, args.Reset());
        if (args.OnThread)
        {
            Assert.IsTrue(args.Received);
            countOnThread++;
        }
        else
        {
            Assert.IsFalse(args.Received);
            countOffThread++;
        }
        //Assert.IsTrue(args.OnThread);
        //Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        if (_form.IsDisposed)
            break;
    }
    Assert.AreEqual(total, countOnThread + countOffThread);
    Assert.IsTrue(_form.IsDisposed);
    Assert.AreNotEqual(0, countOnThread);
    Assert.AreNotEqual(0, countOffThread);
}
catch (Exception e)
{
    Console.Error.WriteLine(e.ToString());
    throw;
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)
handler = New EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler = New EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(handler.EventHandler))
Dim args As New VerifiedReceiptEventArgs()
_form.Shown += Function(s As Object, e As EventArgs) Do
    System.Threading.Thread.Sleep(100)
    _form.Close()
End Function
_thread.Start()
Dim total As Integer = 0, countOnThread As Integer = 0, countOffThread As Integer = 0
Try
    total = 1
    While total < 1000000
        handler.EventHandler(Nothing, args.Reset())
        If args.OnThread Then
            Assert.IsTrue(args.Received)
            System.Math.Max(System.Threading.Interlocked.Increment(countOnThread),countOnThread - 1)
        Else
            Assert.IsFalse(args.Received)
            System.Math.Max(System.Threading.Interlocked.Increment(countOffThread),countOffThread - 1)
        End If
        'Assert.IsTrue(args.OnThread);
        'Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        If _form.IsDisposed Then
            Exit While
        End If
        System.Math.Max(System.Threading.Interlocked.Increment(total),total - 1)
    End While
    Assert.AreEqual(total, countOnThread + countOffThread)
    Assert.IsTrue(_form.IsDisposed)
    Assert.AreNotEqual(0, countOnThread)
    Assert.AreNotEqual(0, countOffThread)
Catch e As Exception
    Console.[Error].WriteLine(e.ToString())
    Throw
Finally
    _thread.Join()
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForActiveControl<TEventArgs> Class
EventHandlerForActiveControl<TEventArgs> Members
Overload List

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
EventHandlerForActiveControl<TEventArgs> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForActiveControl<TEventArgs> Class

Glossary Item Box

For a list of all members of this type, see EventHandlerForActiveControl<TEventArgs> members.

Public Methods

 | Name | Description
Public Method | EventHandler | Handles the 'magic' of safely invoking the delegate on the control without producing a dead-lock. (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Top

Protected Methods

 | Name | Description
Protected Method | OnControlDisposed | Overridden. Handle the case when the control is not valid
Top

See Also

Reference

EventHandlerForActiveControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnControlDisposed Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForActiveControl<TEventArgs> Class : OnControlDisposed Method

sender
args

Glossary Item Box

Handle the case when the control is not valid

Syntax

Visual Basic (Declaration)
Protected Overrides Sub OnControlDisposed( _
   ByVal sender As Object, _
   ByVal args As TEventArgs _
)
C#
protected override void OnControlDisposed(
   object sender,
   TEventArgs args
)

Parameters

sender
args

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForActiveControl<TEventArgs> Class
EventHandlerForActiveControl<TEventArgs> Members
Base Implementation in OnControlDisposed


%%PageItemTitle%%

TEventArgs
[image]
CSharpTest.Net
EventHandlerForControl<TEventArgs> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForControl<TEventArgs> Class

Glossary Item Box

Provies a wrapper type around event handlers for a control that are safe to be used from events on another thread. If the control is not valid at the time the delegate is called an exception of type ObjectDisposedExcpetion will be raised.

Syntax

Visual Basic (Declaration)
Public Class EventHandlerForControl(Of TEventArgs As EventArgs)
C#
public class EventHandlerForControl<TEventArgs>
where TEventArgs: EventArgs

Type Parameters

TEventArgs

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
EventHandler<VerifiedReceiptEventArgs> handler;
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();

_thread.Start();
_form.FormCreated.WaitOne();

try
{
    handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, CloseTheForm);
    handler(null, args);
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As EventHandler(Of VerifiedReceiptEventArgs)
Dim args As New VerifiedReceiptEventArgs()

_thread.Start()
_form.FormCreated.WaitOne()

Try
    handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, CloseTheForm)
    handler(Nothing, args)
Finally
    _thread.Join()
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>
CSharpTest.Net.Delegates.EventHandlerForActiveControl<TEventArgs>
CSharpTest.Net.Delegates.ForcedEventHandlerForControl<TEventArgs>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Members
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
EventHandlerForControl<TEventArgs> Class Members
See Also Fields Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForControl<TEventArgs> Class

Glossary Item Box

The following tables list the members exposed by EventHandlerForControl<TEventArgs>.

Public Constructors

 | Name | Description
Public Constructor | EventHandlerForControl<TEventArgs> Constructor | Overloaded.
Top

Protected Fields

 | Name | Description
Protected Field | _control | The control who's thread we will use for the invoke
Protected Field | _delegate | The delegate to invoke on the control
Top

Public Methods

 | Name | Description
Public Method | EventHandler | Handles the 'magic' of safely invoking the delegate on the control without producing a dead-lock.
Top

Protected Methods

 | Name | Description
Protected Method | OnControlDisposed | Used to handle the condition that a control's handle is not currently available. This can either be before construction or after being disposed.
Top

Public Operators

public Operator Implicit Type Conversion This object will allow an implicit cast to the EventHandler<T> type for easier use.
Top

See Also

Reference

EventHandlerForControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventHandlerForControl<TEventArgs> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class : EventHandlerForControl<TEventArgs> Constructor

Glossary Item Box

Overload List

Overload | Description
EventHandlerForControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>) | Constructs an EventHandler for the specified method on the given control instance.
EventHandlerForControl<TEventArgs> Constructor(Control,Delegate) | Constructs an EventHandler for the specified delegate converting it to the expected EventHandler<TEventArgs> delegate type.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Class
EventHandlerForControl<TEventArgs> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
EventHandlerForControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class > EventHandlerForControl<TEventArgs> Constructor : EventHandlerForControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>)

control
handler

Glossary Item Box

Constructs an EventHandler for the specified method on the given control instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal control As Control, _
   ByVal handler As EventHandler(Of TEventArgs) _
)
C#
public EventHandlerForControl<TEventArgs>(
   Control control,
   EventHandler<TEventArgs> handler
)

Parameters

control
handler

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
EventHandler<VerifiedReceiptEventArgs> handler;
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();

_thread.Start();
_form.FormCreated.WaitOne();

try
{
    handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, CloseTheForm);
    handler(null, args);
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As EventHandler(Of VerifiedReceiptEventArgs)
Dim args As New VerifiedReceiptEventArgs()

_thread.Start()
_form.FormCreated.WaitOne()

Try
    handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, CloseTheForm)
    handler(Nothing, args)
Finally
    _thread.Join()
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Class
EventHandlerForControl<TEventArgs> Members
Overload List

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventHandlerForControl<TEventArgs> Constructor(Control,Delegate)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class > EventHandlerForControl<TEventArgs> Constructor : EventHandlerForControl<TEventArgs> Constructor(Control,Delegate)

control
handler

Glossary Item Box

Constructs an EventHandler for the specified delegate converting it to the expected EventHandler<TEventArgs> delegate type.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal control As Control, _
   ByVal handler As Delegate _
)
C#
public EventHandlerForControl<TEventArgs>(
   Control control,
   Delegate handler
)

Parameters

control
handler

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
EventHandler<VerifiedReceiptEventArgs> handler;
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();

_thread.Start();
_form.FormCreated.WaitOne();

handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler(null, args.Reset());
Assert.IsTrue(args.Received);
Assert.IsTrue(args.OnThread);

handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(VerifiedReceiptRedirect));
handler(null, args.Reset());
Assert.IsTrue(args.Received);
Assert.IsTrue(args.OnThread);

_form.BeginInvoke((Action)_form.Close);
_thread.Join();
VB.NET Copy Code
Dim handler As EventHandler(Of VerifiedReceiptEventArgs)
Dim args As New VerifiedReceiptEventArgs()

_thread.Start()
_form.FormCreated.WaitOne()

handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler(Nothing, args.Reset())
Assert.IsTrue(args.Received)
Assert.IsTrue(args.OnThread)

handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(VerifiedReceiptRedirect))
handler(Nothing, args.Reset())
Assert.IsTrue(args.Received)
Assert.IsTrue(args.OnThread)

_form.BeginInvoke(DirectCast(_form.Close, Action))
_thread.Join()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Class
EventHandlerForControl<TEventArgs> Members
Overload List

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
EventHandlerForControl<TEventArgs> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForControl<TEventArgs> Class

Glossary Item Box

For a list of all members of this type, see EventHandlerForControl<TEventArgs> members.

Public Methods

 | Name | Description
Public Method | EventHandler | Handles the 'magic' of safely invoking the delegate on the control without producing a dead-lock.
Top

Protected Methods

 | Name | Description
Protected Method | OnControlDisposed | Used to handle the condition that a control's handle is not currently available. This can either be before construction or after being disposed.
Top

See Also

Reference

EventHandlerForControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventHandler Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class : EventHandler Method

sender
args

Glossary Item Box

Handles the 'magic' of safely invoking the delegate on the control without producing a dead-lock.

Syntax

Visual Basic (Declaration)
Public Sub EventHandler( _
   ByVal sender As Object, _
   ByVal args As TEventArgs _
)
C#
public void EventHandler(
   object sender,
   TEventArgs args
)

Parameters

sender
args

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
EventHandlerForActiveControl<VerifiedReceiptEventArgs> handler;
handler = new EventHandlerForActiveControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler = new EventHandlerForActiveControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(handler.EventHandler));
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
_form.Shown += delegate(object s, EventArgs e) { System.Threading.Thread.Sleep(100); _form.Close(); };
_thread.Start();
int total = 0, countOnThread = 0, countOffThread = 0;
try
{
    for (total = 1; total < 1000000; total++)
    {
        handler.EventHandler(null, args.Reset());
        if (args.OnThread)
        {
            Assert.IsTrue(args.Received);
            countOnThread++;
        }
        else
        {
            Assert.IsFalse(args.Received);
            countOffThread++;
        }
        //Assert.IsTrue(args.OnThread);
        //Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        if (_form.IsDisposed)
            break;
    }
    Assert.AreEqual(total, countOnThread + countOffThread);
    Assert.IsTrue(_form.IsDisposed);
    Assert.AreNotEqual(0, countOnThread);
    Assert.AreNotEqual(0, countOffThread);
}
catch (Exception e)
{
    Console.Error.WriteLine(e.ToString());
    throw;
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)
handler = New EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler = New EventHandlerForActiveControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(handler.EventHandler))
Dim args As New VerifiedReceiptEventArgs()
_form.Shown += Function(s As Object, e As EventArgs) Do
    System.Threading.Thread.Sleep(100)
    _form.Close()
End Function
_thread.Start()
Dim total As Integer = 0, countOnThread As Integer = 0, countOffThread As Integer = 0
Try
    total = 1
    While total < 1000000
        handler.EventHandler(Nothing, args.Reset())
        If args.OnThread Then
            Assert.IsTrue(args.Received)
            System.Math.Max(System.Threading.Interlocked.Increment(countOnThread),countOnThread - 1)
        Else
            Assert.IsFalse(args.Received)
            System.Math.Max(System.Threading.Interlocked.Increment(countOffThread),countOffThread - 1)
        End If
        'Assert.IsTrue(args.OnThread);
        'Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        If _form.IsDisposed Then
            Exit While
        End If
        System.Math.Max(System.Threading.Interlocked.Increment(total),total - 1)
    End While
    Assert.AreEqual(total, countOnThread + countOffThread)
    Assert.IsTrue(_form.IsDisposed)
    Assert.AreNotEqual(0, countOnThread)
    Assert.AreNotEqual(0, countOffThread)
Catch e As Exception
    Console.[Error].WriteLine(e.ToString())
    Throw
Finally
    _thread.Join()
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Class
EventHandlerForControl<TEventArgs> Members

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnControlDisposed Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class : OnControlDisposed Method

sender
args

Glossary Item Box

Used to handle the condition that a control's handle is not currently available. This can either be before construction or after being disposed.

Syntax

Visual Basic (Declaration)
Protected Overridable Sub OnControlDisposed( _
   ByVal sender As Object, _
   ByVal args As TEventArgs _
)
C#
protected virtual void OnControlDisposed(
   object sender,
   TEventArgs args
)

Parameters

sender
args

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Class
EventHandlerForControl<TEventArgs> Members

Used By

EventHandlerForControl.EventHandler(Object,TEventArgs)


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
EventHandlerForControl<TEventArgs> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForControl<TEventArgs> Class

Glossary Item Box

For a list of all members of this type, see EventHandlerForControl<TEventArgs> members.

Protected Fields

 | Name | Description
Protected Field | _control | The control who's thread we will use for the invoke
Protected Field | _delegate | The delegate to invoke on the control
Top

See Also

Reference

EventHandlerForControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
_control Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class : _control Field

Glossary Item Box

The control who's thread we will use for the invoke

Syntax

Visual Basic (Declaration)
Protected ReadOnly _control As Control
C#
protected readonly Control _control

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Class
EventHandlerForControl<TEventArgs> Members

Used By

EventHandlerForControl.EventHandler(Object,TEventArgs)


%%PageItemTitle%%

[image]
CSharpTest.Net
_delegate Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class : _delegate Field

Glossary Item Box

The delegate to invoke on the control

Syntax

Visual Basic (Declaration)
Protected ReadOnly _delegate As EventHandler(Of TEventArgs)
C#
protected readonly EventHandler<TEventArgs> _delegate

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Class
EventHandlerForControl<TEventArgs> Members

Used By

EventHandlerForControl.EventHandler(Object,TEventArgs)


%%PageItemTitle%%

[image]
CSharpTest.Net
Implicit Type Conversion Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > EventHandlerForControl<TEventArgs> Class : Implicit Type Conversion Operator

instance

Glossary Item Box

This object will allow an implicit cast to the EventHandler<T> type for easier use.

Syntax

Visual Basic (Declaration)
Public Operator Widening CType( _
   ByVal instance As EventHandlerForControl(Of TEventArgs) _
) As EventHandler(Of TEventArgs)
C#
public EventHandler<TEventArgs> operator implicit(
   EventHandlerForControl<TEventArgs> instance
)

Parameters

instance

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventHandlerForControl<TEventArgs> Class
EventHandlerForControl<TEventArgs> Members


%%PageItemTitle%%

TEventArgs
[image]
CSharpTest.Net
ForcedEventHandlerForControl<TEventArgs> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : ForcedEventHandlerForControl<TEventArgs> Class

Glossary Item Box

This derivation of EventHandlerForControl<TEventArgs> will directly call the delegate on the current thread if the control's handle is not valid rather than raising the ObjectDisposedExcpetion.

Syntax

Visual Basic (Declaration)
Public Class ForcedEventHandlerForControl(Of TEventArgs As EventArgs)
   Inherits EventHandlerForControl(Of TEventArgs)
C#
public class ForcedEventHandlerForControl<TEventArgs> : EventHandlerForControl<TEventArgs>
where TEventArgs: EventArgs

Type Parameters

TEventArgs

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
ForcedEventHandlerForControl<VerifiedReceiptEventArgs> handler;
handler = new ForcedEventHandlerForControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler = new ForcedEventHandlerForControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(handler.EventHandler));
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
_form.Shown += delegate(object s, EventArgs e) { System.Threading.Thread.Sleep(100); _form.Close(); };
_thread.Start();
int total = 0, countOnThread = 0, countOffThread = 0;
try
{
    for (total = 1; total < 1000000; total++)
    {
        handler.EventHandler(null, args.Reset());
        Assert.IsTrue(args.Received);
        if (args.OnThread)
            countOnThread++;
        else
            countOffThread++;
        //Assert.IsTrue(args.OnThread);
        //Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        if (_form.IsDisposed)
            break;
    }
    Assert.AreEqual(total, countOnThread + countOffThread);
    Assert.IsTrue(_form.IsDisposed);
    Assert.AreNotEqual(0, countOnThread);
    Assert.AreNotEqual(0, countOffThread);
}
catch (Exception e)
{
    Console.Error.WriteLine(e.ToString());
    throw;
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)
handler = New ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler = New ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(handler.EventHandler))
Dim args As New VerifiedReceiptEventArgs()
_form.Shown += Function(s As Object, e As EventArgs) Do
    System.Threading.Thread.Sleep(100)
    _form.Close()
End Function
_thread.Start()
Dim total As Integer = 0, countOnThread As Integer = 0, countOffThread As Integer = 0
Try
    total = 1
    While total < 1000000
        handler.EventHandler(Nothing, args.Reset())
        Assert.IsTrue(args.Received)
        If args.OnThread Then
            System.Math.Max(System.Threading.Interlocked.Increment(countOnThread),countOnThread - 1)
        Else
            System.Math.Max(System.Threading.Interlocked.Increment(countOffThread),countOffThread - 1)
        End If
        'Assert.IsTrue(args.OnThread);
        'Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        If _form.IsDisposed Then
            Exit While
        End If
        System.Math.Max(System.Threading.Interlocked.Increment(total),total - 1)
    End While
    Assert.AreEqual(total, countOnThread + countOffThread)
    Assert.IsTrue(_form.IsDisposed)
    Assert.AreNotEqual(0, countOnThread)
    Assert.AreNotEqual(0, countOffThread)
Catch e As Exception
    Console.[Error].WriteLine(e.ToString())
    Throw
Finally
    _thread.Join()
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>
CSharpTest.Net.Delegates.ForcedEventHandlerForControl<TEventArgs>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ForcedEventHandlerForControl<TEventArgs> Members
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ForcedEventHandlerForControl<TEventArgs> Class Members
See Also Fields Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : ForcedEventHandlerForControl<TEventArgs> Class

Glossary Item Box

The following tables list the members exposed by ForcedEventHandlerForControl<TEventArgs>.

Public Constructors

 | Name | Description
Public Constructor | ForcedEventHandlerForControl<TEventArgs> Constructor | Overloaded.
Top

Protected Fields

 | Name | Description
Protected Field | _control | The control who's thread we will use for the invoke (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Protected Field | _delegate | The delegate to invoke on the control (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Top

Public Methods

 | Name | Description
Public Method | EventHandler | Handles the 'magic' of safely invoking the delegate on the control without producing a dead-lock. (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Top

Protected Methods

 | Name | Description
Protected Method | OnControlDisposed | Overridden. Handle the case when the control is not valid
Top

See Also

Reference

ForcedEventHandlerForControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ForcedEventHandlerForControl<TEventArgs> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > ForcedEventHandlerForControl<TEventArgs> Class : ForcedEventHandlerForControl<TEventArgs> Constructor

Glossary Item Box

Overload List

Overload | Description
ForcedEventHandlerForControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>) | Constructs an EventHandler for the specified method on the given control instance.
ForcedEventHandlerForControl<TEventArgs> Constructor(Control,Delegate) | Constructs an EventHandler for the specified method on the given control instance.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ForcedEventHandlerForControl<TEventArgs> Class
ForcedEventHandlerForControl<TEventArgs> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ForcedEventHandlerForControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > ForcedEventHandlerForControl<TEventArgs> Class > ForcedEventHandlerForControl<TEventArgs> Constructor : ForcedEventHandlerForControl<TEventArgs> Constructor(Control,EventHandler<TEventArgs>)

control
handler

Glossary Item Box

Constructs an EventHandler for the specified method on the given control instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal control As Control, _
   ByVal handler As EventHandler(Of TEventArgs) _
)
C#
public ForcedEventHandlerForControl<TEventArgs>(
   Control control,
   EventHandler<TEventArgs> handler
)

Parameters

control
handler

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
ForcedEventHandlerForControl<VerifiedReceiptEventArgs> handler;
handler = new ForcedEventHandlerForControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler = new ForcedEventHandlerForControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(handler.EventHandler));
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
_form.Shown += delegate(object s, EventArgs e) { System.Threading.Thread.Sleep(100); _form.Close(); };
_thread.Start();
int total = 0, countOnThread = 0, countOffThread = 0;
try
{
    for (total = 1; total < 1000000; total++)
    {
        handler.EventHandler(null, args.Reset());
        Assert.IsTrue(args.Received);
        if (args.OnThread)
            countOnThread++;
        else
            countOffThread++;
        //Assert.IsTrue(args.OnThread);
        //Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        if (_form.IsDisposed)
            break;
    }
    Assert.AreEqual(total, countOnThread + countOffThread);
    Assert.IsTrue(_form.IsDisposed);
    Assert.AreNotEqual(0, countOnThread);
    Assert.AreNotEqual(0, countOffThread);
}
catch (Exception e)
{
    Console.Error.WriteLine(e.ToString());
    throw;
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)
handler = New ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler = New ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(handler.EventHandler))
Dim args As New VerifiedReceiptEventArgs()
_form.Shown += Function(s As Object, e As EventArgs) Do
    System.Threading.Thread.Sleep(100)
    _form.Close()
End Function
_thread.Start()
Dim total As Integer = 0, countOnThread As Integer = 0, countOffThread As Integer = 0
Try
    total = 1
    While total < 1000000
        handler.EventHandler(Nothing, args.Reset())
        Assert.IsTrue(args.Received)
        If args.OnThread Then
            System.Math.Max(System.Threading.Interlocked.Increment(countOnThread),countOnThread - 1)
        Else
            System.Math.Max(System.Threading.Interlocked.Increment(countOffThread),countOffThread - 1)
        End If
        'Assert.IsTrue(args.OnThread);
        'Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        If _form.IsDisposed Then
            Exit While
        End If
        System.Math.Max(System.Threading.Interlocked.Increment(total),total - 1)
    End While
    Assert.AreEqual(total, countOnThread + countOffThread)
    Assert.IsTrue(_form.IsDisposed)
    Assert.AreNotEqual(0, countOnThread)
    Assert.AreNotEqual(0, countOffThread)
Catch e As Exception
    Console.[Error].WriteLine(e.ToString())
    Throw
Finally
    _thread.Join()
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ForcedEventHandlerForControl<TEventArgs> Class
ForcedEventHandlerForControl<TEventArgs> Members
Overload List

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ForcedEventHandlerForControl<TEventArgs> Constructor(Control,Delegate)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > ForcedEventHandlerForControl<TEventArgs> Class > ForcedEventHandlerForControl<TEventArgs> Constructor : ForcedEventHandlerForControl<TEventArgs> Constructor(Control,Delegate)

control
handler

Glossary Item Box

Constructs an EventHandler for the specified method on the given control instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal control As Control, _
   ByVal handler As Delegate _
)
C#
public ForcedEventHandlerForControl<TEventArgs>(
   Control control,
   Delegate handler
)

Parameters

control
handler

Example

Library/Library.Test/TestDelegates.cs

C# Copy Code
ForcedEventHandlerForControl<VerifiedReceiptEventArgs> handler;
handler = new ForcedEventHandlerForControl<VerifiedReceiptEventArgs>(_form, VerifiedReceipt);
handler = new ForcedEventHandlerForControl<VerifiedReceiptEventArgs>(_form, new VerifiedReceiptEventHandler(handler.EventHandler));
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();
_form.Shown += delegate(object s, EventArgs e) { System.Threading.Thread.Sleep(100); _form.Close(); };
_thread.Start();
int total = 0, countOnThread = 0, countOffThread = 0;
try
{
    for (total = 1; total < 1000000; total++)
    {
        handler.EventHandler(null, args.Reset());
        Assert.IsTrue(args.Received);
        if (args.OnThread)
            countOnThread++;
        else
            countOffThread++;
        //Assert.IsTrue(args.OnThread);
        //Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        if (_form.IsDisposed)
            break;
    }
    Assert.AreEqual(total, countOnThread + countOffThread);
    Assert.IsTrue(_form.IsDisposed);
    Assert.AreNotEqual(0, countOnThread);
    Assert.AreNotEqual(0, countOffThread);
}
catch (Exception e)
{
    Console.Error.WriteLine(e.ToString());
    throw;
}
finally
{
    _thread.Join();
}
VB.NET Copy Code
Dim handler As ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)
handler = New ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, VerifiedReceipt)
handler = New ForcedEventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, New VerifiedReceiptEventHandler(handler.EventHandler))
Dim args As New VerifiedReceiptEventArgs()
_form.Shown += Function(s As Object, e As EventArgs) Do
    System.Threading.Thread.Sleep(100)
    _form.Close()
End Function
_thread.Start()
Dim total As Integer = 0, countOnThread As Integer = 0, countOffThread As Integer = 0
Try
    total = 1
    While total < 1000000
        handler.EventHandler(Nothing, args.Reset())
        Assert.IsTrue(args.Received)
        If args.OnThread Then
            System.Math.Max(System.Threading.Interlocked.Increment(countOnThread),countOnThread - 1)
        Else
            System.Math.Max(System.Threading.Interlocked.Increment(countOffThread),countOffThread - 1)
        End If
        'Assert.IsTrue(args.OnThread);
        'Console.Error.WriteLine("Threaded = {0}", args.OnThread);
        If _form.IsDisposed Then
            Exit While
        End If
        System.Math.Max(System.Threading.Interlocked.Increment(total),total - 1)
    End While
    Assert.AreEqual(total, countOnThread + countOffThread)
    Assert.IsTrue(_form.IsDisposed)
    Assert.AreNotEqual(0, countOnThread)
    Assert.AreNotEqual(0, countOffThread)
Catch e As Exception
    Console.[Error].WriteLine(e.ToString())
    Throw
Finally
    _thread.Join()
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ForcedEventHandlerForControl<TEventArgs> Class
ForcedEventHandlerForControl<TEventArgs> Members
Overload List

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ForcedEventHandlerForControl<TEventArgs> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : ForcedEventHandlerForControl<TEventArgs> Class

Glossary Item Box

For a list of all members of this type, see ForcedEventHandlerForControl<TEventArgs> members.

Public Methods

 | Name | Description
Public Method | EventHandler | Handles the 'magic' of safely invoking the delegate on the control without producing a dead-lock. (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Top

Protected Methods

 | Name | Description
Protected Method | OnControlDisposed | Overridden. Handle the case when the control is not valid
Top

See Also

Reference

ForcedEventHandlerForControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnControlDisposed Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > ForcedEventHandlerForControl<TEventArgs> Class : OnControlDisposed Method

sender
args

Glossary Item Box

Handle the case when the control is not valid

Syntax

Visual Basic (Declaration)
Protected Overrides Sub OnControlDisposed( _
   ByVal sender As Object, _
   ByVal args As TEventArgs _
)
C#
protected override void OnControlDisposed(
   object sender,
   TEventArgs args
)

Parameters

sender
args

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ForcedEventHandlerForControl<TEventArgs> Class
ForcedEventHandlerForControl<TEventArgs> Members
Base Implementation in OnControlDisposed


%%PageItemTitle%%

[image]
CSharpTest.Net
TimeoutAction Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : TimeoutAction Class

Glossary Item Box

Provides scheduling a single-fire event at some duration into the future. The operation is performed once either when the duration expires, or when this object is disposed or collected.

Syntax

Visual Basic (Declaration)
Public Class TimeoutAction
C#
public class TimeoutAction

Inheritance Hierarchy

System.Object
CSharpTest.Net.Delegates.TimeoutAction

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Members
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TimeoutAction Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : TimeoutAction Class

Glossary Item Box

The following tables list the members exposed by TimeoutAction.

Public Constructors

 | Name | Description
Public Constructor | TimeoutAction Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Overloaded. Fires if the event if needed and closes the object
static (Shared in Visual Basic) | Start | Overloaded. Enqueues a task to be performed at some time in the future
Top

Protected Methods

 | Name | Description
Protected Method | Finalize | Fires if the event if needed and closes the object
Top

See Also

Reference

TimeoutAction Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TimeoutAction Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class : TimeoutAction Constructor

Glossary Item Box

Overload List

Overload | Description
TimeoutAction Constructor(TimeSpan,Action) | Provides scheduling a single-fire event at some duration into the future. The operation is performed once either when the duration expires, or when this object is disposed or collected.
TimeoutAction Constructor(TimeSpan,Action,Action<Exception>) | Provides scheduling a single-fire event at some duration into the future. The operation is performed once either when the duration expires, or when this object is disposed or collected.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TimeoutAction Constructor(TimeSpan,Action)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class > TimeoutAction Constructor : TimeoutAction Constructor(TimeSpan,Action)

wait
perform

Glossary Item Box

Provides scheduling a single-fire event at some duration into the future. The operation is performed once either when the duration expires, or when this object is disposed or collected.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal wait As TimeSpan, _
   ByVal perform As Action _
)
C#
public TimeoutAction(
   TimeSpan wait,
   Action perform
)

Parameters

wait
perform

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Overload List

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TimeoutAction Constructor(TimeSpan,Action,Action<Exception>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class > TimeoutAction Constructor : TimeoutAction Constructor(TimeSpan,Action,Action<Exception>)

wait
perform
onerror

Glossary Item Box

Provides scheduling a single-fire event at some duration into the future. The operation is performed once either when the duration expires, or when this object is disposed or collected.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal wait As TimeSpan, _
   ByVal perform As Action, _
   ByVal onerror As Action(Of Exception) _
)
C#
public TimeoutAction(
   TimeSpan wait,
   Action perform,
   Action<Exception> onerror
)

Parameters

wait
perform
onerror

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Overload List

Used By

TimeoutAction TimeoutAction.Start(TimeSpan,Action,Action)

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TimeoutAction Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : TimeoutAction Class

Glossary Item Box

For a list of all members of this type, see TimeoutAction members.

Public Methods

 | Name | Description
Public Method | Dispose | Overloaded. Fires if the event if needed and closes the object
static (Shared in Visual Basic) | Start | Overloaded. Enqueues a task to be performed at some time in the future
Top

Protected Methods

 | Name | Description
Protected Method | Finalize | Fires if the event if needed and closes the object
Top

See Also

Reference

TimeoutAction Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class : Dispose Method

Glossary Item Box

Fires if the event if needed and closes the object

Overload List

Overload | Description
Dispose() | Fires if the event if needed and closes the object
Dispose(Boolean) | Fires if the event if needed and closes the object

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class > Dispose Method : Dispose() Method

Glossary Item Box

Fires if the event if needed and closes the object

Syntax

Visual Basic (Declaration)
Public Overloads Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Overload List

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Fires if the event if needed and closes the object

Syntax

Visual Basic (Declaration)
Protected Overloads Overridable Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected virtual void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Overload List

Used By

TimeoutAction.Dispose()


%%PageItemTitle%%

[image]
CSharpTest.Net
Finalize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class : Finalize Method

Glossary Item Box

Fires if the event if needed and closes the object

Syntax

Visual Basic (Declaration)
Protected Overrides Sub Finalize()
C#
protected override void Finalize()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Base Implementation in Finalize


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class : Start Method

Glossary Item Box

Enqueues a task to be performed at some time in the future

Overload List

Overload | Description
Start(TimeSpan,Action) | Enqueues a task to be performed at some time in the future
Start(TimeSpan,Action,Action<Exception>) | Enqueues a task to be performed at some time in the future
Start<T1>(TimeSpan,Action<T1>,T1) | Enqueues a task to be performed at some time in the future
Start<T1>(TimeSpan,Action<T1>,T1,Action<Exception>) | Enqueues a task to be performed at some time in the future

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Start(TimeSpan,Action) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class > Start Method : Start(TimeSpan,Action) Method

wait
perform

Glossary Item Box

Enqueues a task to be performed at some time in the future

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Start( _
   ByVal wait As TimeSpan, _
   ByVal perform As Action _
) As TimeoutAction
C#
public static TimeoutAction Start(
   TimeSpan wait,
   Action perform
)

Parameters

wait
perform

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Overload List

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start(TimeSpan,Action,Action<Exception>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class > Start Method : Start(TimeSpan,Action,Action<Exception>) Method

wait
perform
onerror

Glossary Item Box

Enqueues a task to be performed at some time in the future

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Start( _
   ByVal wait As TimeSpan, _
   ByVal perform As Action, _
   ByVal onerror As Action(Of Exception) _
) As TimeoutAction
C#
public static TimeoutAction Start(
   TimeSpan wait,
   Action perform,
   Action<Exception> onerror
)

Parameters

wait
perform
onerror

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Overload List

Used By

TimeoutAction TimeoutAction.Start(TimeSpan,Action)
TimeoutAction TimeoutAction.Start(TimeSpan,Action,T1,Action)

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%%

T1
[image]
CSharpTest.Net
Start<T1>(TimeSpan,Action<T1>,T1) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class > Start Method : Start<T1>(TimeSpan,Action<T1>,T1) Method

wait
perform
arg1

Glossary Item Box

Enqueues a task to be performed at some time in the future

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Start(Of T1)( _
   ByVal wait As TimeSpan, _
   ByVal perform As Action(Of T1), _
   ByVal arg1 As T1 _
) As TimeoutAction
C#
public static TimeoutAction Start<T1>(
   TimeSpan wait,
   Action<T1> perform,
   T1 arg1
)

Parameters

wait
perform
arg1

Type Parameters

T1

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Overload List

Source Code

Library/Delegates/TimeoutAction.cs


%%PageItemTitle%%

T1
[image]
CSharpTest.Net
Start<T1>(TimeSpan,Action<T1>,T1,Action<Exception>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace > TimeoutAction Class > Start Method : Start<T1>(TimeSpan,Action<T1>,T1,Action<Exception>) Method

wait
perform
arg1
onerror

Glossary Item Box

Enqueues a task to be performed at some time in the future

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Start(Of T1)( _
   ByVal wait As TimeSpan, _
   ByVal perform As Action(Of T1), _
   ByVal arg1 As T1, _
   ByVal onerror As Action(Of Exception) _
) As TimeoutAction
C#
public static TimeoutAction Start<T1>(
   TimeSpan wait,
   Action<T1> perform,
   T1 arg1,
   Action<Exception> onerror
)

Parameters

wait
perform
arg1
onerror

Type Parameters

T1

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TimeoutAction Class
TimeoutAction Members
Overload List

Source Code

Library/Delegates/TimeoutAction.cs


%%ItemTitle%%

CSharpTest.Net.Formatting Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Formatting Namespace

Glossary Item Box

Classes

 | Class | Description
Class | Base64Stream | Provides reading and writing to a stream of base-64 characters.
Class | Base64Stream.Transform | Provides a crypto-transform used to read/write to a stream of base-64 characters.
Class | ByteEncoding | Defines a type of formatting for encoding byte[] to a string value
Class | HexEncoding | The hexidecimal encoding for the bytes using the following characters: 0-9, a-f
Class | HexStream | Provides reading and writing to a stream of hexidecimal characters.
Class | HexStream.Transform | Provides a crypto-transform used to read/write to a stream of hexidecimal characters.
Class | Safe64Encoding | This encoding produces a 'url' safe string from bytes, similar to base64 encoding yet it replaces '+' with '-', '/' with '_' and omits padding.
Class | Safe64Stream | Provides reading and writing to a stream of base-64 characters while replacing '+' with '-' and '/' with '_' and ommitting padding.
Class | Safe64Stream.Transform | Provides a crypto-transform used to read/write to a stream of base-64 characters while replacing '+' with '-' and '/' with '_' and ommitting padding.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
Base64Stream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Base64Stream Class

Glossary Item Box

Provides reading and writing to a stream of base-64 characters.

Syntax

Visual Basic (Declaration)
Public Class Base64Stream
   Inherits System.Security.Cryptography.CryptoStream
C#
public class Base64Stream : System.Security.Cryptography.CryptoStream

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
byte[] data = new byte[256];
for (int i = 0; i < data.Length; i++)
    data[i] = (byte)i;

using (Stream mem = new MemoryStream())
{
    using (Stream io = new Base64Stream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(data, 0, data.Length);

    Assert.AreEqual(((data.Length + 2) / 3 * 4), mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(Convert.ToBase64String(data), test);
}
VB.NET Copy Code
Dim data As Byte() = New Byte(256) {}
Dim i As Integer = 0
While i < data.Length
    data(i) = DirectCast(i, Byte)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Using mem As Stream = New MemoryStream()
    Using io As Stream = New Base64Stream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(data, 0, data.Length)
    End Using

    Assert.AreEqual(((data.Length + 2) / 3 * 4), mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(Convert.ToBase64String(data), test)
End Using

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
System.Security.Cryptography.CryptoStream
CSharpTest.Net.Formatting.Base64Stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Base64Stream Members
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Base64Stream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Base64Stream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Base64Stream Class

Glossary Item Box

The following tables list the members exposed by Base64Stream.

Public Constructors

 | Name | Description
Public Constructor | Base64Stream Constructor | Provides reading and writing to a stream of base-64 characters.
Top

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.CryptoStream. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | FlushFinalBlock | Updates the underlying data source or repository with the current state of the buffer, then clears the buffer. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

Base64Stream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Base64Stream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Base64Stream Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Base64Stream Class : Base64Stream Constructor

stream
mode

Glossary Item Box

Provides reading and writing to a stream of base-64 characters.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream, _
   ByVal mode As CryptoStreamMode _
)
C#
public Base64Stream(
   Stream stream,
   CryptoStreamMode mode
)

Parameters

stream
mode

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
byte[] data = new byte[256];
for (int i = 0; i < data.Length; i++)
    data[i] = (byte)i;

using (Stream mem = new MemoryStream())
{
    using (Stream io = new Base64Stream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(data, 0, data.Length);

    Assert.AreEqual(((data.Length + 2) / 3 * 4), mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(Convert.ToBase64String(data), test);
}
VB.NET Copy Code
Dim data As Byte() = New Byte(256) {}
Dim i As Integer = 0
While i < data.Length
    data(i) = DirectCast(i, Byte)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Using mem As Stream = New MemoryStream()
    Using io As Stream = New Base64Stream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(data, 0, data.Length)
    End Using

    Assert.AreEqual(((data.Length + 2) / 3 * 4), mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(Convert.ToBase64String(data), test)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Base64Stream Class
Base64Stream Members

Source Code

Library/Formatting/Base64Stream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Base64Stream.Transform Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Base64Stream.Transform Class

Glossary Item Box

Provides a crypto-transform used to read/write to a stream of base-64 characters.

Syntax

Visual Basic (Declaration)
Public Class Base64Stream.Transform
C#
public class Base64Stream.Transform

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
using (ICryptoTransform xform = new Base64Stream.Transform(CryptoStreamMode.Read))
{
    Assert.AreEqual(4, xform.InputBlockSize);
    Assert.AreEqual(3, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
using (ICryptoTransform xform = new Base64Stream.Transform(CryptoStreamMode.Write))
{
    Assert.AreEqual(3, xform.InputBlockSize);
    Assert.AreEqual(4, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
VB.NET Copy Code
Using xform As ICryptoTransform = New Base64Stream.Transform(CryptoStreamMode.Read)
    Assert.AreEqual(4, xform.InputBlockSize)
    Assert.AreEqual(3, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using
Using xform As ICryptoTransform = New Base64Stream.Transform(CryptoStreamMode.Write)
    Assert.AreEqual(3, xform.InputBlockSize)
    Assert.AreEqual(4, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Formatting.Base64Stream.Transform

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Base64Stream.Transform Members
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Base64Stream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Base64Stream.Transform Class Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Base64Stream.Transform Class

Glossary Item Box

The following tables list the members exposed by Base64Stream.Transform.

Public Constructors

 | Name | Description
Public Constructor | Base64Stream.Transform Constructor | Provides a crypto-transform used to read/write to a stream of base-64 characters.
Top

See Also

Reference

Base64Stream.Transform Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Base64Stream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Base64Stream.Transform Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Base64Stream.Transform Class : Base64Stream.Transform Constructor

mode

Glossary Item Box

Provides a crypto-transform used to read/write to a stream of base-64 characters.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal mode As CryptoStreamMode _
)
C#
public Base64Stream.Transform(
   CryptoStreamMode mode
)

Parameters

mode

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
using (ICryptoTransform xform = new Base64Stream.Transform(CryptoStreamMode.Read))
{
    Assert.AreEqual(4, xform.InputBlockSize);
    Assert.AreEqual(3, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
using (ICryptoTransform xform = new Base64Stream.Transform(CryptoStreamMode.Write))
{
    Assert.AreEqual(3, xform.InputBlockSize);
    Assert.AreEqual(4, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
VB.NET Copy Code
Using xform As ICryptoTransform = New Base64Stream.Transform(CryptoStreamMode.Read)
    Assert.AreEqual(4, xform.InputBlockSize)
    Assert.AreEqual(3, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using
Using xform As ICryptoTransform = New Base64Stream.Transform(CryptoStreamMode.Write)
    Assert.AreEqual(3, xform.InputBlockSize)
    Assert.AreEqual(4, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Base64Stream.Transform Class
Base64Stream.Transform Members

Source Code

Library/Formatting/Base64Stream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ByteEncoding Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : ByteEncoding Class

Glossary Item Box

Defines a type of formatting for encoding byte[] to a string value

Syntax

Visual Basic (Declaration)
Public MustInherit Class ByteEncoding
C#
public abstract class ByteEncoding

Inheritance Hierarchy

System.Object
CSharpTest.Net.Formatting.ByteEncoding

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ByteEncoding Members
CSharpTest.Net.Formatting Namespace
String IEncryptDecrypt.Encrypt(String,ByteEncoding)
String IEncryptDecrypt.Decrypt(String,ByteEncoding)
String CryptoKey.Encrypt(String,ByteEncoding)
String CryptoKey.Decrypt(String,ByteEncoding)

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ByteEncoding Class Members
See Also Fields Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : ByteEncoding Class

Glossary Item Box

The following tables list the members exposed by ByteEncoding.

Protected Constructors

 | Name | Description
Protected Constructor | ByteEncoding Constructor |
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Base64 | Standard base-64 padded encoding using the following characters: a-z, A-Z, 0-9, +, /, =
static (Shared in Visual Basic) | Hex | The hexidecimal encoding for the bytes using the following characters: 0-9, a-f
static (Shared in Visual Basic) | Safe64 | A modified base-64 non-padded encoding using the following characters: a-z, A-Z, 0-9, -, _
Top

Public Methods

 | Name | Description
Public Method | DecodeBytes | Decodes the string provided and returns the original set of bytes
Public Method | EncodeBytes | Encodes a set of bytes and returns the encoded text as a string
Top

See Also

Reference

ByteEncoding Class
CSharpTest.Net.Formatting Namespace
String IEncryptDecrypt.Encrypt(String,ByteEncoding)
String IEncryptDecrypt.Decrypt(String,ByteEncoding)
String CryptoKey.Encrypt(String,ByteEncoding)
String CryptoKey.Decrypt(String,ByteEncoding)

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ByteEncoding Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > ByteEncoding Class : ByteEncoding Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected ByteEncoding()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ByteEncoding Class
ByteEncoding Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ByteEncoding Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : ByteEncoding Class

Glossary Item Box

For a list of all members of this type, see ByteEncoding members.

Public Methods

 | Name | Description
Public Method | DecodeBytes | Decodes the string provided and returns the original set of bytes
Public Method | EncodeBytes | Encodes a set of bytes and returns the encoded text as a string
Top

See Also

Reference

ByteEncoding Class
CSharpTest.Net.Formatting Namespace
String IEncryptDecrypt.Encrypt(String,ByteEncoding)
String IEncryptDecrypt.Decrypt(String,ByteEncoding)
String CryptoKey.Encrypt(String,ByteEncoding)
String CryptoKey.Decrypt(String,ByteEncoding)

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > ByteEncoding Class : DecodeBytes Method

input

Glossary Item Box

Decodes the string provided and returns the original set of bytes

Syntax

Visual Basic (Declaration)
Public MustOverride Function DecodeBytes( _
   ByVal input As String _
) As Byte()
C#
public abstract byte[] DecodeBytes(
   string input
)

Parameters

input

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ByteEncoding Class
ByteEncoding Members

Used By

String CryptoKey.Decrypt(String,ByteEncoding)

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > ByteEncoding Class : EncodeBytes Method

input

Glossary Item Box

Encodes a set of bytes and returns the encoded text as a string

Syntax

Visual Basic (Declaration)
Public MustOverride Function EncodeBytes( _
   ByVal input() As Byte _
) As String
C#
public abstract string EncodeBytes(
   byte[] input
)

Parameters

input

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ByteEncoding Class
ByteEncoding Members

Used By

String CryptoKey.Encrypt(String,ByteEncoding)

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
ByteEncoding Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : ByteEncoding Class

Glossary Item Box

For a list of all members of this type, see ByteEncoding members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Base64 | Standard base-64 padded encoding using the following characters: a-z, A-Z, 0-9, +, /, =
static (Shared in Visual Basic) | Hex | The hexidecimal encoding for the bytes using the following characters: 0-9, a-f
static (Shared in Visual Basic) | Safe64 | A modified base-64 non-padded encoding using the following characters: a-z, A-Z, 0-9, -, _
Top

See Also

Reference

ByteEncoding Class
CSharpTest.Net.Formatting Namespace
String IEncryptDecrypt.Encrypt(String,ByteEncoding)
String IEncryptDecrypt.Decrypt(String,ByteEncoding)
String CryptoKey.Encrypt(String,ByteEncoding)
String CryptoKey.Decrypt(String,ByteEncoding)

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Base64 Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > ByteEncoding Class : Base64 Field

Glossary Item Box

Standard base-64 padded encoding using the following characters: a-z, A-Z, 0-9, +, /, =

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Base64 As ByteEncoding
C#
public static readonly ByteEncoding Base64

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string svalue = TEST_PASSWORD;

string esbyuser = Encryptor.Encrypt(svalue, ByteEncoding.Base64);
Assert.AreNotEqual(svalue, esbyuser);
Assert.AreEqual(svalue, Encryptor.Decrypt(esbyuser, ByteEncoding.Base64));
VB.NET Copy Code
Dim svalue As String = TEST_PASSWORD

Dim esbyuser As String = Encryptor.Encrypt(svalue, ByteEncoding.Base64)
Assert.AreNotEqual(svalue, esbyuser)
Assert.AreEqual(svalue, Encryptor.Decrypt(esbyuser, ByteEncoding.Base64))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ByteEncoding Class
ByteEncoding Members

Used By

String CryptoKey.Encrypt(String)
String CryptoKey.Decrypt(String)

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Hex Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > ByteEncoding Class : Hex Field

Glossary Item Box

The hexidecimal encoding for the bytes using the following characters: 0-9, a-f

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Hex As ByteEncoding
C#
public static readonly ByteEncoding Hex

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string value = TEST_PASSWORD;

Encryption.Passthrough.Dispose();//ignores

Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));

byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes))));
VB.NET Copy Code
Dim value As String = TEST_PASSWORD

Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))

Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))

Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ByteEncoding Class
ByteEncoding Members

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Safe64 Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > ByteEncoding Class : Safe64 Field

Glossary Item Box

A modified base-64 non-padded encoding using the following characters: a-z, A-Z, 0-9, -, _

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Safe64 As ByteEncoding
C#
public static readonly ByteEncoding Safe64

Example

Library/Library.Test/TestEncryption.cs

C# Copy Code
string svalue = TEST_PASSWORD;

string esbyuser = Encryptor.Encrypt(svalue, ByteEncoding.Safe64);
Assert.AreNotEqual(svalue, esbyuser);
Assert.AreEqual(svalue, Encryptor.Decrypt(esbyuser, ByteEncoding.Safe64));
VB.NET Copy Code
Dim svalue As String = TEST_PASSWORD

Dim esbyuser As String = Encryptor.Encrypt(svalue, ByteEncoding.Safe64)
Assert.AreNotEqual(svalue, esbyuser)
Assert.AreEqual(svalue, Encryptor.Decrypt(esbyuser, ByteEncoding.Safe64))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ByteEncoding Class
ByteEncoding Members

Source Code

Library/Formatting/ByteEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HexEncoding Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexEncoding Class

Glossary Item Box

The hexidecimal encoding for the bytes using the following characters: 0-9, a-f

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class HexEncoding
C#
public static class HexEncoding

Inheritance Hierarchy

System.Object
CSharpTest.Net.Formatting.HexEncoding

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Members
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HexEncoding Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexEncoding Class

Glossary Item Box

The following tables list the members exposed by HexEncoding.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DecodeBytes | Overloaded. Decodes the ascii text from the bytes provided into the original byte array
static (Shared in Visual Basic) | EncodeBytes | Overloaded. Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values
Top

See Also

Reference

HexEncoding Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HexEncoding Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexEncoding Class

Glossary Item Box

For a list of all members of this type, see HexEncoding members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DecodeBytes | Overloaded. Decodes the ascii text from the bytes provided into the original byte array
static (Shared in Visual Basic) | EncodeBytes | Overloaded. Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values
Top

See Also

Reference

HexEncoding Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class : DecodeBytes Method

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Overload List

Overload | Description
DecodeBytes(String) | Decodes the ascii text from the bytes provided into the original byte array
DecodeBytes(String,Int32,Int32) | Returns the original byte array provided when the encoding was performed
DecodeBytes(Byte[]) | Decodes the ascii text from the bytes provided into the original byte array
DecodeBytes(Byte[],Int32,Int32) | Decodes the ascii text from the bytes provided into the original byte array
DecodeBytes(Byte[],Int32,Int32,Byte[],Int32) | Decodes the ascii text from the bytes provided into the original byte array

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > DecodeBytes Method : DecodeBytes(String) Method

input

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input As String _
) As Byte()
C#
public static byte[] DecodeBytes(
   string input
)

Parameters

input

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
const string hex = "01-0203-0405\t0607\r\n0809\r0a0b0c\n0d0e0f10 ";
byte[] bin = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };

Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(hex)));
Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(Encoding.ASCII.GetBytes(hex))));
VB.NET Copy Code
Const  hex As String = "01-0203-0405" & vbTab & "0607" & vbCr & vbLf & "0809" & vbCr & "0a0b0c" & vbLf & "0d0e0f10 "
Dim bin As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
    7, 8, 9, 10, 11, 12, _
    13, 14, 15, 16}

Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(hex)))
Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(Encoding.ASCII.GetBytes(hex))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members
Overload List

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(String,Int32,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > DecodeBytes Method : DecodeBytes(String,Int32,Int32) Method

input
start
length

Glossary Item Box

Returns the original byte array provided when the encoding was performed

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input As String, _
   ByVal start As Integer, _
   ByVal length As Integer _
) As Byte()
C#
public static byte[] DecodeBytes(
   string input,
   int start,
   int length
)

Parameters

input
start
length

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
const string hex = "0102030405060708090a0b0c0d0e0f10";
byte[] bin = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };

Assert.AreEqual(hex.Substring(4, 10), HexEncoding.EncodeBytes(bin, 2, 5));
Assert.AreEqual(0, BinaryComparer.Compare(new byte[] { 3, 4, 5, 6 }, HexEncoding.DecodeBytes(hex, 4, 8)));
VB.NET Copy Code
Const  hex As String = "0102030405060708090a0b0c0d0e0f10"
Dim bin As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
    7, 8, 9, 10, 11, 12, _
    13, 14, 15, 16}

Assert.AreEqual(hex.Substring(4, 10), HexEncoding.EncodeBytes(bin, 2, 5))
Assert.AreEqual(0, BinaryComparer.Compare(New Byte() {3, 4, 5, 6}, HexEncoding.DecodeBytes(hex, 4, 8)))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members
Overload List

Used By

Byte[] HexEncoding.DecodeBytes(String)

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > DecodeBytes Method : DecodeBytes(Byte[]) Method

input

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input() As Byte _
) As Byte()
C#
public static byte[] DecodeBytes(
   byte[] input
)

Parameters

input

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
const string hex = "01-0203-0405\t0607\r\n0809\r0a0b0c\n0d0e0f10 ";
byte[] bin = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };

Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(hex)));
Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(Encoding.ASCII.GetBytes(hex))));
VB.NET Copy Code
Const  hex As String = "01-0203-0405" & vbTab & "0607" & vbCr & vbLf & "0809" & vbCr & "0a0b0c" & vbLf & "0d0e0f10 "
Dim bin As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
    7, 8, 9, 10, 11, 12, _
    13, 14, 15, 16}

Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(hex)))
Assert.AreEqual(0, BinaryComparer.Compare(bin, HexEncoding.DecodeBytes(Encoding.ASCII.GetBytes(hex))))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members
Overload List

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(Byte[],Int32,Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > DecodeBytes Method : DecodeBytes(Byte[],Int32,Int32) Method

input
start
length

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer _
) As Byte()
C#
public static byte[] DecodeBytes(
   byte[] input,
   int start,
   int length
)

Parameters

input
start
length

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members
Overload List

Used By

Byte[] HexEncoding.DecodeBytes(String,Int32,Int32)
Byte[] HexEncoding.DecodeBytes(Byte[])

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(Byte[],Int32,Int32,Byte[],Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > DecodeBytes Method : DecodeBytes(Byte[],Int32,Int32,Byte[],Int32) Method

input
start
length
results
offset

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer, _
   ByVal results() As Byte, _
   ByVal offset As Integer _
) As Integer
C#
public static int DecodeBytes(
   byte[] input,
   int start,
   int length,
   byte[] results,
   int offset
)

Parameters

input
start
length
results
offset

Exceptions

Exception | Description
System.FormatException | The exception that is thrown when the format of an argument does not meet the parameter specifications of the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members
Overload List

Used By

Byte[] HexEncoding.DecodeBytes(Byte[],Int32,Int32)

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class : EncodeBytes Method

Glossary Item Box

Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values

Overload List

Overload | Description
EncodeBytes(Byte[]) | Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values
EncodeBytes(Byte[],Int32,Int32) | Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values
EncodeBytes(Byte[],Int32,Int32,Byte[],Int32) | Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > EncodeBytes Method : EncodeBytes(Byte[]) Method

input

Glossary Item Box

Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function EncodeBytes( _
   ByVal input() As Byte _
) As String
C#
public static string EncodeBytes(
   byte[] input
)

Parameters

input

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
byte[] all = new byte[256];
for (int i = 0; i < all.Length; i++)
    all[i] = (byte)i;

Assert.AreEqual(AllHex, HexEncoding.EncodeBytes(all));
Assert.AreEqual(0, BinaryComparer.Compare(all, HexEncoding.DecodeBytes(AllHex)));
Assert.AreEqual(0, BinaryComparer.Compare(all, HexEncoding.DecodeBytes(AllHex.ToUpper())));
VB.NET Copy Code
Dim all As Byte() = New Byte(256) {}
Dim i As Integer = 0
While i < all.Length
    all(i) = DirectCast(i, Byte)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(AllHex, HexEncoding.EncodeBytes(all))
Assert.AreEqual(0, BinaryComparer.Compare(all, HexEncoding.DecodeBytes(AllHex)))
Assert.AreEqual(0, BinaryComparer.Compare(all, HexEncoding.DecodeBytes(AllHex.ToUpper())))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members
Overload List

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes(Byte[],Int32,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > EncodeBytes Method : EncodeBytes(Byte[],Int32,Int32) Method

input
start
length

Glossary Item Box

Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function EncodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer _
) As String
C#
public static string EncodeBytes(
   byte[] input,
   int start,
   int length
)

Parameters

input
start
length

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
const string hex = "0102030405060708090a0b0c0d0e0f10";
byte[] bin = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };

Assert.AreEqual(hex.Substring(4, 10), HexEncoding.EncodeBytes(bin, 2, 5));
Assert.AreEqual(0, BinaryComparer.Compare(new byte[] { 3, 4, 5, 6 }, HexEncoding.DecodeBytes(hex, 4, 8)));
VB.NET Copy Code
Const  hex As String = "0102030405060708090a0b0c0d0e0f10"
Dim bin As Byte() = New Byte() {1, 2, 3, 4, 5, 6, _
    7, 8, 9, 10, 11, 12, _
    13, 14, 15, 16}

Assert.AreEqual(hex.Substring(4, 10), HexEncoding.EncodeBytes(bin, 2, 5))
Assert.AreEqual(0, BinaryComparer.Compare(New Byte() {3, 4, 5, 6}, HexEncoding.DecodeBytes(hex, 4, 8)))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members
Overload List

Used By

String HexEncoding.EncodeBytes(Byte[])

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes(Byte[],Int32,Int32,Byte[],Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexEncoding Class > EncodeBytes Method : EncodeBytes(Byte[],Int32,Int32,Byte[],Int32) Method

input
start
length
output
offset

Glossary Item Box

Transforms a sequence of characters from '0' - '9' and 'a' - 'f' in the binary values

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function EncodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer, _
   ByVal output() As Byte, _
   ByVal offset As Integer _
) As Integer
C#
public static int EncodeBytes(
   byte[] input,
   int start,
   int length,
   byte[] output,
   int offset
)

Parameters

input
start
length
output
offset

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexEncoding Class
HexEncoding Members
Overload List

Used By

String HexEncoding.EncodeBytes(Byte[],Int32,Int32)

Source Code

Library/Formatting/HexEncoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HexStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexStream Class

Glossary Item Box

Provides reading and writing to a stream of hexidecimal characters.

Syntax

Visual Basic (Declaration)
Public Class HexStream
   Inherits System.Security.Cryptography.CryptoStream
C#
public class HexStream : System.Security.Cryptography.CryptoStream

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
using (Stream mem = new MemoryStream())
{
    using (Stream io = new HexStream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(HexEncoding.DecodeBytes(AllHex), 0, AllHex.Length / 2);

    Assert.AreEqual(AllHex.Length, mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(AllHex, test);
}
VB.NET Copy Code
Using mem As Stream = New MemoryStream()
    Using io As Stream = New HexStream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(HexEncoding.DecodeBytes(AllHex), 0, AllHex.Length / 2)
    End Using

    Assert.AreEqual(AllHex.Length, mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(AllHex, test)
End Using

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
System.Security.Cryptography.CryptoStream
CSharpTest.Net.Formatting.HexStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexStream Members
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HexStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexStream Class

Glossary Item Box

The following tables list the members exposed by HexStream.

Public Constructors

 | Name | Description
Public Constructor | HexStream Constructor | Provides reading and writing to a stream of hexidecimal characters.
Top

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.CryptoStream. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | FlushFinalBlock | Updates the underlying data source or repository with the current state of the buffer, then clears the buffer. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

HexStream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HexStream Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexStream Class : HexStream Constructor

stream
mode

Glossary Item Box

Provides reading and writing to a stream of hexidecimal characters.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream, _
   ByVal mode As CryptoStreamMode _
)
C#
public HexStream(
   Stream stream,
   CryptoStreamMode mode
)

Parameters

stream
mode

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
using (Stream mem = new MemoryStream())
{
    using (Stream io = new HexStream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(HexEncoding.DecodeBytes(AllHex), 0, AllHex.Length / 2);

    Assert.AreEqual(AllHex.Length, mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(AllHex, test);
}
VB.NET Copy Code
Using mem As Stream = New MemoryStream()
    Using io As Stream = New HexStream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(HexEncoding.DecodeBytes(AllHex), 0, AllHex.Length / 2)
    End Using

    Assert.AreEqual(AllHex.Length, mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(AllHex, test)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexStream Class
HexStream Members

Source Code

Library/Formatting/HexStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HexStream.Transform Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexStream.Transform Class

Glossary Item Box

Provides a crypto-transform used to read/write to a stream of hexidecimal characters.

Syntax

Visual Basic (Declaration)
Public Class HexStream.Transform
C#
public class HexStream.Transform

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
using (ICryptoTransform xform = new HexStream.Transform(CryptoStreamMode.Read))
{
    Assert.AreEqual(2, xform.InputBlockSize);
    Assert.AreEqual(1, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
using (ICryptoTransform xform = new HexStream.Transform(CryptoStreamMode.Write))
{
    Assert.AreEqual(1, xform.InputBlockSize);
    Assert.AreEqual(2, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
VB.NET Copy Code
Using xform As ICryptoTransform = New HexStream.Transform(CryptoStreamMode.Read)
    Assert.AreEqual(2, xform.InputBlockSize)
    Assert.AreEqual(1, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using
Using xform As ICryptoTransform = New HexStream.Transform(CryptoStreamMode.Write)
    Assert.AreEqual(1, xform.InputBlockSize)
    Assert.AreEqual(2, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Formatting.HexStream.Transform

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexStream.Transform Members
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HexStream.Transform Class Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexStream.Transform Class

Glossary Item Box

The following tables list the members exposed by HexStream.Transform.

Public Constructors

 | Name | Description
Public Constructor | HexStream.Transform Constructor | Provides a crypto-transform used to read/write to a stream of hexidecimal characters.
Top

See Also

Reference

HexStream.Transform Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HexStream.Transform Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > HexStream.Transform Class : HexStream.Transform Constructor

mode

Glossary Item Box

Provides a crypto-transform used to read/write to a stream of hexidecimal characters.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal mode As CryptoStreamMode _
)
C#
public HexStream.Transform(
   CryptoStreamMode mode
)

Parameters

mode

Example

Library/Library.Test/TestHexEncoding.cs

C# Copy Code
using (ICryptoTransform xform = new HexStream.Transform(CryptoStreamMode.Read))
{
    Assert.AreEqual(2, xform.InputBlockSize);
    Assert.AreEqual(1, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
using (ICryptoTransform xform = new HexStream.Transform(CryptoStreamMode.Write))
{
    Assert.AreEqual(1, xform.InputBlockSize);
    Assert.AreEqual(2, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
VB.NET Copy Code
Using xform As ICryptoTransform = New HexStream.Transform(CryptoStreamMode.Read)
    Assert.AreEqual(2, xform.InputBlockSize)
    Assert.AreEqual(1, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using
Using xform As ICryptoTransform = New HexStream.Transform(CryptoStreamMode.Write)
    Assert.AreEqual(1, xform.InputBlockSize)
    Assert.AreEqual(2, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HexStream.Transform Class
HexStream.Transform Members

Source Code

Library/Formatting/HexStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Safe64Encoding Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Encoding Class

Glossary Item Box

This encoding produces a 'url' safe string from bytes, similar to base64 encoding yet it replaces '+' with '-', '/' with '_' and omits padding.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class Safe64Encoding
C#
public static class Safe64Encoding

Inheritance Hierarchy

System.Object
CSharpTest.Net.Formatting.Safe64Encoding

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Members
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Encoding.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Safe64Encoding Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Encoding Class

Glossary Item Box

The following tables list the members exposed by Safe64Encoding.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DecodeBytes | Overloaded. Decodes the ascii text from the bytes provided into the original byte array
static (Shared in Visual Basic) | EncodeBytes | Overloaded. Returns a encoded string of ascii characters that are URI safe
Top

See Also

Reference

Safe64Encoding Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Encoding.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Safe64Encoding Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Encoding Class

Glossary Item Box

For a list of all members of this type, see Safe64Encoding members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DecodeBytes | Overloaded. Decodes the ascii text from the bytes provided into the original byte array
static (Shared in Visual Basic) | EncodeBytes | Overloaded. Returns a encoded string of ascii characters that are URI safe
Top

See Also

Reference

Safe64Encoding Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Encoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class : DecodeBytes Method

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Overload List

Overload | Description
DecodeBytes(String) | Decodes the ascii text from the bytes provided into the original byte array
DecodeBytes(String,Int32,Int32) | Decodes the ascii text from the bytes provided into the original byte array
DecodeBytes(Byte[]) | Decodes the ascii text from the bytes provided into the original byte array
DecodeBytes(Byte[],Int32,Int32) | Decodes the ascii text from the bytes provided into the original byte array
DecodeBytes(Byte[],Int32,Int32,Byte[],Int32) | Decodes the ascii text from the bytes provided into the original byte array

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > DecodeBytes Method : DecodeBytes(String) Method

input

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input As String _
) As Byte()
C#
public static byte[] DecodeBytes(
   string input
)

Parameters

input

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
string encoded = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
byte[] data = Safe64Encoding.DecodeBytes(encoded);
byte[] test;
using (Stream io = new Safe64Stream(new MemoryStream(Encoding.ASCII.GetBytes(encoded)), CryptoStreamMode.Read))
    test = IOStream.Read(io, data.Length);

Assert.AreEqual(data, test);
VB.NET Copy Code
Dim encoded As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
Dim data As Byte() = Safe64Encoding.DecodeBytes(encoded)
Dim test As Byte()
Using io As Stream = New Safe64Stream(New MemoryStream(Encoding.ASCII.GetBytes(encoded)), CryptoStreamMode.Read)
    test = IOStream.Read(io, data.Length)
End Using

Assert.AreEqual(data, test)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members
Overload List

Source Code

Library/Formatting/Safe64Encoding.cs

Used By

Byte[] AsciiEncoder.DecodeBytes(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(String,Int32,Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > DecodeBytes Method : DecodeBytes(String,Int32,Int32) Method

input
start
length

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input As String, _
   ByVal start As Integer, _
   ByVal length As Integer _
) As Byte()
C#
public static byte[] DecodeBytes(
   string input,
   int start,
   int length
)

Parameters

input
start
length

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members
Overload List

Used By

Byte[] Safe64Encoding.DecodeBytes(String)

Source Code

Library/Formatting/Safe64Encoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > DecodeBytes Method : DecodeBytes(Byte[]) Method

input

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input() As Byte _
) As Byte()
C#
public static byte[] DecodeBytes(
   byte[] input
)

Parameters

input

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members
Overload List

Source Code

Library/Formatting/Safe64Encoding.cs

Used By

Byte[] AsciiEncoder.DecodeBytes(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(Byte[],Int32,Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > DecodeBytes Method : DecodeBytes(Byte[],Int32,Int32) Method

input
start
length

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer _
) As Byte()
C#
public static byte[] DecodeBytes(
   byte[] input,
   int start,
   int length
)

Parameters

input
start
length

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members
Overload List

Used By

Byte[] Safe64Encoding.DecodeBytes(String,Int32,Int32)
Byte[] Safe64Encoding.DecodeBytes(Byte[])

Source Code

Library/Formatting/Safe64Encoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DecodeBytes(Byte[],Int32,Int32,Byte[],Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > DecodeBytes Method : DecodeBytes(Byte[],Int32,Int32,Byte[],Int32) Method

input
start
length
output
offset

Glossary Item Box

Decodes the ascii text from the bytes provided into the original byte array

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function DecodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer, _
   ByVal output() As Byte, _
   ByVal offset As Integer _
) As Integer
C#
public static int DecodeBytes(
   byte[] input,
   int start,
   int length,
   byte[] output,
   int offset
)

Parameters

input
start
length
output
offset

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members
Overload List

Used By

Byte[] Safe64Encoding.DecodeBytes(Byte[],Int32,Int32)

Source Code

Library/Formatting/Safe64Encoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class : EncodeBytes Method

Glossary Item Box

Returns a encoded string of ascii characters that are URI safe

Overload List

Overload | Description
EncodeBytes(Byte[]) | Returns a encoded string of ascii characters that are URI safe
EncodeBytes(Byte[],Int32,Int32) | Returns a encoded string of ascii characters that are URI safe
EncodeBytes(Byte[],Int32,Int32,Byte[],Int32) | Returns a encoded string of ascii characters that are URI safe

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes(Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > EncodeBytes Method : EncodeBytes(Byte[]) Method

input

Glossary Item Box

Returns a encoded string of ascii characters that are URI safe

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function EncodeBytes( _
   ByVal input() As Byte _
) As String
C#
public static string EncodeBytes(
   byte[] input
)

Parameters

input

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
byte[] data = new byte[222];
new Random().NextBytes(data);
using (Stream mem = new MemoryStream())
{
    using (Stream io = new Safe64Stream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(data, 0, data.Length);

    Assert.AreEqual((long)Math.Ceiling((data.Length * 8) / 6d), mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(Safe64Encoding.EncodeBytes(data), test);
}
VB.NET Copy Code
Dim data As Byte() = New Byte(222) {}
New Random().NextBytes(data)
Using mem As Stream = New MemoryStream()
    Using io As Stream = New Safe64Stream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(data, 0, data.Length)
    End Using

    Assert.AreEqual(DirectCast(Math.Ceiling((data.Length * 8) / 6.0), Long), mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(Safe64Encoding.EncodeBytes(data), test)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members
Overload List

Source Code

Library/Formatting/Safe64Encoding.cs

Used By

String AsciiEncoder.EncodeBytes(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes(Byte[],Int32,Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > EncodeBytes Method : EncodeBytes(Byte[],Int32,Int32) Method

input
start
length

Glossary Item Box

Returns a encoded string of ascii characters that are URI safe

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function EncodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer _
) As String
C#
public static string EncodeBytes(
   byte[] input,
   int start,
   int length
)

Parameters

input
start
length

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members
Overload List

Used By

String Safe64Encoding.EncodeBytes(Byte[])

Source Code

Library/Formatting/Safe64Encoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EncodeBytes(Byte[],Int32,Int32,Byte[],Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Encoding Class > EncodeBytes Method : EncodeBytes(Byte[],Int32,Int32,Byte[],Int32) Method

input
start
length
output
offset

Glossary Item Box

Returns a encoded string of ascii characters that are URI safe

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function EncodeBytes( _
   ByVal input() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer, _
   ByVal output() As Byte, _
   ByVal offset As Integer _
) As Integer
C#
public static int EncodeBytes(
   byte[] input,
   int start,
   int length,
   byte[] output,
   int offset
)

Parameters

input
start
length
output
offset

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Encoding Class
Safe64Encoding Members
Overload List

Used By

String Safe64Encoding.EncodeBytes(Byte[],Int32,Int32)

Source Code

Library/Formatting/Safe64Encoding.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Safe64Stream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Stream Class

Glossary Item Box

Provides reading and writing to a stream of base-64 characters while replacing '+' with '-' and '/' with '_' and ommitting padding.

Syntax

Visual Basic (Declaration)
Public Class Safe64Stream
   Inherits System.Security.Cryptography.CryptoStream
C#
public class Safe64Stream : System.Security.Cryptography.CryptoStream

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
byte[] data = new byte[222];
new Random().NextBytes(data);
using (Stream mem = new MemoryStream())
{
    using (Stream io = new Safe64Stream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(data, 0, data.Length);

    Assert.AreEqual((long)Math.Ceiling((data.Length * 8) / 6d), mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(Safe64Encoding.EncodeBytes(data), test);
}
VB.NET Copy Code
Dim data As Byte() = New Byte(222) {}
New Random().NextBytes(data)
Using mem As Stream = New MemoryStream()
    Using io As Stream = New Safe64Stream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(data, 0, data.Length)
    End Using

    Assert.AreEqual(DirectCast(Math.Ceiling((data.Length * 8) / 6.0), Long), mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(Safe64Encoding.EncodeBytes(data), test)
End Using

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
System.Security.Cryptography.CryptoStream
CSharpTest.Net.Formatting.Safe64Stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Stream Members
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Stream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Safe64Stream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Stream Class

Glossary Item Box

The following tables list the members exposed by Safe64Stream.

Public Constructors

 | Name | Description
Public Constructor | Safe64Stream Constructor | Provides reading and writing to a stream of base-64 characters while replacing '+' with '-' and '/' with '_' and ommitting padding.
Top

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.CryptoStream. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | FlushFinalBlock | Updates the underlying data source or repository with the current state of the buffer, then clears the buffer. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

Safe64Stream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Stream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Safe64Stream Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Stream Class : Safe64Stream Constructor

stream
mode

Glossary Item Box

Provides reading and writing to a stream of base-64 characters while replacing '+' with '-' and '/' with '_' and ommitting padding.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream, _
   ByVal mode As CryptoStreamMode _
)
C#
public Safe64Stream(
   Stream stream,
   CryptoStreamMode mode
)

Parameters

stream
mode

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
byte[] data = new byte[222];
new Random().NextBytes(data);
using (Stream mem = new MemoryStream())
{
    using (Stream io = new Safe64Stream(new NonClosingStream(mem), CryptoStreamMode.Write))
        io.Write(data, 0, data.Length);

    Assert.AreEqual((long)Math.Ceiling((data.Length * 8) / 6d), mem.Position);
    mem.Position = 0;
    string test = new StreamReader(mem).ReadToEnd();
    Assert.AreEqual(Safe64Encoding.EncodeBytes(data), test);
}
VB.NET Copy Code
Dim data As Byte() = New Byte(222) {}
New Random().NextBytes(data)
Using mem As Stream = New MemoryStream()
    Using io As Stream = New Safe64Stream(New NonClosingStream(mem), CryptoStreamMode.Write)
        io.Write(data, 0, data.Length)
    End Using

    Assert.AreEqual(DirectCast(Math.Ceiling((data.Length * 8) / 6.0), Long), mem.Position)
    mem.Position = 0
    Dim test As String = New StreamReader(mem).ReadToEnd()
    Assert.AreEqual(Safe64Encoding.EncodeBytes(data), test)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Stream Class
Safe64Stream Members

Source Code

Library/Formatting/Safe64Stream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Safe64Stream.Transform Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Stream.Transform Class

Glossary Item Box

Provides a crypto-transform used to read/write to a stream of base-64 characters while replacing '+' with '-' and '/' with '_' and ommitting padding.

Syntax

Visual Basic (Declaration)
Public Class Safe64Stream.Transform
C#
public class Safe64Stream.Transform

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
using (ICryptoTransform xform = new Safe64Stream.Transform(CryptoStreamMode.Read))
{
    Assert.AreEqual(4, xform.InputBlockSize);
    Assert.AreEqual(3, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
using (ICryptoTransform xform = new Safe64Stream.Transform(CryptoStreamMode.Write))
{
    Assert.AreEqual(3, xform.InputBlockSize);
    Assert.AreEqual(4, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
VB.NET Copy Code
Using xform As ICryptoTransform = New Safe64Stream.Transform(CryptoStreamMode.Read)
    Assert.AreEqual(4, xform.InputBlockSize)
    Assert.AreEqual(3, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using
Using xform As ICryptoTransform = New Safe64Stream.Transform(CryptoStreamMode.Write)
    Assert.AreEqual(3, xform.InputBlockSize)
    Assert.AreEqual(4, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Formatting.Safe64Stream.Transform

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Stream.Transform Members
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Stream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Safe64Stream.Transform Class Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Stream.Transform Class

Glossary Item Box

The following tables list the members exposed by Safe64Stream.Transform.

Public Constructors

 | Name | Description
Public Constructor | Safe64Stream.Transform Constructor | Provides a crypto-transform used to read/write to a stream of base-64 characters while replacing '+' with '-' and '/' with '_' and ommitting padding.
Top

See Also

Reference

Safe64Stream.Transform Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Stream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Safe64Stream.Transform Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace > Safe64Stream.Transform Class : Safe64Stream.Transform Constructor

mode

Glossary Item Box

Provides a crypto-transform used to read/write to a stream of base-64 characters while replacing '+' with '-' and '/' with '_' and ommitting padding.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal mode As CryptoStreamMode _
)
C#
public Safe64Stream.Transform(
   CryptoStreamMode mode
)

Parameters

mode

Example

Library/Library.Test/TestSafe64Encoding.cs

C# Copy Code
using (ICryptoTransform xform = new Safe64Stream.Transform(CryptoStreamMode.Read))
{
    Assert.AreEqual(4, xform.InputBlockSize);
    Assert.AreEqual(3, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
using (ICryptoTransform xform = new Safe64Stream.Transform(CryptoStreamMode.Write))
{
    Assert.AreEqual(3, xform.InputBlockSize);
    Assert.AreEqual(4, xform.OutputBlockSize);
    Assert.AreEqual(true, xform.CanReuseTransform);
    Assert.AreEqual(true, xform.CanTransformMultipleBlocks);
}
VB.NET Copy Code
Using xform As ICryptoTransform = New Safe64Stream.Transform(CryptoStreamMode.Read)
    Assert.AreEqual(4, xform.InputBlockSize)
    Assert.AreEqual(3, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using
Using xform As ICryptoTransform = New Safe64Stream.Transform(CryptoStreamMode.Write)
    Assert.AreEqual(3, xform.InputBlockSize)
    Assert.AreEqual(4, xform.OutputBlockSize)
    Assert.AreEqual(True, xform.CanReuseTransform)
    Assert.AreEqual(True, xform.CanTransformMultipleBlocks)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Safe64Stream.Transform Class
Safe64Stream.Transform Members

Source Code

Library/Formatting/Safe64Stream.cs


%%ItemTitle%%

CSharpTest.Net.Html Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Html Namespace

Glossary Item Box

Classes

 | Class | Description
Class | HtmlLightDocument | Represents a loosly parsed html document
Class | XhtmlValidation | Provides validation of Xhtml documents based on w3c DTDs
Class | XmlLightAttributes | A collection of attributes for an element
Class | XmlLightDocument | Inteded to quickly read 'mostly' well-formed html text
Class | XmlLightElement | Represents an html element
Class | XmlLightParser | Provides a means by which you can cursur through xml/html documents and be notified for each tag/text/etc via implementing the IXmlLightReader interface.

Interfaces

 | Interface | Description
Interface | IXmlLightReader | Provides a means by which the XmlLightParser can inform you of the document elements encountered.

Structures

 | Structure | Description
Structure | XmlLightAttribute | Represents a single attribute on an xml element
Structure | XmlTagInfo | Wraps up the information about a tag start while parsing

Enumerations

 | Enumeration | Description
Enumeration | XhtmlDTDSpecification | Defines the required DTD specification
Enumeration | XmlLightParser.AttributeFormat | Determines how strict attributes are treated durring parsing
Enumeration | XmlQuoteStyle | The quote used with an attribute value

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
HtmlLightDocument Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : HtmlLightDocument Class

Glossary Item Box

Represents a loosly parsed html document

Object Model

HtmlLightDocument ClassXmlLightElement ClassXmlLightElement ClassXmlLightElement ClassXmlLightElement Class

Syntax

Visual Basic (Declaration)
Public Class HtmlLightDocument
   Inherits XmlLightDocument
   Implements IXmlLightReader
C#
public class HtmlLightDocument : XmlLightDocument, IXmlLightReader

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string[] files = Directory.GetFiles(@"c:\temp\trash", "*.htm", SearchOption.AllDirectories);
System.Diagnostics.Stopwatch sw;

for (int i = 0; i < 10; i++)
{
    //HTML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new HtmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds);
    //XML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new XmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds);
    //Parse Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    IXmlLightReader rdr = new EmptyReader();
    foreach (string file in files)
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr);

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds);
    //Text Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        XmlLightParser.ParseText(File.ReadAllText(file));

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds);
}
VB.NET Copy Code
Dim files As String() = Directory.GetFiles("c:\temp\trash", "*.htm", SearchOption.AllDirectories)
Dim sw As System.Diagnostics.Stopwatch

Dim i As Integer = 0
While i < 10
    'HTML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New HtmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds)
    'XML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New XmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds)
    'Parse Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    Dim rdr As IXmlLightReader = New EmptyReader()
    For Each file As String In files
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr)
    Next

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds)
    'Text Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        XmlLightParser.ParseText(File.ReadAllText(file))
    Next

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Inheritance Hierarchy

System.Object
CSharpTest.Net.Html.XmlLightElement
CSharpTest.Net.Html.XmlLightDocument
CSharpTest.Net.Html.HtmlLightDocument

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HtmlLightDocument Members
CSharpTest.Net.Html Namespace

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HtmlLightDocument Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : HtmlLightDocument Class

Glossary Item Box

The following tables list the members exposed by HtmlLightDocument.

Public Constructors

 | Name | Description
Public Constructor | HtmlLightDocument Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | Attributes | Returns the attributes of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Field | Children | Returns the children of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Field | Root | Returns the root element (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Top

Protected Fields

 | Name | Description
Protected Field | _parserStack | Stores the current node stack while parsing documents (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Top

Public Properties

 | Name | Description
Public Property | ClosingTagWhitespace | Whitespace appearing before the close of the end tag (</div >) (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Document | Returns the root-level node (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | InnerText | Returns the inner text of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | InnerXml | Returns the re-constructed innerHTML in a well-formed Xml format (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsComment | Returns true if the node is a comment (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsEmpty | Returns true if the node is self-closing (i.e. ends with '/>') (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsSpecialTag | Returns true if the node is not a normal element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsText | Returns true if the node has a textual value, i.e. text or cdata (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | LocalName | Returns the name without the namespace prefix (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Namespace | Returns the namespace or empty string (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | NamespaceOrNull | Returns the namespace or null (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | NextSibling | Returns the next sibling element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | OpeningTagWhitespace | Whitespace appearing before the close of the start tag (<div >) (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | OriginalTag | Returns the text in it's original format. Where IsSpecial == true, this is used to rewrite the content. (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Parent | Returns the parent (if any) of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | PrevSibling | Returns the previous sibling element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | TagName | Returns the tag name of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Value | Returns the value (if any) of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

Public Methods

 | Name | Description
Public Method | AddCData | Encountered cdata section in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | AddComment | Encountered comment in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | AddControl | Encountered control information <! ... > in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | AddInstruction | Encountered processing instruction <? ... ?> in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | AddText | Encountered text or whitespace in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | CreateNavigator | Returns a new System.Xml.XPath.XPathNavigator object. (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | EndDocument | Overridden. Ends the processing of an xml input
Public Method | EndTag | Overridden.
Public Method | FindElement | Finds the elements matching the provided criteria (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | GetElementById | Deep-scans heirarchy for the element with the provided id (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | Remove | Removes this node from it's parent element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | Select | Returns the elements from the given xpath expression (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | SelectSingleNode | Returns the first element from the given xpath expression (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | StartDocument | Begins the processing of an xml input (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | StartTag | Overridden.
Public Method | WriteUnformatted | Writes the modified document in it's original formatting (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | WriteXml | Overloaded. Writes XML to an xml writer to ensure proper formatting (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

Protected Methods

 | Name | Description
Protected Method | WriteText | (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

See Also

Reference

HtmlLightDocument Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HtmlLightDocument Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > HtmlLightDocument Class : HtmlLightDocument Constructor

Glossary Item Box

Overload List

Overload | Description
HtmlLightDocument Constructor() | Represents a loosly parsed html document
HtmlLightDocument Constructor(String) | Represents a loosly parsed html document

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HtmlLightDocument Class
HtmlLightDocument Members


%%PageItemTitle%%

[image]
CSharpTest.Net
HtmlLightDocument Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > HtmlLightDocument Class > HtmlLightDocument Constructor : HtmlLightDocument Constructor()

Glossary Item Box

Represents a loosly parsed html document

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public HtmlLightDocument()

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string notxml = "<html id=a ><body foo='bar' bar=\"foo\" />";

HtmlLightDocument html = new HtmlLightDocument();
XmlLightParser.Parse(notxml, html);
Assert.AreEqual("html", html.Root.TagName);
Assert.AreEqual(1, html.Root.Attributes.Count);
Assert.AreEqual("a", html.Root.Attributes["id"]);
Assert.AreEqual(1, html.Root.Children.Count);
Assert.AreEqual("body", html.Root.Children[0].TagName);
Assert.AreEqual("foo", html.Root.Children[0].Attributes["bar"]);
Assert.AreEqual("bar", html.Root.Children[0].Attributes["foo"]);

XmlLightDocument xml = new XmlLightDocument();
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml);
Assert.AreEqual(2, xml.Root.Attributes.Count);
//Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName);
Assert.AreEqual("foo", xml.Root.Attributes["bar"]);
Assert.AreEqual("bar", xml.Root.Attributes["foo"]);
VB.NET Copy Code
Dim notxml As String = "<html id=a ><body foo='bar' bar=""foo"" />"

Dim html As New HtmlLightDocument()
XmlLightParser.Parse(notxml, html)
Assert.AreEqual("html", html.Root.TagName)
Assert.AreEqual(1, html.Root.Attributes.Count)
Assert.AreEqual("a", html.Root.Attributes("id"))
Assert.AreEqual(1, html.Root.Children.Count)
Assert.AreEqual("body", html.Root.Children(0).TagName)
Assert.AreEqual("foo", html.Root.Children(0).Attributes("bar"))
Assert.AreEqual("bar", html.Root.Children(0).Attributes("foo"))

Dim xml As New XmlLightDocument()
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml)
Assert.AreEqual(2, xml.Root.Attributes.Count)
'Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName)
Assert.AreEqual("foo", xml.Root.Attributes("bar"))
Assert.AreEqual("bar", xml.Root.Attributes("foo"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HtmlLightDocument Class
HtmlLightDocument Members
Overload List

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HtmlLightDocument Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > HtmlLightDocument Class > HtmlLightDocument Constructor : HtmlLightDocument Constructor(String)

content

Glossary Item Box

Represents a loosly parsed html document

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal content As String _
)
C#
public HtmlLightDocument(
   string content
)

Parameters

content

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string[] files = Directory.GetFiles(@"c:\temp\trash", "*.htm", SearchOption.AllDirectories);
System.Diagnostics.Stopwatch sw;

for (int i = 0; i < 10; i++)
{
    //HTML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new HtmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds);
    //XML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new XmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds);
    //Parse Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    IXmlLightReader rdr = new EmptyReader();
    foreach (string file in files)
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr);

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds);
    //Text Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        XmlLightParser.ParseText(File.ReadAllText(file));

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds);
}
VB.NET Copy Code
Dim files As String() = Directory.GetFiles("c:\temp\trash", "*.htm", SearchOption.AllDirectories)
Dim sw As System.Diagnostics.Stopwatch

Dim i As Integer = 0
While i < 10
    'HTML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New HtmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds)
    'XML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New XmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds)
    'Parse Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    Dim rdr As IXmlLightReader = New EmptyReader()
    For Each file As String In files
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr)
    Next

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds)
    'Text Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        XmlLightParser.ParseText(File.ReadAllText(file))
    Next

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HtmlLightDocument Class
HtmlLightDocument Members
Overload List

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HtmlLightDocument Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : HtmlLightDocument Class

Glossary Item Box

For a list of all members of this type, see HtmlLightDocument members.

Public Methods

 | Name | Description
Public Method | AddCData | Encountered cdata section in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | AddComment | Encountered comment in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | AddControl | Encountered control information <! ... > in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | AddInstruction | Encountered processing instruction <? ... ?> in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | AddText | Encountered text or whitespace in the document (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | CreateNavigator | Returns a new System.Xml.XPath.XPathNavigator object. (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | EndDocument | Overridden. Ends the processing of an xml input
Public Method | EndTag | Overridden.
Public Method | FindElement | Finds the elements matching the provided criteria (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | GetElementById | Deep-scans heirarchy for the element with the provided id (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | Remove | Removes this node from it's parent element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | Select | Returns the elements from the given xpath expression (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | SelectSingleNode | Returns the first element from the given xpath expression (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | StartDocument | Begins the processing of an xml input (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Public Method | StartTag | Overridden.
Public Method | WriteUnformatted | Writes the modified document in it's original formatting (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | WriteXml | Overloaded. Writes XML to an xml writer to ensure proper formatting (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

Protected Methods

 | Name | Description
Protected Method | WriteText | (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

See Also

Reference

HtmlLightDocument Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EndDocument Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > HtmlLightDocument Class : EndDocument Method

Glossary Item Box

Ends the processing of an xml input

Syntax

Visual Basic (Declaration)
Public Overrides Sub EndDocument()
C#
public override void EndDocument()

Exceptions

Exception | Description
System.ApplicationException | The exception that is thrown when a non-fatal application error occurs.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HtmlLightDocument Class
HtmlLightDocument Members
Base Implementation in EndDocument

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EndTag Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > HtmlLightDocument Class : EndTag Method

tag

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Overrides Sub EndTag( _
   ByVal tag As XmlTagInfo _
)
C#
public override void EndTag(
   XmlTagInfo tag
)

Parameters

tag

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HtmlLightDocument Class
HtmlLightDocument Members
Base Implementation in EndTag
XmlTagInfo

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StartTag Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > HtmlLightDocument Class : StartTag Method

tag

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Overrides Sub StartTag( _
   ByVal tag As XmlTagInfo _
)
C#
public override void StartTag(
   XmlTagInfo tag
)

Parameters

tag

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HtmlLightDocument Class
HtmlLightDocument Members
Base Implementation in StartTag
XmlTagInfo

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XhtmlValidation Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XhtmlValidation Class

Glossary Item Box

Provides validation of Xhtml documents based on w3c DTDs

Syntax

Visual Basic (Declaration)
Public Class XhtmlValidation
C#
public class XhtmlValidation

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<html>
    <head><title>required</title></head>
    <body></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.None);
v.Validate(new StringReader(doc));
VB.NET Copy Code
Dim doc As String = "<html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.None)
v.Validate(New StringReader(doc))

Inheritance Hierarchy

System.Object
CSharpTest.Net.Html.XhtmlValidation

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XhtmlValidation Members
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XhtmlValidation.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
XhtmlValidation Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XhtmlValidation Class

Glossary Item Box

The following tables list the members exposed by XhtmlValidation.

Public Constructors

 | Name | Description
Public Constructor | XhtmlValidation Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Validate | Overloaded. Validate the input textreader
Top

See Also

Reference

XhtmlValidation Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XhtmlValidation.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XhtmlValidation Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XhtmlValidation Class : XhtmlValidation Constructor

Glossary Item Box

Overload List

Overload | Description
XhtmlValidation Constructor() | Creates a validator that requires documents to use any of the three DTD specifications
XhtmlValidation Constructor(XhtmlDTDSpecification) | Creates a validator that requires documents to use the specified DTD

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XhtmlValidation Class
XhtmlValidation Members


%%PageItemTitle%%

[image]
CSharpTest.Net
XhtmlValidation Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XhtmlValidation Class > XhtmlValidation Constructor : XhtmlValidation Constructor()

Glossary Item Box

Creates a validator that requires documents to use any of the three DTD specifications

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public XhtmlValidation()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XhtmlValidation Class
XhtmlValidation Members
Overload List

Source Code

Library/Html/XhtmlValidation.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XhtmlValidation Constructor(XhtmlDTDSpecification)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XhtmlValidation Class > XhtmlValidation Constructor : XhtmlValidation Constructor(XhtmlDTDSpecification)

dtdRequired

Glossary Item Box

Creates a validator that requires documents to use the specified DTD

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal dtdRequired As XhtmlDTDSpecification _
)
C#
public XhtmlValidation(
   XhtmlDTDSpecification dtdRequired
)

Parameters

dtdRequired

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<html>
    <head><title>required</title></head>
    <body></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.None);
v.Validate(new StringReader(doc));
VB.NET Copy Code
Dim doc As String = "<html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.None)
v.Validate(New StringReader(doc))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XhtmlValidation Class
XhtmlValidation Members
Overload List

Source Code

Library/Html/XhtmlValidation.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
XhtmlValidation Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XhtmlValidation Class

Glossary Item Box

For a list of all members of this type, see XhtmlValidation members.

Public Methods

 | Name | Description
Public Method | Validate | Overloaded. Validate the input textreader
Top

See Also

Reference

XhtmlValidation Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XhtmlValidation.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Validate Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XhtmlValidation Class : Validate Method

Glossary Item Box

Validate the input textreader

Overload List

Overload | Description
Validate(String,TextReader) | Validate the input textreader
Validate(TextReader) | Validate the input textreader
Validate(String) | Validate the input filename

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XhtmlValidation Class
XhtmlValidation Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Validate(String,TextReader) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XhtmlValidation Class > Validate Method : Validate(String,TextReader) Method

originalFilename
reader

Glossary Item Box

Validate the input textreader

Syntax

Visual Basic (Declaration)
Public Overloads Sub Validate( _
   ByVal originalFilename As String, _
   ByVal reader As TextReader _
)
C#
public void Validate(
   string originalFilename,
   TextReader reader
)

Parameters

originalFilename
reader

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html>
    <head><title>required</title></head>
    <body><iframe></iframe></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10);

using (TempFile temp = new TempFile())
{
    temp.WriteAllText(doc);
    v.Validate(@"C:\transitional.xhtml", new StreamReader(temp.Read()));
}
VB.NET Copy Code
Dim doc As String = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" & vbCr & vbLf & "            <html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body><iframe></iframe></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10)

Using temp As New TempFile()
    temp.WriteAllText(doc)
    v.Validate("C:\transitional.xhtml", New StreamReader(temp.Read()))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XhtmlValidation Class
XhtmlValidation Members
Overload List

Source Code

Library/Html/XhtmlValidation.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Validate(TextReader) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XhtmlValidation Class > Validate Method : Validate(TextReader) Method

reader

Glossary Item Box

Validate the input textreader

Syntax

Visual Basic (Declaration)
Public Overloads Sub Validate( _
   ByVal reader As TextReader _
)
C#
public void Validate(
   TextReader reader
)

Parameters

reader

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<html>
    <head><title>required</title></head>
    <body></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.None);
v.Validate(new StringReader(doc));
VB.NET Copy Code
Dim doc As String = "<html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.None)
v.Validate(New StringReader(doc))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XhtmlValidation Class
XhtmlValidation Members
Overload List

Source Code

Library/Html/XhtmlValidation.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Validate(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XhtmlValidation Class > Validate Method : Validate(String) Method

filename

Glossary Item Box

Validate the input filename

Syntax

Visual Basic (Declaration)
Public Overloads Sub Validate( _
   ByVal filename As String _
)
C#
public void Validate(
   string filename
)

Parameters

filename

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">
<html>
    <head><title>required</title></head>
    <body></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlStrict_10);

using (TempFile temp = new TempFile())
{
    temp.WriteAllText(doc);
    v.Validate(temp.TempPath);
}
VB.NET Copy Code
Dim doc As String = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">" & vbCr & vbLf & "            <html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.XhtmlStrict_10)

Using temp As New TempFile()
    temp.WriteAllText(doc)
    v.Validate(temp.TempPath)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XhtmlValidation Class
XhtmlValidation Members
Overload List

Source Code

Library/Html/XhtmlValidation.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightAttributes Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightAttributes Class

Glossary Item Box

A collection of attributes for an element

Object Model

XmlLightAttributes ClassString Class

Syntax

Visual Basic (Declaration)
Public Class XmlLightAttributes
C#
public class XmlLightAttributes

Inheritance Hierarchy

System.Object
CSharpTest.Net.Html.XmlLightAttributes

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Members
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
XmlLightAttributes Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightAttributes Class

Glossary Item Box

The following tables list the members exposed by XmlLightAttributes.

Public Properties

 | Name | Description
Public Property | Count | Returns the number of items in the collection.
Public Property | Item | Gets or Sets the attribute's unencoded text value
Public Property | Keys | Returns the names of the attributes in appearance order
Top

Public Methods

 | Name | Description
Public Method | Add | Adds a new attribute to the collection
Public Method | ContainsKey | Returns true if hte attribute is defined
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | Remove | Removes an item from the collection
Public Method | ToArray | Returns the attributes as a collection
Public Method | TryGetValue | Gets the value associated with the specified key.
Top

See Also

Reference

XmlLightAttributes Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
XmlLightAttributes Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightAttributes Class

Glossary Item Box

For a list of all members of this type, see XmlLightAttributes members.

Public Methods

 | Name | Description
Public Method | Add | Adds a new attribute to the collection
Public Method | ContainsKey | Returns true if hte attribute is defined
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | Remove | Removes an item from the collection
Public Method | ToArray | Returns the attributes as a collection
Public Method | TryGetValue | Gets the value associated with the specified key.
Top

See Also

Reference

XmlLightAttributes Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : Add Method

name
value

Glossary Item Box

Adds a new attribute to the collection

Syntax

Visual Basic (Declaration)
Public Sub Add( _
   ByVal name As String, _
   ByVal value As String _
)
C#
public void Add(
   string name,
   string value
)

Parameters

name
value

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
HtmlLightDocument doc = new HtmlLightDocument();
XmlLightElement body = new XmlLightElement(new XmlLightElement(doc, "html"), "body");
body.IsEmpty = false;
body.Attributes.Add("id", "bdy");
Assert.AreEqual("<html> <body id=\"bdy\"> </body> </html>", Normalize(doc.InnerXml));
VB.NET Copy Code
Dim doc As New HtmlLightDocument()
Dim body As New XmlLightElement(New XmlLightElement(doc, "html"), "body")
body.IsEmpty = False
body.Attributes.Add("id", "bdy")
Assert.AreEqual("<html> <body id=""bdy""> </body> </html>", Normalize(doc.InnerXml))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContainsKey Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : ContainsKey Method

name

Glossary Item Box

Returns true if hte attribute is defined

Syntax

Visual Basic (Declaration)
Public Function ContainsKey( _
   ByVal name As String _
) As Boolean
C#
public bool ContainsKey(
   string name
)

Parameters

name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members

Used By

XmlLightElement.WriteXml(XmlWriter)

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of KeyValuePair(Of String,String))
C#
public IEnumerator<KeyValuePair<string,string>> GetEnumerator()

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string xml = "<root id='a'></root>";
XmlLightDocument doc = new XmlLightDocument(xml);
Assert.AreEqual("root", doc.Root.LocalName);
Assert.AreEqual(1, doc.Root.Attributes.Count);
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext());
Assert.IsTrue(((System.Collections.IEnumerable)doc.Root.Attributes).GetEnumerator().MoveNext());
Assert.IsTrue(doc.Root.Attributes.Remove("id"));
Assert.AreEqual(0, doc.Root.Attributes.Count);
VB.NET Copy Code
Dim xml As String = "<root id='a'></root>"
Dim doc As New XmlLightDocument(xml)
Assert.AreEqual("root", doc.Root.LocalName)
Assert.AreEqual(1, doc.Root.Attributes.Count)
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext())
Assert.IsTrue((DirectCast(doc.Root.Attributes, System.Collections.IEnumerable)).GetEnumerator().MoveNext())
Assert.IsTrue(doc.Root.Attributes.Remove("id"))
Assert.AreEqual(0, doc.Root.Attributes.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : Remove Method

name

Glossary Item Box

Removes an item from the collection

Syntax

Visual Basic (Declaration)
Public Function Remove( _
   ByVal name As String _
) As Boolean
C#
public bool Remove(
   string name
)

Parameters

name

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string xml = "<root id='a'></root>";
XmlLightDocument doc = new XmlLightDocument(xml);
Assert.AreEqual("root", doc.Root.LocalName);
Assert.AreEqual(1, doc.Root.Attributes.Count);
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext());
Assert.IsTrue(((System.Collections.IEnumerable)doc.Root.Attributes).GetEnumerator().MoveNext());
Assert.IsTrue(doc.Root.Attributes.Remove("id"));
Assert.AreEqual(0, doc.Root.Attributes.Count);
VB.NET Copy Code
Dim xml As String = "<root id='a'></root>"
Dim doc As New XmlLightDocument(xml)
Assert.AreEqual("root", doc.Root.LocalName)
Assert.AreEqual(1, doc.Root.Attributes.Count)
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext())
Assert.IsTrue((DirectCast(doc.Root.Attributes, System.Collections.IEnumerable)).GetEnumerator().MoveNext())
Assert.IsTrue(doc.Root.Attributes.Remove("id"))
Assert.AreEqual(0, doc.Root.Attributes.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : ToArray Method

Glossary Item Box

Returns the attributes as a collection

Syntax

Visual Basic (Declaration)
Public Function ToArray() As XmlLightAttribute()
C#
public XmlLightAttribute[] ToArray()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members
XmlLightAttribute

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : TryGetValue Method

name
The name of the attribute to find
value
Set to the value of the attribute

Glossary Item Box

Gets the value associated with the specified key.

Syntax

Visual Basic (Declaration)
Public Function TryGetValue( _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out string value
)

Parameters

name
The name of the attribute to find
value
Set to the value of the attribute

Return Value

Returns true if the attribute was defined

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
XmlLightAttributes Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightAttributes Class

Glossary Item Box

For a list of all members of this type, see XmlLightAttributes members.

Public Properties

 | Name | Description
Public Property | Count | Returns the number of items in the collection.
Public Property | Item | Gets or Sets the attribute's unencoded text value
Public Property | Keys | Returns the names of the attributes in appearance order
Top

See Also

Reference

XmlLightAttributes Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : Count Property

Glossary Item Box

Returns the number of items in the collection.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string xml = "<root id='a'></root>";
XmlLightDocument doc = new XmlLightDocument(xml);
Assert.AreEqual("root", doc.Root.LocalName);
Assert.AreEqual(1, doc.Root.Attributes.Count);
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext());
Assert.IsTrue(((System.Collections.IEnumerable)doc.Root.Attributes).GetEnumerator().MoveNext());
Assert.IsTrue(doc.Root.Attributes.Remove("id"));
Assert.AreEqual(0, doc.Root.Attributes.Count);
VB.NET Copy Code
Dim xml As String = "<root id='a'></root>"
Dim doc As New XmlLightDocument(xml)
Assert.AreEqual("root", doc.Root.LocalName)
Assert.AreEqual(1, doc.Root.Attributes.Count)
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext())
Assert.IsTrue((DirectCast(doc.Root.Attributes, System.Collections.IEnumerable)).GetEnumerator().MoveNext())
Assert.IsTrue(doc.Root.Attributes.Remove("id"))
Assert.AreEqual(0, doc.Root.Attributes.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : Item Property

name

Glossary Item Box

Gets or Sets the attribute's unencoded text value

Syntax

Visual Basic (Declaration)
Public Default Property Item( _
   ByVal name As String _
) As String
C#
public string this[
   string name
]; {get; set;}

Parameters

name

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightAttributes.Add(String,String)

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttributes Class : Keys Property

Glossary Item Box

Returns the names of the attributes in appearance order

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As IEnumerable(Of String)
C#
public IEnumerable<string> Keys {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttributes Class
XmlLightAttributes Members

Source Code

Library/Html/XmlLightAttributes.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightDocument Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightDocument Class

Glossary Item Box

Inteded to quickly read 'mostly' well-formed html text

Object Model

XmlLightDocument ClassXmlLightElement ClassXmlLightElement ClassXmlLightElement ClassXmlLightElement Class

Syntax

Visual Basic (Declaration)
Public Class XmlLightDocument
   Inherits XmlLightElement
   Implements IXmlLightReader
C#
public class XmlLightDocument : XmlLightElement, IXmlLightReader

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string[] files = Directory.GetFiles(@"c:\temp\trash", "*.htm", SearchOption.AllDirectories);
System.Diagnostics.Stopwatch sw;

for (int i = 0; i < 10; i++)
{
    //HTML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new HtmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds);
    //XML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new XmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds);
    //Parse Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    IXmlLightReader rdr = new EmptyReader();
    foreach (string file in files)
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr);

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds);
    //Text Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        XmlLightParser.ParseText(File.ReadAllText(file));

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds);
}
VB.NET Copy Code
Dim files As String() = Directory.GetFiles("c:\temp\trash", "*.htm", SearchOption.AllDirectories)
Dim sw As System.Diagnostics.Stopwatch

Dim i As Integer = 0
While i < 10
    'HTML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New HtmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds)
    'XML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New XmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds)
    'Parse Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    Dim rdr As IXmlLightReader = New EmptyReader()
    For Each file As String In files
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr)
    Next

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds)
    'Text Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        XmlLightParser.ParseText(File.ReadAllText(file))
    Next

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Inheritance Hierarchy

System.Object
CSharpTest.Net.Html.XmlLightElement
CSharpTest.Net.Html.XmlLightDocument
CSharpTest.Net.Html.HtmlLightDocument

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Members
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
XmlLightDocument Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightDocument Class

Glossary Item Box

The following tables list the members exposed by XmlLightDocument.

Public Constructors

 | Name | Description
Public Constructor | XmlLightDocument Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | Attributes | Returns the attributes of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Field | Children | Returns the children of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Field | Root | Returns the root element
Top

Protected Fields

 | Name | Description
Protected Field | _parserStack | Stores the current node stack while parsing documents
Top

Public Properties

 | Name | Description
Public Property | ClosingTagWhitespace | Whitespace appearing before the close of the end tag (</div >) (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Document | Returns the root-level node (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | InnerText | Returns the inner text of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | InnerXml | Returns the re-constructed innerHTML in a well-formed Xml format (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsComment | Returns true if the node is a comment (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsEmpty | Returns true if the node is self-closing (i.e. ends with '/>') (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsSpecialTag | Returns true if the node is not a normal element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsText | Returns true if the node has a textual value, i.e. text or cdata (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | LocalName | Returns the name without the namespace prefix (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Namespace | Returns the namespace or empty string (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | NamespaceOrNull | Returns the namespace or null (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | NextSibling | Returns the next sibling element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | OpeningTagWhitespace | Whitespace appearing before the close of the start tag (<div >) (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | OriginalTag | Returns the text in it's original format. Where IsSpecial == true, this is used to rewrite the content. (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Parent | Returns the parent (if any) of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | PrevSibling | Returns the previous sibling element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | TagName | Returns the tag name of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Value | Returns the value (if any) of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

Public Methods

 | Name | Description
Public Method | AddCData | Encountered cdata section in the document
Public Method | AddComment | Encountered comment in the document
Public Method | AddControl | Encountered control information <! ... > in the document
Public Method | AddInstruction | Encountered processing instruction <? ... ?> in the document
Public Method | AddText | Encountered text or whitespace in the document
Public Method | CreateNavigator | Returns a new System.Xml.XPath.XPathNavigator object. (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | EndDocument | Ends the processing of an xml input
Public Method | EndTag | Ends the processing of an xml tag
Public Method | FindElement | Finds the elements matching the provided criteria (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | GetElementById | Deep-scans heirarchy for the element with the provided id (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | Remove | Removes this node from it's parent element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | Select | Returns the elements from the given xpath expression (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | SelectSingleNode | Returns the first element from the given xpath expression (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | StartDocument | Begins the processing of an xml input
Public Method | StartTag | Begins the processing of an xml tag
Public Method | WriteUnformatted | Overridden. Writes the re-constructed document while attempting to preserve formatting
Public Method | WriteXml | Overloaded. Overridden. Writes the re-constructed innerXML
Top

Protected Methods

 | Name | Description
Protected Method | WriteText | (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

See Also

Reference

XmlLightDocument Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightDocument Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : XmlLightDocument Constructor

Glossary Item Box

Overload List

Overload | Description
XmlLightDocument Constructor() | Parses the document provided
XmlLightDocument Constructor(String) | Parses the document provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightDocument Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class > XmlLightDocument Constructor : XmlLightDocument Constructor()

Glossary Item Box

Parses the document provided

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public XmlLightDocument()

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string notxml = "<html id=a ><body foo='bar' bar=\"foo\" />";

HtmlLightDocument html = new HtmlLightDocument();
XmlLightParser.Parse(notxml, html);
Assert.AreEqual("html", html.Root.TagName);
Assert.AreEqual(1, html.Root.Attributes.Count);
Assert.AreEqual("a", html.Root.Attributes["id"]);
Assert.AreEqual(1, html.Root.Children.Count);
Assert.AreEqual("body", html.Root.Children[0].TagName);
Assert.AreEqual("foo", html.Root.Children[0].Attributes["bar"]);
Assert.AreEqual("bar", html.Root.Children[0].Attributes["foo"]);

XmlLightDocument xml = new XmlLightDocument();
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml);
Assert.AreEqual(2, xml.Root.Attributes.Count);
//Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName);
Assert.AreEqual("foo", xml.Root.Attributes["bar"]);
Assert.AreEqual("bar", xml.Root.Attributes["foo"]);
VB.NET Copy Code
Dim notxml As String = "<html id=a ><body foo='bar' bar=""foo"" />"

Dim html As New HtmlLightDocument()
XmlLightParser.Parse(notxml, html)
Assert.AreEqual("html", html.Root.TagName)
Assert.AreEqual(1, html.Root.Attributes.Count)
Assert.AreEqual("a", html.Root.Attributes("id"))
Assert.AreEqual(1, html.Root.Children.Count)
Assert.AreEqual("body", html.Root.Children(0).TagName)
Assert.AreEqual("foo", html.Root.Children(0).Attributes("bar"))
Assert.AreEqual("bar", html.Root.Children(0).Attributes("foo"))

Dim xml As New XmlLightDocument()
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml)
Assert.AreEqual(2, xml.Root.Attributes.Count)
'Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName)
Assert.AreEqual("foo", xml.Root.Attributes("bar"))
Assert.AreEqual("bar", xml.Root.Attributes("foo"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members
Overload List

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightDocument Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class > XmlLightDocument Constructor : XmlLightDocument Constructor(String)

content

Glossary Item Box

Parses the document provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal content As String _
)
C#
public XmlLightDocument(
   string content
)

Parameters

content

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string[] files = Directory.GetFiles(@"c:\temp\trash", "*.htm", SearchOption.AllDirectories);
System.Diagnostics.Stopwatch sw;

for (int i = 0; i < 10; i++)
{
    //HTML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new HtmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds);
    //XML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new XmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds);
    //Parse Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    IXmlLightReader rdr = new EmptyReader();
    foreach (string file in files)
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr);

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds);
    //Text Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        XmlLightParser.ParseText(File.ReadAllText(file));

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds);
}
VB.NET Copy Code
Dim files As String() = Directory.GetFiles("c:\temp\trash", "*.htm", SearchOption.AllDirectories)
Dim sw As System.Diagnostics.Stopwatch

Dim i As Integer = 0
While i < 10
    'HTML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New HtmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds)
    'XML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New XmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds)
    'Parse Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    Dim rdr As IXmlLightReader = New EmptyReader()
    For Each file As String In files
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr)
    Next

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds)
    'Text Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        XmlLightParser.ParseText(File.ReadAllText(file))
    Next

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members
Overload List

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
XmlLightDocument Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightDocument Class

Glossary Item Box

For a list of all members of this type, see XmlLightDocument members.

Public Methods

 | Name | Description
Public Method | AddCData | Encountered cdata section in the document
Public Method | AddComment | Encountered comment in the document
Public Method | AddControl | Encountered control information <! ... > in the document
Public Method | AddInstruction | Encountered processing instruction <? ... ?> in the document
Public Method | AddText | Encountered text or whitespace in the document
Public Method | CreateNavigator | Returns a new System.Xml.XPath.XPathNavigator object. (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | EndDocument | Ends the processing of an xml input
Public Method | EndTag | Ends the processing of an xml tag
Public Method | FindElement | Finds the elements matching the provided criteria (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | GetElementById | Deep-scans heirarchy for the element with the provided id (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | Remove | Removes this node from it's parent element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | Select | Returns the elements from the given xpath expression (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | SelectSingleNode | Returns the first element from the given xpath expression (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Method | StartDocument | Begins the processing of an xml input
Public Method | StartTag | Begins the processing of an xml tag
Public Method | WriteUnformatted | Overridden. Writes the re-constructed document while attempting to preserve formatting
Public Method | WriteXml | Overloaded. Overridden. Writes the re-constructed innerXML
Top

Protected Methods

 | Name | Description
Protected Method | WriteText | (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

See Also

Reference

XmlLightDocument Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddCData Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : AddCData Method

cdata

Glossary Item Box

Encountered cdata section in the document

Syntax

Visual Basic (Declaration)
Public Overridable Sub AddCData( _
   ByVal cdata As String _
)
C#
public virtual void AddCData(
   string cdata
)

Parameters

cdata

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddComment Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : AddComment Method

comment

Glossary Item Box

Encountered comment in the document

Syntax

Visual Basic (Declaration)
Public Overridable Sub AddComment( _
   ByVal comment As String _
)
C#
public virtual void AddComment(
   string comment
)

Parameters

comment

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddControl Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : AddControl Method

ctrl

Glossary Item Box

Encountered control information <! ... > in the document

Syntax

Visual Basic (Declaration)
Public Overridable Sub AddControl( _
   ByVal ctrl As String _
)
C#
public virtual void AddControl(
   string ctrl
)

Parameters

ctrl

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddInstruction Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : AddInstruction Method

instruction

Glossary Item Box

Encountered processing instruction <? ... ?> in the document

Syntax

Visual Basic (Declaration)
Public Overridable Sub AddInstruction( _
   ByVal instruction As String _
)
C#
public virtual void AddInstruction(
   string instruction
)

Parameters

instruction

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddText Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : AddText Method

content

Glossary Item Box

Encountered text or whitespace in the document

Syntax

Visual Basic (Declaration)
Public Overridable Sub AddText( _
   ByVal content As String _
)
C#
public virtual void AddText(
   string content
)

Parameters

content

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EndDocument Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : EndDocument Method

Glossary Item Box

Ends the processing of an xml input

Syntax

Visual Basic (Declaration)
Public Overridable Sub EndDocument()
C#
public virtual void EndDocument()

Exceptions

Exception | Description
System.Xml.XmlException | Returns detailed information about the last exception.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EndTag Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : EndTag Method

tag

Glossary Item Box

Ends the processing of an xml tag

Syntax

Visual Basic (Declaration)
Public Overridable Sub EndTag( _
   ByVal tag As XmlTagInfo _
)
C#
public virtual void EndTag(
   XmlTagInfo tag
)

Parameters

tag

Exceptions

Exception | Description
System.Xml.XmlException | Returns detailed information about the last exception.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members
XmlTagInfo

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StartDocument Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : StartDocument Method

Glossary Item Box

Begins the processing of an xml input

Syntax

Visual Basic (Declaration)
Public Overridable Sub StartDocument()
C#
public virtual void StartDocument()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StartTag Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : StartTag Method

tag

Glossary Item Box

Begins the processing of an xml tag

Syntax

Visual Basic (Declaration)
Public Overridable Sub StartTag( _
   ByVal tag As XmlTagInfo _
)
C#
public virtual void StartTag(
   XmlTagInfo tag
)

Parameters

tag

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members
XmlTagInfo

Source Code

Library/Html/XmlLightDocument.cs

Used By

HtmlLightDocument.StartTag(XmlTagInfo)


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteUnformatted Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : WriteUnformatted Method

wtr

Glossary Item Box

Writes the re-constructed document while attempting to preserve formatting

Syntax

Visual Basic (Declaration)
Public Overrides Sub WriteUnformatted( _
   ByVal wtr As TextWriter _
)
C#
public override void WriteUnformatted(
   TextWriter wtr
)

Parameters

wtr

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members
Base Implementation in WriteUnformatted

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteXml Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : WriteXml Method

Glossary Item Box

Writes the re-constructed innerXML

Overload List

Overload | Description
WriteXml(XmlWriter) | Writes the re-constructed innerXML
WriteXml(TextWriter) | Writes the re-constructed innerHTML in a well-formed Xml format (Inherited from CSharpTest.Net.Html.XmlLightElement)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members
Base Implementation in WriteXml


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteXml(XmlWriter) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class > WriteXml Method : WriteXml(XmlWriter) Method

wtr

Glossary Item Box

Writes the re-constructed innerXML

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Sub WriteXml( _
   ByVal wtr As XmlWriter _
)
C#
public override void WriteXml(
   XmlWriter wtr
)

Parameters

wtr

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members
Overload List
Base Implementation in WriteXml(XmlWriter)

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
XmlLightDocument Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightDocument Class

Glossary Item Box

For a list of all members of this type, see XmlLightDocument members.

Public Fields

 | Name | Description
Public Field | Attributes | Returns the attributes of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Field | Children | Returns the children of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Field | Root | Returns the root element
Top

Protected Fields

 | Name | Description
Protected Field | _parserStack | Stores the current node stack while parsing documents
Top

See Also

Reference

XmlLightDocument Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
_parserStack Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : _parserStack Field

Glossary Item Box

Stores the current node stack while parsing documents

Syntax

Visual Basic (Declaration)
Protected _parserStack As Stack(Of XmlLightElement)
C#
protected Stack<XmlLightElement> _parserStack

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Used By

XmlLightDocument.StartDocument()
XmlLightDocument.StartTag(XmlTagInfo)
XmlLightDocument.EndTag(XmlTagInfo)
XmlLightDocument.AddText(String)
XmlLightDocument.AddComment(String)
XmlLightDocument.AddCData(String)
XmlLightDocument.AddControl(String)
XmlLightDocument.AddInstruction(String)
XmlLightDocument.EndDocument()
HtmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.EndDocument()


%%PageItemTitle%%

[image]
CSharpTest.Net
Root Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightDocument Class : Root Field

Glossary Item Box

Returns the root element

Syntax

Visual Basic (Declaration)
Public Root As XmlLightElement
C#
public XmlLightElement Root

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string xml = "<root id='a'></root>";
XmlLightDocument doc = new XmlLightDocument(xml);
Assert.AreEqual("root", doc.Root.LocalName);
Assert.AreEqual(1, doc.Root.Attributes.Count);
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext());
Assert.IsTrue(((System.Collections.IEnumerable)doc.Root.Attributes).GetEnumerator().MoveNext());
Assert.IsTrue(doc.Root.Attributes.Remove("id"));
Assert.AreEqual(0, doc.Root.Attributes.Count);
VB.NET Copy Code
Dim xml As String = "<root id='a'></root>"
Dim doc As New XmlLightDocument(xml)
Assert.AreEqual("root", doc.Root.LocalName)
Assert.AreEqual(1, doc.Root.Attributes.Count)
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext())
Assert.IsTrue((DirectCast(doc.Root.Attributes, System.Collections.IEnumerable)).GetEnumerator().MoveNext())
Assert.IsTrue(doc.Root.Attributes.Remove("id"))
Assert.AreEqual(0, doc.Root.Attributes.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightDocument Class
XmlLightDocument Members

Used By

XmlLightDocument.StartTag(XmlTagInfo)
XmlLightDocument.EndDocument()
HtmlLightDocument.EndDocument()

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightElement Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightElement Class

Glossary Item Box

Represents an html element

Object Model

XmlLightElement ClassXmlLightElement ClassXmlLightElement ClassXmlLightElement ClassXmlLightElement Class

Syntax

Visual Basic (Declaration)
Public Class XmlLightElement
C#
public class XmlLightElement

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Inheritance Hierarchy

System.Object
CSharpTest.Net.Html.XmlLightElement
CSharpTest.Net.Html.XmlLightDocument

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Members
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
XmlLightElement Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightElement Class

Glossary Item Box

The following tables list the members exposed by XmlLightElement.

Public Constructors

 | Name | Description
Public Constructor | XmlLightElement Constructor | Creates a new xml element
Top

Public Fields

 | Name | Description
Public Field | Attributes | Returns the attributes of this html element
static (Shared in Visual Basic) | CDATA | Provides tag name assigned to the CDATA nodes in the heirarchy
Public Field | Children | Returns the children of this html element
static (Shared in Visual Basic) | COMMENT | Provides tag name assigned to comment nodes in the heirarchy
static (Shared in Visual Basic) | CONTROL | Provides tag name assigned to the TEXT nodes in the heirarchy
static (Shared in Visual Basic) | PROCESSING | Provides tag name assigned to processing instruction nodes in the heirarchy
static (Shared in Visual Basic) | ROOT | Provides tag name assigned to the ROOT node of the heirarchy
static (Shared in Visual Basic) | TEXT | Provides tag name assigned to the TEXT nodes in the heirarchy
Top

Public Properties

 | Name | Description
Public Property | ClosingTagWhitespace | Whitespace appearing before the close of the end tag (</div >)
Public Property | Document | Returns the root-level node
Public Property | InnerText | Returns the inner text of this html element
Public Property | InnerXml | Returns the re-constructed innerHTML in a well-formed Xml format
Public Property | IsComment | Returns true if the node is a comment
Public Property | IsEmpty | Returns true if the node is self-closing (i.e. ends with '/>')
Public Property | IsSpecialTag | Returns true if the node is not a normal element
Public Property | IsText | Returns true if the node has a textual value, i.e. text or cdata
Public Property | LocalName | Returns the name without the namespace prefix
Public Property | Namespace | Returns the namespace or empty string
Public Property | NamespaceOrNull | Returns the namespace or null
Public Property | NextSibling | Returns the next sibling element
Public Property | OpeningTagWhitespace | Whitespace appearing before the close of the start tag (<div >)
Public Property | OriginalTag | Returns the text in it's original format. Where IsSpecial == true, this is used to rewrite the content.
Public Property | Parent | Returns the parent (if any) of this html element
Public Property | PrevSibling | Returns the previous sibling element
Public Property | TagName | Returns the tag name of this html element
Public Property | Value | Returns the value (if any) of this html element
Top

Public Methods

 | Name | Description
Public Method | CreateNavigator | Returns a new System.Xml.XPath.XPathNavigator object.
Public Method | FindElement | Finds the elements matching the provided criteria
Public Method | GetElementById | Deep-scans heirarchy for the element with the provided id
Public Method | Remove | Removes this node from it's parent element
Public Method | Select | Returns the elements from the given xpath expression
Public Method | SelectSingleNode | Returns the first element from the given xpath expression
Public Method | WriteUnformatted | Writes the modified document in it's original formatting
Public Method | WriteXml | Overloaded. Writes XML to an xml writer to ensure proper formatting
Top

Protected Methods

 | Name | Description
Protected Method | WriteText | Writes the text to the xml writer while preserving entities and still ensuring the remainder of the text is properly encoded.
Top

See Also

Reference

XmlLightElement Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightElement Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : XmlLightElement Constructor

parent
tagName

Glossary Item Box

Creates a new xml element

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal parent As XmlLightElement, _
   ByVal tagName As String _
)
C#
public XmlLightElement(
   XmlLightElement parent,
   string tagName
)

Parameters

parent
tagName

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
XmlLightElement Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightElement Class

Glossary Item Box

For a list of all members of this type, see XmlLightElement members.

Public Methods

 | Name | Description
Public Method | CreateNavigator | Returns a new System.Xml.XPath.XPathNavigator object.
Public Method | FindElement | Finds the elements matching the provided criteria
Public Method | GetElementById | Deep-scans heirarchy for the element with the provided id
Public Method | Remove | Removes this node from it's parent element
Public Method | Select | Returns the elements from the given xpath expression
Public Method | SelectSingleNode | Returns the first element from the given xpath expression
Public Method | WriteUnformatted | Writes the modified document in it's original formatting
Public Method | WriteXml | Overloaded. Writes XML to an xml writer to ensure proper formatting
Top

Protected Methods

 | Name | Description
Protected Method | WriteText | Writes the text to the xml writer while preserving entities and still ensuring the remainder of the text is properly encoded.
Top

See Also

Reference

XmlLightElement Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNavigator Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : CreateNavigator Method

Glossary Item Box

Returns a new System.Xml.XPath.XPathNavigator object.

Syntax

Visual Basic (Declaration)
Public Function CreateNavigator() As XPathNavigator
C#
public XPathNavigator CreateNavigator()

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XPathNavigator nav = new HtmlLightDocument(document).CreateNavigator().SelectSingleNode("/html/body//p[@class='1']");
XPathNavigator pos = nav.Clone();
Assert.IsFalse(nav.MoveToPrevious());
Assert.IsTrue(nav.MoveToNext());
Assert.IsTrue(nav.MoveToPrevious());
Assert.IsTrue(nav.IsSamePosition(pos));

Assert.IsFalse(nav.MoveToFirstNamespace());
Assert.IsFalse(nav.MoveToNextNamespace());

Assert.IsTrue(Object.ReferenceEquals(nav.NameTable, pos.NameTable));
Assert.IsNotNull(nav.BaseURI);
Assert.AreEqual(nav.BaseURI, pos.BaseURI);

Assert.IsTrue(nav.MoveToId("one"));
Assert.AreEqual("body", nav.Name);
Assert.IsFalse(nav.MoveToId("none-exists"));
Assert.AreEqual("body", nav.Name);
VB.NET Copy Code
Dim nav As XPathNavigator = New HtmlLightDocument(document).CreateNavigator().SelectSingleNode("/html/body//p[@class='1']")
Dim pos As XPathNavigator = nav.Clone()
Assert.IsFalse(nav.MoveToPrevious())
Assert.IsTrue(nav.MoveToNext())
Assert.IsTrue(nav.MoveToPrevious())
Assert.IsTrue(nav.IsSamePosition(pos))

Assert.IsFalse(nav.MoveToFirstNamespace())
Assert.IsFalse(nav.MoveToNextNamespace())

Assert.IsTrue([Object].ReferenceEquals(nav.NameTable, pos.NameTable))
Assert.IsNotNull(nav.BaseURI)
Assert.AreEqual(nav.BaseURI, pos.BaseURI)

Assert.IsTrue(nav.MoveToId("one"))
Assert.AreEqual("body", nav.Name)
Assert.IsFalse(nav.MoveToId("none-exists"))
Assert.AreEqual("body", nav.Name)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindElement Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : FindElement Method

match

Glossary Item Box

Finds the elements matching the provided criteria

Syntax

Visual Basic (Declaration)
Public Function FindElement( _
   ByVal match As Predicate(Of XmlLightElement) _
) As IEnumerable(Of XmlLightElement)
C#
public IEnumerable<XmlLightElement> FindElement(
   Predicate<XmlLightElement> match
)

Parameters

match

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement XmlLightElement.GetElementById(String)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetElementById Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : GetElementById Method

id

Glossary Item Box

Deep-scans heirarchy for the element with the provided id

Syntax

Visual Basic (Declaration)
Public Function GetElementById( _
   ByVal id As String _
) As XmlLightElement
C#
public XmlLightElement GetElementById(
   string id
)

Parameters

id

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : Remove Method

Glossary Item Box

Removes this node from it's parent element

Syntax

Visual Basic (Declaration)
Public Sub Remove()
C#
public void Remove()

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Select Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : Select Method

xpath

Glossary Item Box

Returns the elements from the given xpath expression

Syntax

Visual Basic (Declaration)
Public Function Select( _
   ByVal xpath As String _
) As IEnumerable(Of XmlLightElement)
C#
public IEnumerable<XmlLightElement> Select(
   string xpath
)

Parameters

xpath

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs

Used By

XmlLightElement XmlLightElement.SelectSingleNode(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
SelectSingleNode Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : SelectSingleNode Method

xpath

Glossary Item Box

Returns the first element from the given xpath expression

Syntax

Visual Basic (Declaration)
Public Function SelectSingleNode( _
   ByVal xpath As String _
) As XmlLightElement
C#
public XmlLightElement SelectSingleNode(
   string xpath
)

Parameters

xpath

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightDocument doc = new HtmlLightDocument(document);
XmlLightElement e = doc.SelectSingleNode("/html/head");
e = e.NextSibling;
Assert.IsTrue(e.IsComment);
Assert.AreEqual("<!-- comments included -->", e.InnerXml);
VB.NET Copy Code
Dim doc As XmlLightDocument = New HtmlLightDocument(document)
Dim e As XmlLightElement = doc.SelectSingleNode("/html/head")
e = e.NextSibling
Assert.IsTrue(e.IsComment)
Assert.AreEqual("<!-- comments included -->", e.InnerXml)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteText(XmlWriter,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : WriteText(XmlWriter,String) Method

wtr
encodedValue

Glossary Item Box

Writes the text to the xml writer while preserving entities and still ensuring the remainder of the text is properly encoded.

Syntax

Visual Basic (Declaration)
Protected Overridable Sub WriteText( _
   ByVal wtr As XmlWriter, _
   ByVal encodedValue As String _
)
C#
protected virtual void WriteText(
   XmlWriter wtr,
   string encodedValue
)

Parameters

wtr
encodedValue

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteUnformatted Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : WriteUnformatted Method

wtr

Glossary Item Box

Writes the modified document in it's original formatting

Syntax

Visual Basic (Declaration)
Public Overridable Sub WriteUnformatted( _
   ByVal wtr As TextWriter _
)
C#
public virtual void WriteUnformatted(
   TextWriter wtr
)

Parameters

wtr

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs

Used By

XmlLightElement.WriteUnformatted(TextWriter)
XmlLightDocument.WriteUnformatted(TextWriter)


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteXml Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : WriteXml Method

Glossary Item Box

Writes XML to an xml writer to ensure proper formatting

Overload List

Overload | Description
WriteXml(XmlWriter) | Writes XML to an xml writer to ensure proper formatting
WriteXml(TextWriter) | Writes the re-constructed innerHTML in a well-formed Xml format

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteXml(XmlWriter) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class > WriteXml Method : WriteXml(XmlWriter) Method

wtr

Glossary Item Box

Writes XML to an xml writer to ensure proper formatting

Syntax

Visual Basic (Declaration)
Public Overloads Overridable Sub WriteXml( _
   ByVal wtr As XmlWriter _
)
C#
public virtual void WriteXml(
   XmlWriter wtr
)

Parameters

wtr

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string html = @"<html>
<body attrib=""this & that ><&nbsp;&#32;!"">
    this char '<' and this one '>' and this one '&' should be encoded.
    We encoded ' &nbsp; ' and &Atilde; and '&#32;' and '&#x20;' all by ourselves.
    This in not valid xml &#xffffffff;, nor is &#123456789;, but we still allow it.
    This entity name will pass-through &unknown; this will not &whateverthatmeans;
    and nor will these &; &#; &h; &l t; &1two; &234; &#x00fg; &#-123;.
</body>
</html>";
string expect = @"<html><body attrib=""this &amp; that &gt;&lt;" + (Char)160 + @" !"">
    this char '&lt;' and this one '&gt;' and this one '&amp;' should be encoded.
    We encoded ' &nbsp; ' and &Atilde; and '&#32;' and '&#x20;' all by ourselves.
    This in not valid xml &#xffffffff;, nor is &#123456789;, but we still allow it.
    This entity name will pass-through &unknown; this will not &amp;whateverthatmeans;
    and nor will these &amp;; &amp;#; &amp;h; &amp;l t; &amp;1two; &amp;234; &amp;#x00fg; &amp;#-123;.
</body></html>";

XmlLightDocument doc = new HtmlLightDocument(html);
XmlWriterSettings settings = new XmlWriterSettings()
{
    CheckCharacters = true,
    Indent = false,
    IndentChars = "",
    NewLineChars = "",
    NewLineHandling = NewLineHandling.None,
    OmitXmlDeclaration = true,
    CloseOutput = false
};
StringWriter sw = new StringWriter();
XmlWriter wtr = XmlWriter.Create(sw, settings);
doc.WriteXml(wtr);
wtr.Flush();
string xml = sw.ToString();

Assert.AreEqual(expect, xml);
VB.NET Copy Code
Dim html As String = "<html>" & vbCr & vbLf & "            <body attrib=""this & that ><&nbsp;&#32;!"">" & vbCr & vbLf & "                this char '<' and this one '>' and this one '&' should be encoded.  " & vbCr & vbLf & "                We encoded ' &nbsp; ' and &Atilde; and '&#32;' and '&#x20;' all by ourselves." & vbCr & vbLf & "                This in not valid xml &#xffffffff;, nor is &#123456789;, but we still allow it." & vbCr & vbLf & "                This entity name will pass-through &unknown; this will not &whateverthatmeans;" & vbCr & vbLf & "                and nor will these &; &#; &h; &l t; &1two; &234; &#x00fg; &#-123;." & vbCr & vbLf & "            </body>" & vbCr & vbLf & "            </html>"
Dim expect As String = "<html><body attrib=""this &amp; that &gt;&lt;" + DirectCast(160, [Char]) + " !"">" & vbCr & vbLf & "                this char '&lt;' and this one '&gt;' and this one '&amp;' should be encoded.  " & vbCr & vbLf & "                We encoded ' &nbsp; ' and &Atilde; and '&#32;' and '&#x20;' all by ourselves." & vbCr & vbLf & "                This in not valid xml &#xffffffff;, nor is &#123456789;, but we still allow it." & vbCr & vbLf & "                This entity name will pass-through &unknown; this will not &amp;whateverthatmeans;" & vbCr & vbLf & "                and nor will these &amp;; &amp;#; &amp;h; &amp;l t; &amp;1two; &amp;234; &amp;#x00fg; &amp;#-123;." & vbCr & vbLf & "            </body></html>"

Dim doc As XmlLightDocument = New HtmlLightDocument(html)
Dim settings As New XmlWriterSettings() With { _
    Key .CheckCharacters = True, _
    Key .Indent = False, _
    Key .IndentChars = "", _
    Key .NewLineChars = "", _
    Key .NewLineHandling = NewLineHandling.None, _
    Key .OmitXmlDeclaration = True, _
    Key .CloseOutput = False _
}
Dim sw As New StringWriter()
Dim wtr As XmlWriter = XmlWriter.Create(sw, settings)
doc.WriteXml(wtr)
wtr.Flush()
Dim xml As String = sw.ToString()

Assert.AreEqual(expect, xml)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members
Overload List

Source Code

Library/Html/XmlLightElement.cs

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteXml(TextWriter)
XmlLightDocument.WriteXml(XmlWriter)


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteXml(TextWriter) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class > WriteXml Method : WriteXml(TextWriter) Method

wtr

Glossary Item Box

Writes the re-constructed innerHTML in a well-formed Xml format

Syntax

Visual Basic (Declaration)
Public Overloads Sub WriteXml( _
   ByVal wtr As TextWriter _
)
C#
public void WriteXml(
   TextWriter wtr
)

Parameters

wtr

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightDocument doc = new HtmlLightDocument(document);
XmlLightDocument doc2;
using (TempFile t = new TempFile())
{
    using (TextWriter tw = new StreamWriter(t.Open()))
        doc.WriteXml(tw);
    new XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10).Validate(t.TempPath);
    doc2 = new XmlLightDocument(t.ReadAllText());

    Assert.AreEqual(doc.InnerXml, doc2.InnerXml);
}
VB.NET Copy Code
Dim doc As XmlLightDocument = New HtmlLightDocument(document)
Dim doc2 As XmlLightDocument
Using t As New TempFile()
    Using tw As TextWriter = New StreamWriter(t.Open())
        doc.WriteXml(tw)
    End Using
    New XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10).Validate(t.TempPath)
    doc2 = New XmlLightDocument(t.ReadAllText())

    Assert.AreEqual(doc.InnerXml, doc2.InnerXml)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members
Overload List

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
XmlLightElement Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightElement Class

Glossary Item Box

For a list of all members of this type, see XmlLightElement members.

Public Properties

 | Name | Description
Public Property | ClosingTagWhitespace | Whitespace appearing before the close of the end tag (</div >)
Public Property | Document | Returns the root-level node
Public Property | InnerText | Returns the inner text of this html element
Public Property | InnerXml | Returns the re-constructed innerHTML in a well-formed Xml format
Public Property | IsComment | Returns true if the node is a comment
Public Property | IsEmpty | Returns true if the node is self-closing (i.e. ends with '/>')
Public Property | IsSpecialTag | Returns true if the node is not a normal element
Public Property | IsText | Returns true if the node has a textual value, i.e. text or cdata
Public Property | LocalName | Returns the name without the namespace prefix
Public Property | Namespace | Returns the namespace or empty string
Public Property | NamespaceOrNull | Returns the namespace or null
Public Property | NextSibling | Returns the next sibling element
Public Property | OpeningTagWhitespace | Whitespace appearing before the close of the start tag (<div >)
Public Property | OriginalTag | Returns the text in it's original format. Where IsSpecial == true, this is used to rewrite the content.
Public Property | Parent | Returns the parent (if any) of this html element
Public Property | PrevSibling | Returns the previous sibling element
Public Property | TagName | Returns the tag name of this html element
Public Property | Value | Returns the value (if any) of this html element
Top

See Also

Reference

XmlLightElement Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClosingTagWhitespace Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : ClosingTagWhitespace Property

Glossary Item Box

Whitespace appearing before the close of the end tag (</div >)

Syntax

Visual Basic (Declaration)
Public Property ClosingTagWhitespace As String
C#
public string ClosingTagWhitespace {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteUnformatted(TextWriter)
XmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Document Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : Document Property

Glossary Item Box

Returns the root-level node

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Document As XmlLightElement
C#
public XmlLightElement Document {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InnerText Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : InnerText Property

Glossary Item Box

Returns the inner text of this html element

Syntax

Visual Basic (Declaration)
Public ReadOnly Property InnerText As String
C#
public string InnerText {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightDocument doc = new HtmlLightDocument(document);
XmlLightElement e = doc.SelectSingleNode("/html/body");
Assert.AreEqual("this is > cdata! Hi, this is content.", Normalize(e.InnerText));
Assert.AreEqual("Hi", e.SelectSingleNode(".//div[@id='two']").InnerText);
Assert.AreEqual("this is > cdata!", Normalize(e.SelectSingleNode("text()").InnerText));
VB.NET Copy Code
Dim doc As XmlLightDocument = New HtmlLightDocument(document)
Dim e As XmlLightElement = doc.SelectSingleNode("/html/body")
Assert.AreEqual("this is > cdata! Hi, this is content.", Normalize(e.InnerText))
Assert.AreEqual("Hi", e.SelectSingleNode(".//div[@id='two']").InnerText)
Assert.AreEqual("this is > cdata!", Normalize(e.SelectSingleNode("text()").InnerText))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InnerXml Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : InnerXml Property

Glossary Item Box

Returns the re-constructed innerHTML in a well-formed Xml format

Syntax

Visual Basic (Declaration)
Public ReadOnly Property InnerXml As String
C#
public string InnerXml {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightDocument doc = new HtmlLightDocument(document);
XmlLightElement e = doc.SelectSingleNode("/html/head");
e = e.NextSibling;
Assert.IsTrue(e.IsComment);
Assert.AreEqual("<!-- comments included -->", e.InnerXml);
VB.NET Copy Code
Dim doc As XmlLightDocument = New HtmlLightDocument(document)
Dim e As XmlLightElement = doc.SelectSingleNode("/html/head")
e = e.NextSibling
Assert.IsTrue(e.IsComment)
Assert.AreEqual("<!-- comments included -->", e.InnerXml)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsComment Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : IsComment Property

Glossary Item Box

Returns true if the node is a comment

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsComment As Boolean
C#
public bool IsComment {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightDocument doc = new HtmlLightDocument(document);
XmlLightElement e = doc.SelectSingleNode("/html/head");
e = e.NextSibling;
Assert.IsTrue(e.IsComment);
Assert.AreEqual("<!-- comments included -->", e.InnerXml);
VB.NET Copy Code
Dim doc As XmlLightDocument = New HtmlLightDocument(document)
Dim e As XmlLightElement = doc.SelectSingleNode("/html/head")
e = e.NextSibling
Assert.IsTrue(e.IsComment)
Assert.AreEqual("<!-- comments included -->", e.InnerXml)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsEmpty Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : IsEmpty Property

Glossary Item Box

Returns true if the node is self-closing (i.e. ends with '/>')

Syntax

Visual Basic (Declaration)
Public Property IsEmpty As Boolean
C#
public bool IsEmpty {get; set;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
HtmlLightDocument doc = new HtmlLightDocument();
XmlLightElement body = new XmlLightElement(new XmlLightElement(doc, "html"), "body");
body.IsEmpty = false;
body.Attributes.Add("id", "bdy");
Assert.AreEqual("<html> <body id=\"bdy\"> </body> </html>", Normalize(doc.InnerXml));
VB.NET Copy Code
Dim doc As New HtmlLightDocument()
Dim body As New XmlLightElement(New XmlLightElement(doc, "html"), "body")
body.IsEmpty = False
body.Attributes.Add("id", "bdy")
Assert.AreEqual("<html> <body id=""bdy""> </body> </html>", Normalize(doc.InnerXml))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsSpecialTag Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : IsSpecialTag Property

Glossary Item Box

Returns true if the node is not a normal element

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsSpecialTag As Boolean
C#
public bool IsSpecialTag {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsText Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : IsText Property

Glossary Item Box

Returns true if the node has a textual value, i.e. text or cdata

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsText As Boolean
C#
public bool IsText {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : LocalName Property

Glossary Item Box

Returns the name without the namespace prefix

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LocalName As String
C#
public string LocalName {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string xml = "<root id='a'></root>";
XmlLightDocument doc = new XmlLightDocument(xml);
Assert.AreEqual("root", doc.Root.LocalName);
Assert.AreEqual(1, doc.Root.Attributes.Count);
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext());
Assert.IsTrue(((System.Collections.IEnumerable)doc.Root.Attributes).GetEnumerator().MoveNext());
Assert.IsTrue(doc.Root.Attributes.Remove("id"));
Assert.AreEqual(0, doc.Root.Attributes.Count);
VB.NET Copy Code
Dim xml As String = "<root id='a'></root>"
Dim doc As New XmlLightDocument(xml)
Assert.AreEqual("root", doc.Root.LocalName)
Assert.AreEqual(1, doc.Root.Attributes.Count)
Assert.IsTrue(doc.Root.Attributes.GetEnumerator().MoveNext())
Assert.IsTrue((DirectCast(doc.Root.Attributes, System.Collections.IEnumerable)).GetEnumerator().MoveNext())
Assert.IsTrue(doc.Root.Attributes.Remove("id"))
Assert.AreEqual(0, doc.Root.Attributes.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Namespace Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : Namespace Property

Glossary Item Box

Returns the namespace or empty string

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Namespace As String
C#
public string Namespace {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightDocument doc = new HtmlLightDocument(document);
Assert.IsNull(doc.PrevSibling);
Assert.IsNull(doc.Children[0].PrevSibling);
Assert.IsNull(doc.NextSibling);
Assert.IsNull(doc.Children[doc.Children.Count - 1].NextSibling);

XmlLightElement e = doc.SelectSingleNode("/html/body//*[@class='2']");
Assert.IsNotNull(e);
Assert.AreEqual("p", e.TagName);
Assert.IsNotNull(e.PrevSibling);
Assert.AreEqual("p", e.PrevSibling.TagName);

Assert.AreEqual("", e.Namespace);
Assert.AreEqual("p", e.LocalName);

e = new XmlLightElement(null, "a:b");
Assert.AreEqual("a", e.Namespace);
Assert.AreEqual("b", e.LocalName);
VB.NET Copy Code
Dim doc As XmlLightDocument = New HtmlLightDocument(document)
Assert.IsNull(doc.PrevSibling)
Assert.IsNull(doc.Children(0).PrevSibling)
Assert.IsNull(doc.NextSibling)
Assert.IsNull(doc.Children(doc.Children.Count - 1).NextSibling)

Dim e As XmlLightElement = doc.SelectSingleNode("/html/body//*[@class='2']")
Assert.IsNotNull(e)
Assert.AreEqual("p", e.TagName)
Assert.IsNotNull(e.PrevSibling)
Assert.AreEqual("p", e.PrevSibling.TagName)

Assert.AreEqual("", e.[Namespace])
Assert.AreEqual("p", e.LocalName)

e = New XmlLightElement(Nothing, "a:b")
Assert.AreEqual("a", e.[Namespace])
Assert.AreEqual("b", e.LocalName)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NamespaceOrNull Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : NamespaceOrNull Property

Glossary Item Box

Returns the namespace or null

Syntax

Visual Basic (Declaration)
Public ReadOnly Property NamespaceOrNull As String
C#
public string NamespaceOrNull {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NextSibling Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : NextSibling Property

Glossary Item Box

Returns the next sibling element

Syntax

Visual Basic (Declaration)
Public ReadOnly Property NextSibling As XmlLightElement
C#
public XmlLightElement NextSibling {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightDocument doc = new HtmlLightDocument(document);
XmlLightElement e = doc.SelectSingleNode("/html/head");
e = e.NextSibling;
Assert.IsTrue(e.IsComment);
Assert.AreEqual("<!-- comments included -->", e.InnerXml);
VB.NET Copy Code
Dim doc As XmlLightDocument = New HtmlLightDocument(document)
Dim e As XmlLightElement = doc.SelectSingleNode("/html/head")
e = e.NextSibling
Assert.IsTrue(e.IsComment)
Assert.AreEqual("<!-- comments included -->", e.InnerXml)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OpeningTagWhitespace Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : OpeningTagWhitespace Property

Glossary Item Box

Whitespace appearing before the close of the start tag (<div >)

Syntax

Visual Basic (Declaration)
Public Property OpeningTagWhitespace As String
C#
public string OpeningTagWhitespace {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OriginalTag Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : OriginalTag Property

Glossary Item Box

Returns the text in it's original format. Where IsSpecial == true, this is used to rewrite the content.

Syntax

Visual Basic (Declaration)
Public Property OriginalTag As String
C#
public string OriginalTag {get; set;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Parent Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : Parent Property

Glossary Item Box

Returns the parent (if any) of this html element

Syntax

Visual Basic (Declaration)
Public Property Parent As XmlLightElement
C#
public XmlLightElement Parent {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.Remove()

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PrevSibling Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : PrevSibling Property

Glossary Item Box

Returns the previous sibling element

Syntax

Visual Basic (Declaration)
Public ReadOnly Property PrevSibling As XmlLightElement
C#
public XmlLightElement PrevSibling {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightDocument doc = new HtmlLightDocument(document);
Assert.IsNull(doc.PrevSibling);
Assert.IsNull(doc.Children[0].PrevSibling);
Assert.IsNull(doc.NextSibling);
Assert.IsNull(doc.Children[doc.Children.Count - 1].NextSibling);

XmlLightElement e = doc.SelectSingleNode("/html/body//*[@class='2']");
Assert.IsNotNull(e);
Assert.AreEqual("p", e.TagName);
Assert.IsNotNull(e.PrevSibling);
Assert.AreEqual("p", e.PrevSibling.TagName);

Assert.AreEqual("", e.Namespace);
Assert.AreEqual("p", e.LocalName);

e = new XmlLightElement(null, "a:b");
Assert.AreEqual("a", e.Namespace);
Assert.AreEqual("b", e.LocalName);
VB.NET Copy Code
Dim doc As XmlLightDocument = New HtmlLightDocument(document)
Assert.IsNull(doc.PrevSibling)
Assert.IsNull(doc.Children(0).PrevSibling)
Assert.IsNull(doc.NextSibling)
Assert.IsNull(doc.Children(doc.Children.Count - 1).NextSibling)

Dim e As XmlLightElement = doc.SelectSingleNode("/html/body//*[@class='2']")
Assert.IsNotNull(e)
Assert.AreEqual("p", e.TagName)
Assert.IsNotNull(e.PrevSibling)
Assert.AreEqual("p", e.PrevSibling.TagName)

Assert.AreEqual("", e.[Namespace])
Assert.AreEqual("p", e.LocalName)

e = New XmlLightElement(Nothing, "a:b")
Assert.AreEqual("a", e.[Namespace])
Assert.AreEqual("b", e.LocalName)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TagName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : TagName Property

Glossary Item Box

Returns the tag name of this html element

Syntax

Visual Basic (Declaration)
Public ReadOnly Property TagName As String
C#
public string TagName {get;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string notxml = "<html id=a ><body foo='bar' bar=\"foo\" />";

HtmlLightDocument html = new HtmlLightDocument();
XmlLightParser.Parse(notxml, html);
Assert.AreEqual("html", html.Root.TagName);
Assert.AreEqual(1, html.Root.Attributes.Count);
Assert.AreEqual("a", html.Root.Attributes["id"]);
Assert.AreEqual(1, html.Root.Children.Count);
Assert.AreEqual("body", html.Root.Children[0].TagName);
Assert.AreEqual("foo", html.Root.Children[0].Attributes["bar"]);
Assert.AreEqual("bar", html.Root.Children[0].Attributes["foo"]);

XmlLightDocument xml = new XmlLightDocument();
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml);
Assert.AreEqual(2, xml.Root.Attributes.Count);
//Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName);
Assert.AreEqual("foo", xml.Root.Attributes["bar"]);
Assert.AreEqual("bar", xml.Root.Attributes["foo"]);
VB.NET Copy Code
Dim notxml As String = "<html id=a ><body foo='bar' bar=""foo"" />"

Dim html As New HtmlLightDocument()
XmlLightParser.Parse(notxml, html)
Assert.AreEqual("html", html.Root.TagName)
Assert.AreEqual(1, html.Root.Attributes.Count)
Assert.AreEqual("a", html.Root.Attributes("id"))
Assert.AreEqual(1, html.Root.Children.Count)
Assert.AreEqual("body", html.Root.Children(0).TagName)
Assert.AreEqual("foo", html.Root.Children(0).Attributes("bar"))
Assert.AreEqual("bar", html.Root.Children(0).Attributes("foo"))

Dim xml As New XmlLightDocument()
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml)
Assert.AreEqual(2, xml.Root.Attributes.Count)
'Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName)
Assert.AreEqual("foo", xml.Root.Attributes("bar"))
Assert.AreEqual("bar", xml.Root.Attributes("foo"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)
XmlLightDocument.EndTag(XmlTagInfo)
XmlLightDocument.EndDocument()
HtmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.EndDocument()

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : Value Property

Glossary Item Box

Returns the value (if any) of this html element

Syntax

Visual Basic (Declaration)
Public Property Value As String
C#
public string Value {get; set;}

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
XmlLightElement Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightElement Class

Glossary Item Box

For a list of all members of this type, see XmlLightElement members.

Public Fields

 | Name | Description
Public Field | Attributes | Returns the attributes of this html element
static (Shared in Visual Basic) | CDATA | Provides tag name assigned to the CDATA nodes in the heirarchy
Public Field | Children | Returns the children of this html element
static (Shared in Visual Basic) | COMMENT | Provides tag name assigned to comment nodes in the heirarchy
static (Shared in Visual Basic) | CONTROL | Provides tag name assigned to the TEXT nodes in the heirarchy
static (Shared in Visual Basic) | PROCESSING | Provides tag name assigned to processing instruction nodes in the heirarchy
static (Shared in Visual Basic) | ROOT | Provides tag name assigned to the ROOT node of the heirarchy
static (Shared in Visual Basic) | TEXT | Provides tag name assigned to the TEXT nodes in the heirarchy
Top

See Also

Reference

XmlLightElement Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Attributes Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : Attributes Field

Glossary Item Box

Returns the attributes of this html element

Syntax

Visual Basic (Declaration)
Public ReadOnly Attributes As XmlLightAttributes
C#
public readonly XmlLightAttributes Attributes

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CDATA Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : CDATA Field

Glossary Item Box

Provides tag name assigned to the CDATA nodes in the heirarchy

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly CDATA As String
C#
public static readonly string CDATA

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightDocument.AddCData(String)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Children Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : Children Field

Glossary Item Box

Returns the children of this html element

Syntax

Visual Basic (Declaration)
Public ReadOnly Children As List(Of XmlLightElement)
C#
public readonly List<XmlLightElement> Children

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string notxml = "<html id=a ><body foo='bar' bar=\"foo\" />";

HtmlLightDocument html = new HtmlLightDocument();
XmlLightParser.Parse(notxml, html);
Assert.AreEqual("html", html.Root.TagName);
Assert.AreEqual(1, html.Root.Attributes.Count);
Assert.AreEqual("a", html.Root.Attributes["id"]);
Assert.AreEqual(1, html.Root.Children.Count);
Assert.AreEqual("body", html.Root.Children[0].TagName);
Assert.AreEqual("foo", html.Root.Children[0].Attributes["bar"]);
Assert.AreEqual("bar", html.Root.Children[0].Attributes["foo"]);

XmlLightDocument xml = new XmlLightDocument();
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml);
Assert.AreEqual(2, xml.Root.Attributes.Count);
//Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName);
Assert.AreEqual("foo", xml.Root.Attributes["bar"]);
Assert.AreEqual("bar", xml.Root.Attributes["foo"]);
VB.NET Copy Code
Dim notxml As String = "<html id=a ><body foo='bar' bar=""foo"" />"

Dim html As New HtmlLightDocument()
XmlLightParser.Parse(notxml, html)
Assert.AreEqual("html", html.Root.TagName)
Assert.AreEqual(1, html.Root.Attributes.Count)
Assert.AreEqual("a", html.Root.Attributes("id"))
Assert.AreEqual(1, html.Root.Children.Count)
Assert.AreEqual("body", html.Root.Children(0).TagName)
Assert.AreEqual("foo", html.Root.Children(0).Attributes("bar"))
Assert.AreEqual("bar", html.Root.Children(0).Attributes("foo"))

Dim xml As New XmlLightDocument()
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml)
Assert.AreEqual(2, xml.Root.Attributes.Count)
'Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName)
Assert.AreEqual("foo", xml.Root.Attributes("bar"))
Assert.AreEqual("bar", xml.Root.Attributes("foo"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.Remove()
XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)
XmlLightDocument.WriteXml(XmlWriter)
XmlLightDocument.WriteUnformatted(TextWriter)
XmlLightDocument.StartDocument()

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
COMMENT Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : COMMENT Field

Glossary Item Box

Provides tag name assigned to comment nodes in the heirarchy

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly COMMENT As String
C#
public static readonly string COMMENT

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightDocument.AddComment(String)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CONTROL Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : CONTROL Field

Glossary Item Box

Provides tag name assigned to the TEXT nodes in the heirarchy

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly CONTROL As String
C#
public static readonly string CONTROL

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs

Used By

XmlLightDocument.AddControl(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
PROCESSING Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : PROCESSING Field

Glossary Item Box

Provides tag name assigned to processing instruction nodes in the heirarchy

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly PROCESSING As String
C#
public static readonly string PROCESSING

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs

Used By

XmlLightDocument.AddInstruction(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
ROOT Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : ROOT Field

Glossary Item Box

Provides tag name assigned to the ROOT node of the heirarchy

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly ROOT As String
C#
public static readonly string ROOT

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TEXT Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : TEXT Field

Glossary Item Box

Provides tag name assigned to the TEXT nodes in the heirarchy

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly TEXT As String
C#
public static readonly string TEXT

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
XmlLightElement root = new XmlLightElement(null, "root");
new XmlLightElement(root, "a").Attributes["b"] = "c";
new XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text";
new XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->";
new XmlLightElement(root, XmlLightElement.CONTROL){
    OriginalTag = "<? Hey, that isn't valid !>"
}.Remove();

StringWriter sw = new StringWriter();
root.WriteUnformatted(sw);
Assert.AreEqual("<root><a b=\"c\"/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString());
VB.NET Copy Code
Dim root As New XmlLightElement(Nothing, "root")
New XmlLightElement(root, "a").Attributes("b") = "c"
New XmlLightElement(root, XmlLightElement.TEXT).Value = "Normal & <Encoded> Text"
New XmlLightElement(root, XmlLightElement.COMMENT).OriginalTag = "<!-- This is just a <simple> comment. -->"
New XmlLightElement(root, XmlLightElement.CONTROL) With { _
    Key .OriginalTag = "<? Hey, that isn't valid !>" _
}.Remove()

Dim sw As New StringWriter()
root.WriteUnformatted(sw)
Assert.AreEqual("<root><a b=""c""/>Normal &amp; &lt;Encoded&gt; Text<!-- This is just a <simple> comment. --></root>", sw.ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightDocument.AddText(String)

Source Code

Library/Html/XmlLightElement.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightParser Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightParser Class

Glossary Item Box

Provides a means by which you can cursur through xml/html documents and be notified for each tag/text/etc via implementing the IXmlLightReader interface.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class XmlLightParser
C#
public static class XmlLightParser

Inheritance Hierarchy

System.Object
CSharpTest.Net.Html.XmlLightParser

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightParser Members
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
XmlLightParser Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightParser Class

Glossary Item Box

The following tables list the members exposed by XmlLightParser.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Parse | Overloaded. Parses the provided xml/html document into discrete components and provides the information to the provided reader, see XmlLightDocument
static (Shared in Visual Basic) | ParseAttributes | Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">
static (Shared in Visual Basic) | ParseText | Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">
Top

See Also

Reference

XmlLightParser Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
XmlLightParser Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightParser Class

Glossary Item Box

For a list of all members of this type, see XmlLightParser members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Parse | Overloaded. Parses the provided xml/html document into discrete components and provides the information to the provided reader, see XmlLightDocument
static (Shared in Visual Basic) | ParseAttributes | Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">
static (Shared in Visual Basic) | ParseText | Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">
Top

See Also

Reference

XmlLightParser Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Parse Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class : Parse Method

Glossary Item Box

Parses the provided xml/html document into discrete components and provides the information to the provided reader, see XmlLightDocument

Overload List

Overload | Description
Parse(String,IXmlLightReader) | Parses the provided xml/html document into discrete components and provides the information to the provided reader, see XmlLightDocument
Parse(String,AttributeFormat,IXmlLightReader) | Parses the provided xml/html document into discrete components and provides the information to the provided reader, see XmlLightDocument
Parse(String,Regex,IXmlLightReader) | Parses the provided document into discrete components using the regex provided and provides the information to the provided reader, see XmlLightDocument

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightParser Class
XmlLightParser Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Parse(String,IXmlLightReader) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class > Parse Method : Parse(String,IXmlLightReader) Method

content
reader

Glossary Item Box

Parses the provided xml/html document into discrete components and provides the information to the provided reader, see XmlLightDocument

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Parse( _
   ByVal content As String, _
   ByVal reader As IXmlLightReader _
)
C#
public static void Parse(
   string content,
   IXmlLightReader reader
)

Parameters

content
reader

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string notxml = "<html id=a ><body foo='bar' bar=\"foo\" />";

HtmlLightDocument html = new HtmlLightDocument();
XmlLightParser.Parse(notxml, html);
Assert.AreEqual("html", html.Root.TagName);
Assert.AreEqual(1, html.Root.Attributes.Count);
Assert.AreEqual("a", html.Root.Attributes["id"]);
Assert.AreEqual(1, html.Root.Children.Count);
Assert.AreEqual("body", html.Root.Children[0].TagName);
Assert.AreEqual("foo", html.Root.Children[0].Attributes["bar"]);
Assert.AreEqual("bar", html.Root.Children[0].Attributes["foo"]);

XmlLightDocument xml = new XmlLightDocument();
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml);
Assert.AreEqual(2, xml.Root.Attributes.Count);
//Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName);
Assert.AreEqual("foo", xml.Root.Attributes["bar"]);
Assert.AreEqual("bar", xml.Root.Attributes["foo"]);
VB.NET Copy Code
Dim notxml As String = "<html id=a ><body foo='bar' bar=""foo"" />"

Dim html As New HtmlLightDocument()
XmlLightParser.Parse(notxml, html)
Assert.AreEqual("html", html.Root.TagName)
Assert.AreEqual(1, html.Root.Attributes.Count)
Assert.AreEqual("a", html.Root.Attributes("id"))
Assert.AreEqual(1, html.Root.Children.Count)
Assert.AreEqual("body", html.Root.Children(0).TagName)
Assert.AreEqual("foo", html.Root.Children(0).Attributes("bar"))
Assert.AreEqual("bar", html.Root.Children(0).Attributes("foo"))

Dim xml As New XmlLightDocument()
XmlLightParser.Parse(notxml, XmlLightParser.AttributeFormat.Xml, xml)
Assert.AreEqual(2, xml.Root.Attributes.Count)
'Not recognized: xml.Root.Attributes["id"]
Assert.AreEqual("body", xml.Root.TagName)
Assert.AreEqual("foo", xml.Root.Attributes("bar"))
Assert.AreEqual("bar", xml.Root.Attributes("foo"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightParser Class
XmlLightParser Members
Overload List
IXmlLightReader

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Parse(String,AttributeFormat,IXmlLightReader) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class > Parse Method : Parse(String,AttributeFormat,IXmlLightReader) Method

content
format
reader

Glossary Item Box

Parses the provided xml/html document into discrete components and provides the information to the provided reader, see XmlLightDocument

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Parse( _
   ByVal content As String, _
   ByVal format As XmlLightParser.AttributeFormat, _
   ByVal reader As IXmlLightReader _
)
C#
public static void Parse(
   string content,
   XmlLightParser.AttributeFormat format,
   IXmlLightReader reader
)

Parameters

content
format
reader

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string[] files = Directory.GetFiles(@"c:\temp\trash", "*.htm", SearchOption.AllDirectories);
System.Diagnostics.Stopwatch sw;

for (int i = 0; i < 10; i++)
{
    //HTML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new HtmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds);
    //XML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new XmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds);
    //Parse Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    IXmlLightReader rdr = new EmptyReader();
    foreach (string file in files)
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr);

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds);
    //Text Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        XmlLightParser.ParseText(File.ReadAllText(file));

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds);
}
VB.NET Copy Code
Dim files As String() = Directory.GetFiles("c:\temp\trash", "*.htm", SearchOption.AllDirectories)
Dim sw As System.Diagnostics.Stopwatch

Dim i As Integer = 0
While i < 10
    'HTML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New HtmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds)
    'XML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New XmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds)
    'Parse Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    Dim rdr As IXmlLightReader = New EmptyReader()
    For Each file As String In files
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr)
    Next

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds)
    'Text Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        XmlLightParser.ParseText(File.ReadAllText(file))
    Next

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightParser Class
XmlLightParser Members
Overload List
XmlLightParser.AttributeFormat
IXmlLightReader

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Parse(String,Regex,IXmlLightReader) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class > Parse Method : Parse(String,Regex,IXmlLightReader) Method

content
parserExp
reader

Glossary Item Box

Parses the provided document into discrete components using the regex provided and provides the information to the provided reader, see XmlLightDocument

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Parse( _
   ByVal content As String, _
   ByVal parserExp As Regex, _
   ByVal reader As IXmlLightReader _
)
C#
public static void Parse(
   string content,
   Regex parserExp,
   IXmlLightReader reader
)

Parameters

content
parserExp
reader

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightParser Class
XmlLightParser Members
Overload List
IXmlLightReader

Used By

XmlLightParser.Parse(String,IXmlLightReader)
XmlLightParser.Parse(String,XmlLightParser.AttributeFormat,IXmlLightReader)

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ParseAttributes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class : ParseAttributes Method

tagXml

Glossary Item Box

Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">

Syntax

Visual Basic (Declaration)
Public Shared Function ParseAttributes( _
   ByVal tagXml As String _
) As IEnumerable(Of XmlLightAttribute)
C#
public static IEnumerable<XmlLightAttribute> ParseAttributes(
   string tagXml
)

Parameters

tagXml

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
IEnumerator<XmlLightAttribute> en;
en = XmlLightParser.ParseAttributes("<tag a=\"1\" b='2' c=3 d e=>").GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("a", en.Current.Name);
Assert.AreEqual("1", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("b", en.Current.Name);
Assert.AreEqual("2", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("c", en.Current.Name);
Assert.AreEqual("3", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("d", en.Current.Name);
Assert.AreEqual(null, en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("e", en.Current.Name);
Assert.AreEqual("", en.Current.Value);
Assert.IsFalse(en.MoveNext());

en = XmlLightParser.ParseAttributes("<?xml version='1.0'?>").GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("version", en.Current.Name);
Assert.AreEqual("1.0", en.Current.Value);
Assert.IsFalse(en.MoveNext());
VB.NET Copy Code
Dim en As IEnumerator(Of XmlLightAttribute)
en = XmlLightParser.ParseAttributes("<tag a=""1"" b='2' c=3 d e=>").GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("a", en.Current.Name)
Assert.AreEqual("1", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("b", en.Current.Name)
Assert.AreEqual("2", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("c", en.Current.Name)
Assert.AreEqual("3", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("d", en.Current.Name)
Assert.AreEqual(Nothing, en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("e", en.Current.Name)
Assert.AreEqual("", en.Current.Value)
Assert.IsFalse(en.MoveNext())

en = XmlLightParser.ParseAttributes("<?xml version='1.0'?>").GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("version", en.Current.Name)
Assert.AreEqual("1.0", en.Current.Value)
Assert.IsFalse(en.MoveNext())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightParser Class
XmlLightParser Members

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ParseText(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class : ParseText(String) Method

content

Glossary Item Box

Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">

Syntax

Visual Basic (Declaration)
Public Shared Function ParseText( _
   ByVal content As String _
) As String
C#
public static string ParseText(
   string content
)

Parameters

content

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
string[] files = Directory.GetFiles(@"c:\temp\trash", "*.htm", SearchOption.AllDirectories);
System.Diagnostics.Stopwatch sw;

for (int i = 0; i < 10; i++)
{
    //HTML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new HtmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds);
    //XML Parser
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        new XmlLightDocument(File.ReadAllText(file));

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds);
    //Parse Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    IXmlLightReader rdr = new EmptyReader();
    foreach (string file in files)
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr);

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds);
    //Text Only
    sw = new System.Diagnostics.Stopwatch();
    sw.Start();

    foreach (string file in files)
        XmlLightParser.ParseText(File.ReadAllText(file));

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds);
}
VB.NET Copy Code
Dim files As String() = Directory.GetFiles("c:\temp\trash", "*.htm", SearchOption.AllDirectories)
Dim sw As System.Diagnostics.Stopwatch

Dim i As Integer = 0
While i < 10
    'HTML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New HtmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("HTML = {0}", sw.ElapsedMilliseconds)
    'XML Parser
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        New XmlLightDocument(File.ReadAllText(file))
    Next

    Console.WriteLine("XHTM = {0}", sw.ElapsedMilliseconds)
    'Parse Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    Dim rdr As IXmlLightReader = New EmptyReader()
    For Each file As String In files
        XmlLightParser.Parse(File.ReadAllText(file), XmlLightParser.AttributeFormat.Xml, rdr)
    Next

    Console.WriteLine("NDOM = {0}", sw.ElapsedMilliseconds)
    'Text Only
    sw = New System.Diagnostics.Stopwatch()
    sw.Start()

    For Each file As String In files
        XmlLightParser.ParseText(File.ReadAllText(file))
    Next

    Console.WriteLine("TEXT = {0}", sw.ElapsedMilliseconds)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightParser Class
XmlLightParser Members

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XhtmlDTDSpecification Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XhtmlDTDSpecification Enumeration

Glossary Item Box

Defines the required DTD specification

Syntax

Visual Basic (Declaration)
Public Enum XhtmlDTDSpecification
   Inherits System.Enum
C#
public enum XhtmlDTDSpecification : System.Enum

Members

Member | Description
Any | Allow any of the supported DTDs, but must be declared and compliant
None | Use DTD only if defined
XhtmlFrameset_10 | Use the XHTML 1.0 Transitional DTD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XhtmlStrict_10 | Use the XHTML 1.0 Transitional DTD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XhtmlTransitional_10 | Use the XHTML 1.0 Transitional DTD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Html.XhtmlDTDSpecification

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Html Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightParser.AttributeFormat Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightParser.AttributeFormat Enumeration

Glossary Item Box

Determines how strict attributes are treated durring parsing

Syntax

Visual Basic (Declaration)
Public Enum XmlLightParser.AttributeFormat
   Inherits System.Enum
C#
public enum XmlLightParser.AttributeFormat : System.Enum

Members

Member | Description
Html | allows non-value and unquoted attributes
Xml | requires attributes to have quoted values

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Html.XmlLightParser.AttributeFormat

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Html Namespace
XmlLightParser.Parse(String,XmlLightParser.AttributeFormat,IXmlLightReader)

Source Code

Library/Html/XmlLightParser.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlQuoteStyle Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlQuoteStyle Enumeration

Glossary Item Box

The quote used with an attribute value

Syntax

Visual Basic (Declaration)
Public Enum XmlQuoteStyle
   Inherits System.Enum
C#
public enum XmlQuoteStyle : System.Enum

Members

Member | Description
Double | The value was not quoted, name="value"
Missing | The value was not quoted, name=value
None | The value was not defined, no '=' sign
Single | The value was not quoted, name='value'

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Html.XmlQuoteStyle

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Html Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightAttribute Structure
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightAttribute Structure

Glossary Item Box

Represents a single attribute on an xml element

Syntax

Visual Basic (Declaration)
Public Structure XmlLightAttribute
   Inherits System.ValueType
C#
public struct XmlLightAttribute : System.ValueType

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Html.XmlLightAttribute

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Members
CSharpTest.Net.Html Namespace
XmlLightAttribute[] XmlLightAttributes.ToArray()

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
XmlLightAttribute Structure Members
See Also Fields Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightAttribute Structure

Glossary Item Box

The following tables list the members exposed by XmlLightAttribute.

Public Constructors

 | Name | Description
Public Constructor | XmlLightAttribute Constructor | XmlLightAttribute
Top

Public Fields

 | Name | Description
Public Field | Before | The white-space characters preceeding the attribute name
Public Field | Name | The full name of the attribute
Public Field | Ordinal | The offset of the attribute in the list
Public Field | Quote | The character used to quote the original value
Public Field | Value | The original encoded text value of the attribute
Top

Public Properties

 | Name | Description
Public Property | LocalName | Returns the name without the namespace prefix
Public Property | Namespace | Returns the namespace or empty string
Public Property | NamespaceOrNull | Returns the namespace or null
Top

See Also

Reference

XmlLightAttribute Structure
CSharpTest.Net.Html Namespace
XmlLightAttribute[] XmlLightAttributes.ToArray()

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightAttribute Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : XmlLightAttribute Constructor

name

Glossary Item Box

XmlLightAttribute

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal name As String _
)
C#
public XmlLightAttribute(
   string name
)

Parameters

name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
XmlLightAttribute Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightAttribute Structure

Glossary Item Box

For a list of all members of this type, see XmlLightAttribute members.

Public Properties

 | Name | Description
Public Property | LocalName | Returns the name without the namespace prefix
Public Property | Namespace | Returns the namespace or empty string
Public Property | NamespaceOrNull | Returns the namespace or null
Top

See Also

Reference

XmlLightAttribute Structure
CSharpTest.Net.Html Namespace
XmlLightAttribute[] XmlLightAttributes.ToArray()

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : LocalName Property

Glossary Item Box

Returns the name without the namespace prefix

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LocalName As String
C#
public string LocalName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Used By

XmlLightElement.WriteXml(XmlWriter)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Namespace Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : Namespace Property

Glossary Item Box

Returns the namespace or empty string

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Namespace As String
C#
public string Namespace {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Used By

XmlLightElement.WriteXml(XmlWriter)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NamespaceOrNull Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : NamespaceOrNull Property

Glossary Item Box

Returns the namespace or null

Syntax

Visual Basic (Declaration)
Public ReadOnly Property NamespaceOrNull As String
C#
public string NamespaceOrNull {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Used By

XmlLightElement.WriteXml(XmlWriter)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
XmlLightAttribute Structure Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightAttribute Structure

Glossary Item Box

For a list of all members of this type, see XmlLightAttribute members.

Public Fields

 | Name | Description
Public Field | Before | The white-space characters preceeding the attribute name
Public Field | Name | The full name of the attribute
Public Field | Ordinal | The offset of the attribute in the list
Public Field | Quote | The character used to quote the original value
Public Field | Value | The original encoded text value of the attribute
Top

See Also

Reference

XmlLightAttribute Structure
CSharpTest.Net.Html Namespace
XmlLightAttribute[] XmlLightAttributes.ToArray()

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Before Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : Before Field

Glossary Item Box

The white-space characters preceeding the attribute name

Syntax

Visual Basic (Declaration)
Public Before As String
C#
public string Before

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Used By

XmlLightElement.WriteUnformatted(TextWriter)


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : Name Field

Glossary Item Box

The full name of the attribute

Syntax

Visual Basic (Declaration)
Public Name As String
C#
public string Name

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
IEnumerator<XmlLightAttribute> en;
en = XmlLightParser.ParseAttributes("<tag a=\"1\" b='2' c=3 d e=>").GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("a", en.Current.Name);
Assert.AreEqual("1", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("b", en.Current.Name);
Assert.AreEqual("2", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("c", en.Current.Name);
Assert.AreEqual("3", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("d", en.Current.Name);
Assert.AreEqual(null, en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("e", en.Current.Name);
Assert.AreEqual("", en.Current.Value);
Assert.IsFalse(en.MoveNext());

en = XmlLightParser.ParseAttributes("<?xml version='1.0'?>").GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("version", en.Current.Name);
Assert.AreEqual("1.0", en.Current.Value);
Assert.IsFalse(en.MoveNext());
VB.NET Copy Code
Dim en As IEnumerator(Of XmlLightAttribute)
en = XmlLightParser.ParseAttributes("<tag a=""1"" b='2' c=3 d e=>").GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("a", en.Current.Name)
Assert.AreEqual("1", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("b", en.Current.Name)
Assert.AreEqual("2", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("c", en.Current.Name)
Assert.AreEqual("3", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("d", en.Current.Name)
Assert.AreEqual(Nothing, en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("e", en.Current.Name)
Assert.AreEqual("", en.Current.Value)
Assert.IsFalse(en.MoveNext())

en = XmlLightParser.ParseAttributes("<?xml version='1.0'?>").GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("version", en.Current.Name)
Assert.AreEqual("1.0", en.Current.Value)
Assert.IsFalse(en.MoveNext())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)
Boolean XmlLightAttributes.Remove(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
Ordinal Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : Ordinal Field

Glossary Item Box

The offset of the attribute in the list

Syntax

Visual Basic (Declaration)
Public Ordinal As Integer
C#
public int Ordinal

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Used By

Boolean XmlLightAttributes.Remove(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
Quote Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : Quote Field

Glossary Item Box

The character used to quote the original value

Syntax

Visual Basic (Declaration)
Public Quote As XmlQuoteStyle
C#
public XmlQuoteStyle Quote

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Used By

XmlLightElement.WriteUnformatted(TextWriter)


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightAttribute Structure : Value Field

Glossary Item Box

The original encoded text value of the attribute

Syntax

Visual Basic (Declaration)
Public Value As String
C#
public string Value

Example

Library/Library.Test/TestHtmlParser.cs

C# Copy Code
IEnumerator<XmlLightAttribute> en;
en = XmlLightParser.ParseAttributes("<tag a=\"1\" b='2' c=3 d e=>").GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("a", en.Current.Name);
Assert.AreEqual("1", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("b", en.Current.Name);
Assert.AreEqual("2", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("c", en.Current.Name);
Assert.AreEqual("3", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("d", en.Current.Name);
Assert.AreEqual(null, en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("e", en.Current.Name);
Assert.AreEqual("", en.Current.Value);
Assert.IsFalse(en.MoveNext());

en = XmlLightParser.ParseAttributes("<?xml version='1.0'?>").GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("version", en.Current.Name);
Assert.AreEqual("1.0", en.Current.Value);
Assert.IsFalse(en.MoveNext());
VB.NET Copy Code
Dim en As IEnumerator(Of XmlLightAttribute)
en = XmlLightParser.ParseAttributes("<tag a=""1"" b='2' c=3 d e=>").GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("a", en.Current.Name)
Assert.AreEqual("1", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("b", en.Current.Name)
Assert.AreEqual("2", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("c", en.Current.Name)
Assert.AreEqual("3", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("d", en.Current.Name)
Assert.AreEqual(Nothing, en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("e", en.Current.Name)
Assert.AreEqual("", en.Current.Value)
Assert.IsFalse(en.MoveNext())

en = XmlLightParser.ParseAttributes("<?xml version='1.0'?>").GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("version", en.Current.Name)
Assert.AreEqual("1.0", en.Current.Value)
Assert.IsFalse(en.MoveNext())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightAttribute Structure
XmlLightAttribute Members

Used By

XmlLightElement.WriteXml(XmlWriter)
XmlLightElement.WriteUnformatted(TextWriter)
Boolean XmlLightAttributes.TryGetValue(String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlTagInfo Structure
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlTagInfo Structure

Glossary Item Box

Wraps up the information about a tag start while parsing

Syntax

Visual Basic (Declaration)
Public Structure XmlTagInfo
   Inherits System.ValueType
C#
public struct XmlTagInfo : System.ValueType

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Html.XmlTagInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlTagInfo Members
CSharpTest.Net.Html Namespace
IXmlLightReader.StartTag(XmlTagInfo)
IXmlLightReader.EndTag(XmlTagInfo)
XmlLightDocument.StartTag(XmlTagInfo)
XmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
XmlTagInfo Structure Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlTagInfo Structure

Glossary Item Box

The following tables list the members exposed by XmlTagInfo.

Public Constructors

 | Name | Description
Public Constructor | XmlTagInfo Constructor | XmlTagInfo
Top

Public Fields

 | Name | Description
Public Field | Attributes | The name/value pair attributes
Public Field | EndingWhitespace | THe space preceeding the tag close '>'
Public Field | FullName | The full name token of the element 'ns:name'
Public Field | SelfClosed | True if the tag is self-closing/empty: <empty/>
Public Field | UnparsedTag | The complete tag in raw/unparsed form
Top

See Also

Reference

XmlTagInfo Structure
CSharpTest.Net.Html Namespace
IXmlLightReader.StartTag(XmlTagInfo)
IXmlLightReader.EndTag(XmlTagInfo)
XmlLightDocument.StartTag(XmlTagInfo)
XmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlTagInfo Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlTagInfo Structure : XmlTagInfo Constructor

name
closed

Glossary Item Box

XmlTagInfo

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal name As String, _
   ByVal closed As Boolean _
)
C#
public XmlTagInfo(
   string name,
   bool closed
)

Parameters

name
closed

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlTagInfo Structure
XmlTagInfo Members

Used By

HtmlLightDocument.StartTag(XmlTagInfo)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
XmlTagInfo Structure Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlTagInfo Structure

Glossary Item Box

For a list of all members of this type, see XmlTagInfo members.

Public Fields

 | Name | Description
Public Field | Attributes | The name/value pair attributes
Public Field | EndingWhitespace | THe space preceeding the tag close '>'
Public Field | FullName | The full name token of the element 'ns:name'
Public Field | SelfClosed | True if the tag is self-closing/empty: <empty/>
Public Field | UnparsedTag | The complete tag in raw/unparsed form
Top

See Also

Reference

XmlTagInfo Structure
CSharpTest.Net.Html Namespace
IXmlLightReader.StartTag(XmlTagInfo)
IXmlLightReader.EndTag(XmlTagInfo)
XmlLightDocument.StartTag(XmlTagInfo)
XmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)

Source Code

Library/Html/XmlLightInterfaces.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Attributes Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlTagInfo Structure : Attributes Field

Glossary Item Box

The name/value pair attributes

Syntax

Visual Basic (Declaration)
Public Attributes As IEnumerable(Of XmlLightAttribute)
C#
public IEnumerable<XmlLightAttribute> Attributes

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlTagInfo Structure
XmlTagInfo Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
EndingWhitespace Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlTagInfo Structure : EndingWhitespace Field

Glossary Item Box

THe space preceeding the tag close '>'

Syntax

Visual Basic (Declaration)
Public EndingWhitespace As String
C#
public string EndingWhitespace

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlTagInfo Structure
XmlTagInfo Members

Used By

XmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)
XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
FullName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlTagInfo Structure : FullName Field

Glossary Item Box

The full name token of the element 'ns:name'

Syntax

Visual Basic (Declaration)
Public FullName As String
C#
public string FullName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlTagInfo Structure
XmlTagInfo Members

Used By

XmlLightDocument.EndTag(XmlTagInfo)
HtmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.EndTag(XmlTagInfo)
XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
SelfClosed Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlTagInfo Structure : SelfClosed Field

Glossary Item Box

True if the tag is self-closing/empty: <empty/>

Syntax

Visual Basic (Declaration)
Public SelfClosed As Boolean
C#
public bool SelfClosed

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlTagInfo Structure
XmlTagInfo Members

Used By

XmlLightDocument.StartTag(XmlTagInfo)
HtmlLightDocument.StartTag(XmlTagInfo)
XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
UnparsedTag Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlTagInfo Structure : UnparsedTag Field

Glossary Item Box

The complete tag in raw/unparsed form

Syntax

Visual Basic (Declaration)
Public UnparsedTag As String
C#
public string UnparsedTag

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlTagInfo Structure
XmlTagInfo Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
IXmlLightReader Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : IXmlLightReader Interface

Glossary Item Box

Provides a means by which the XmlLightParser can inform you of the document elements encountered.

Syntax

Visual Basic (Declaration)
Public Interface IXmlLightReader
C#
public interface IXmlLightReader

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Members
CSharpTest.Net.Html Namespace
XmlLightParser.Parse(String,IXmlLightReader)
XmlLightParser.Parse(String,XmlLightParser.AttributeFormat,IXmlLightReader)
XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IXmlLightReader Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : IXmlLightReader Interface

Glossary Item Box

The following tables list the members exposed by IXmlLightReader.

Public Methods

 | Name | Description
Method | AddCData | Encountered cdata section in the document
Method | AddComment | Encountered comment in the document
Method | AddControl | Encountered control information <! ... > in the document
Method | AddInstruction | Encountered processing instruction <? ... ?> in the document
Method | AddText | Encountered text or whitespace in the document
Method | EndDocument | Ends the processing of an xml input
Method | EndTag | Ends the processing of an xml tag
Method | StartDocument | Begins the processing of an xml input
Method | StartTag | Begins the processing of an xml tag
Top

See Also

Reference

IXmlLightReader Interface
CSharpTest.Net.Html Namespace
XmlLightParser.Parse(String,IXmlLightReader)
XmlLightParser.Parse(String,XmlLightParser.AttributeFormat,IXmlLightReader)
XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IXmlLightReader Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : IXmlLightReader Interface

Glossary Item Box

For a list of all members of this type, see IXmlLightReader members.

Public Methods

 | Name | Description
Method | AddCData | Encountered cdata section in the document
Method | AddComment | Encountered comment in the document
Method | AddControl | Encountered control information <! ... > in the document
Method | AddInstruction | Encountered processing instruction <? ... ?> in the document
Method | AddText | Encountered text or whitespace in the document
Method | EndDocument | Ends the processing of an xml input
Method | EndTag | Ends the processing of an xml tag
Method | StartDocument | Begins the processing of an xml input
Method | StartTag | Begins the processing of an xml tag
Top

See Also

Reference

IXmlLightReader Interface
CSharpTest.Net.Html Namespace
XmlLightParser.Parse(String,IXmlLightReader)
XmlLightParser.Parse(String,XmlLightParser.AttributeFormat,IXmlLightReader)
XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddCData Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : AddCData Method

cdata

Glossary Item Box

Encountered cdata section in the document

Syntax

Visual Basic (Declaration)
Sub AddCData( _
   ByVal cdata As String _
)
C#
void AddCData(
   string cdata
)

Parameters

cdata

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddComment Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : AddComment Method

comment

Glossary Item Box

Encountered comment in the document

Syntax

Visual Basic (Declaration)
Sub AddComment( _
   ByVal comment As String _
)
C#
void AddComment(
   string comment
)

Parameters

comment

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddControl Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : AddControl Method

cdata

Glossary Item Box

Encountered control information <! ... > in the document

Syntax

Visual Basic (Declaration)
Sub AddControl( _
   ByVal cdata As String _
)
C#
void AddControl(
   string cdata
)

Parameters

cdata

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddInstruction Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : AddInstruction Method

instruction

Glossary Item Box

Encountered processing instruction <? ... ?> in the document

Syntax

Visual Basic (Declaration)
Sub AddInstruction( _
   ByVal instruction As String _
)
C#
void AddInstruction(
   string instruction
)

Parameters

instruction

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddText Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : AddText Method

content

Glossary Item Box

Encountered text or whitespace in the document

Syntax

Visual Basic (Declaration)
Sub AddText( _
   ByVal content As String _
)
C#
void AddText(
   string content
)

Parameters

content

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
EndDocument Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : EndDocument Method

Glossary Item Box

Ends the processing of an xml input

Syntax

Visual Basic (Declaration)
Sub EndDocument()
C#
void EndDocument()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
EndTag Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : EndTag Method

tag

Glossary Item Box

Ends the processing of an xml tag

Syntax

Visual Basic (Declaration)
Sub EndTag( _
   ByVal tag As XmlTagInfo _
)
C#
void EndTag(
   XmlTagInfo tag
)

Parameters

tag

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members
XmlTagInfo

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
StartDocument Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : StartDocument Method

Glossary Item Box

Begins the processing of an xml input

Syntax

Visual Basic (Declaration)
Sub StartDocument()
C#
void StartDocument()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
StartTag Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > IXmlLightReader Interface : StartTag Method

tag

Glossary Item Box

Begins the processing of an xml tag

Syntax

Visual Basic (Declaration)
Sub StartTag( _
   ByVal tag As XmlTagInfo _
)
C#
void StartTag(
   XmlTagInfo tag
)

Parameters

tag

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IXmlLightReader Interface
IXmlLightReader Members
XmlTagInfo

Used By

XmlLightParser.Parse(String,Regex,IXmlLightReader)


%%ItemTitle%%

CSharpTest.Net.Http Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Http Namespace

Glossary Item Box

Classes

 | Class | Description
Class | HttpContextEventArgs | The event type used for the processing event to access the HttpListenerContext and the HttpServer instance.
Class | HttpServer | Hosts an HttpListener on a dedicated set of worker threads, providing a clean shutdown on dispose.
Class | MimeMessagePart | A MessagePart is a part of an email message used to describe the whole email parse tree.
Class | MimeMultiPartData | Parses a raw HTML form where ContentType = "multipart/form-data", including one or more attachments. Caution advised as this is entirely in-memory for the moment and not a viable option for large files.

Enumerations

 | Enumeration | Description
Enumeration | ContentTransferEncoding | System.Enum that describes the ContentTransferEncoding header field

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpContextEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : HttpContextEventArgs Class

Glossary Item Box

The event type used for the processing event to access the HttpListenerContext and the HttpServer instance.

Object Model

HttpContextEventArgs ClassHttpServer Class

Syntax

Visual Basic (Declaration)
Public NotInheritable Class HttpContextEventArgs
   Inherits System.EventArgs
C#
public sealed class HttpContextEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Http.HttpContextEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpContextEventArgs Members
CSharpTest.Net.Http Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HttpContextEventArgs Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : HttpContextEventArgs Class

Glossary Item Box

The following tables list the members exposed by HttpContextEventArgs.

Public Properties

 | Name | Description
Public Property | Context | The HttpListenerContext for this request
Public Property | Host | The HttpServer recieving the request
Top

See Also

Reference

HttpContextEventArgs Class
CSharpTest.Net.Http Namespace


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HttpContextEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : HttpContextEventArgs Class

Glossary Item Box

For a list of all members of this type, see HttpContextEventArgs members.

Public Properties

 | Name | Description
Public Property | Context | The HttpListenerContext for this request
Public Property | Host | The HttpServer recieving the request
Top

See Also

Reference

HttpContextEventArgs Class
CSharpTest.Net.Http Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
Context Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpContextEventArgs Class : Context Property

Glossary Item Box

The HttpListenerContext for this request

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Context As HttpListenerContext
C#
public HttpListenerContext Context {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpContextEventArgs Class
HttpContextEventArgs Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Host Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpContextEventArgs Class : Host Property

Glossary Item Box

The HttpServer recieving the request

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Host As HttpServer
C#
public HttpServer Host {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpContextEventArgs Class
HttpContextEventArgs Members
HttpServer


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpServer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : HttpServer Class

Glossary Item Box

Hosts an HttpListener on a dedicated set of worker threads, providing a clean shutdown on dispose.

Syntax

Visual Basic (Declaration)
Public Class HttpServer
C#
public class HttpServer

Inheritance Hierarchy

System.Object
CSharpTest.Net.Http.HttpServer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Members
CSharpTest.Net.Http Namespace
HttpServer HttpContextEventArgs.Host

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
HttpServer Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : HttpServer Class

Glossary Item Box

The following tables list the members exposed by HttpServer.

Public Constructors

 | Name | Description
Public Constructor | HttpServer Constructor | Constructs the HttpServer with a fixed thread-pool size.
Top

Public Properties

 | Name | Description
Public Property | ApplicationPath | Returns the path being used to host this server instance, for example return "/root/" when prefixes = "http://*:8080/root"
static (Shared in Visual Basic) | Context | Returns a thread-static HttpListenerContext of the current http request, or null if there is none.
Public Property | ShutdownEvent | Exposes a WaitHandle that can be used to signal other threads that the HTTP server is shutting down.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Start | Starts the HttpServer listening on the prefixes supplied. use "http://+:80/" to match any host identifier not already mapped, or "http://*:80/" to match all host identifiers.
Public Method | Stop | Stops the HTTP server and all worker threads.
Top

Public Events

 | Name | Description
Public Event | OnError | Raised when an unhandled exception occurs, you can use HttpServer.Context to respond to the http client if needed.
Public Event | ProcessRequest | Performs the processing of the request on one of the worker threads
Top

See Also

Reference

HttpServer Class
CSharpTest.Net.Http Namespace
HttpServer HttpContextEventArgs.Host

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpServer Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : HttpServer Constructor

maxThreads

Glossary Item Box

Constructs the HttpServer with a fixed thread-pool size.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal maxThreads As Integer _
)
C#
public HttpServer(
   int maxThreads
)

Parameters

maxThreads

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Used By

CommandInterpreter.HostHttp(Int32,String,Boolean,Boolean)

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HttpServer Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : HttpServer Class

Glossary Item Box

For a list of all members of this type, see HttpServer members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Start | Starts the HttpServer listening on the prefixes supplied. use "http://+:80/" to match any host identifier not already mapped, or "http://*:80/" to match all host identifiers.
Public Method | Stop | Stops the HTTP server and all worker threads.
Top

See Also

Reference

HttpServer Class
CSharpTest.Net.Http Namespace
HttpServer HttpContextEventArgs.Host

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : Start Method

prefixes
see http://msdn.microsoft.com/en-us/library/system.net.httplistenerprefixcollection.add.aspx

Glossary Item Box

Starts the HttpServer listening on the prefixes supplied. use "http://+:80/" to match any host identifier not already mapped, or "http://*:80/" to match all host identifiers.

Syntax

Visual Basic (Declaration)
Public Sub Start( _
   ByVal prefixes() As String _
)
C#
public void Start(
   string[] prefixes
)

Parameters

prefixes
see http://msdn.microsoft.com/en-us/library/system.net.httplistenerprefixcollection.add.aspx

Exceptions

Exception | Description
System.ArgumentException | The exception that is thrown when one of the arguments provided to a method is not valid.
System.UnauthorizedAccessException | The exception that is thrown when the operating system denies access because of an I/O error or a specific type of security error.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Used By

CommandInterpreter.HostHttp(Int32,String,Boolean,Boolean)

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Stop Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : Stop Method

Glossary Item Box

Stops the HTTP server and all worker threads.

Syntax

Visual Basic (Declaration)
Public Sub Stop()
C#
public void Stop()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Used By

CommandInterpreter.HostHttp(Int32,String,Boolean,Boolean)
HttpServer.Dispose()

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HttpServer Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : HttpServer Class

Glossary Item Box

For a list of all members of this type, see HttpServer members.

Public Properties

 | Name | Description
Public Property | ApplicationPath | Returns the path being used to host this server instance, for example return "/root/" when prefixes = "http://*:8080/root"
static (Shared in Visual Basic) | Context | Returns a thread-static HttpListenerContext of the current http request, or null if there is none.
Public Property | ShutdownEvent | Exposes a WaitHandle that can be used to signal other threads that the HTTP server is shutting down.
Top

See Also

Reference

HttpServer Class
CSharpTest.Net.Http Namespace
HttpServer HttpContextEventArgs.Host

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ApplicationPath Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : ApplicationPath Property

Glossary Item Box

Returns the path being used to host this server instance, for example return "/root/" when prefixes = "http://*:8080/root"

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ApplicationPath As String
C#
public string ApplicationPath {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Used By

HttpServer.Start(String[])

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Context Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : Context Property

Glossary Item Box

Returns a thread-static HttpListenerContext of the current http request, or null if there is none.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Context As HttpListenerContext
C#
public static HttpListenerContext Context {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ShutdownEvent Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : ShutdownEvent Property

Glossary Item Box

Exposes a WaitHandle that can be used to signal other threads that the HTTP server is shutting down.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ShutdownEvent As WaitHandle
C#
public WaitHandle ShutdownEvent {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
HttpServer Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : HttpServer Class

Glossary Item Box

For a list of all members of this type, see HttpServer members.

Public Events

 | Name | Description
Public Event | OnError | Raised when an unhandled exception occurs, you can use HttpServer.Context to respond to the http client if needed.
Public Event | ProcessRequest | Performs the processing of the request on one of the worker threads
Top

See Also

Reference

HttpServer Class
CSharpTest.Net.Http Namespace
HttpServer HttpContextEventArgs.Host

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnError Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : OnError Event

Glossary Item Box

Raised when an unhandled exception occurs, you can use HttpServer.Context to respond to the http client if needed.

Syntax

Visual Basic (Declaration)
Public Event OnError As EventHandler(Of ErrorEventArgs)
C#
public event EventHandler<ErrorEventArgs> OnError

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessRequest Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > HttpServer Class : ProcessRequest Event

Glossary Item Box

Performs the processing of the request on one of the worker threads

Syntax

Visual Basic (Declaration)
Public Event ProcessRequest As EventHandler(Of HttpContextEventArgs)
C#
public event EventHandler<HttpContextEventArgs> ProcessRequest

Event Data

The event handler receives an argument of type HttpContextEventArgs containing data related to this event. The following HttpContextEventArgs properties provide information specific to this event.

Property | Description
Context | The HttpListenerContext for this request
Host | The HttpServer recieving the request

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

HttpServer Class
HttpServer Members

Used By

CommandInterpreter.HostHttp(Int32,String,Boolean,Boolean)

Source Code

Library/Http/HttpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MimeMessagePart Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : MimeMessagePart Class

Glossary Item Box

A MessagePart is a part of an email message used to describe the whole email parse tree.

Syntax

Visual Basic (Declaration)
Public NotInheritable Class MimeMessagePart
C#
public sealed class MimeMessagePart

Inheritance Hierarchy

System.Object
CSharpTest.Net.Http.MimeMessagePart

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Members
CSharpTest.Net.Http Namespace
Boolean MimeMultiPartData.TryGetMessagePart(String,MimeMessagePart)
MimeMessagePart MimeMultiPartData.Item

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
MimeMessagePart Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : MimeMessagePart Class

Glossary Item Box

The following tables list the members exposed by MimeMessagePart.

Public Properties

 | Name | Description
Public Property | Body | This is the parsed body of this MimeMessagePart. It is parsed in that way, if the body was ContentTransferEncoded, it has been decoded to the correct bytes. It will be a null reference (Nothing in Visual Basic) if this MimeMessagePart is a MultiPart message. Use IsMultiPart to check if this MimeMessagePart is a MultiPart message.
Public Property | BodyEncoding | This is the encoding used to parse the message body if the MimeMessagePart is not a MultiPart message. It is derived from the ContentType character set property.
Public Property | ContentDescription | A human readable description of the body a null reference (Nothing in Visual Basic) if no Content-Description header was present in the message.
Public Property | ContentDisposition | Used to describe if a MimeMessagePart is to be displayed or to be though of as an attachment. Also contains information about filename if such was sent. a null reference (Nothing in Visual Basic) if no Content-Disposition header field was present in the message
Public Property | ContentId | ID of the content part (like an attached image). Used with MultiPart messages. a null reference (Nothing in Visual Basic) if no Content-ID header field was present in the message.
Public Property | ContentTransferEncoding | This header describes the Content encoding during transfer. If no Content-Transfer-Encoding header was present in the message, it is set to the default of ContentTransferEncoding.SevenBit in accordance to the RFC.
Public Property | ContentType | The Content-Type header field. If not set, the ContentType is created by the default "text/plain; charset=us-ascii" which is defined in RFC 2045 section 5.2. If set, the default is overridden.
Public Property | FileName | Returns the ContentDisposition's FileName field, or Name if not present
Public Property | Headers | Returns the collection of headers for a message part
Public Property | IsAttachment | A MimeMessagePart is considered to be an attachment, if - it is not holding text and is not a MultiPart message or - it has a Content-Disposition header that says it is an attachment
Public Property | IsMultiPart | Describes if this MimeMessagePart is a MultiPart message The MimeMessagePart is a MultiPart message if the ContentType media type property starts with "multipart/"
Public Property | IsText | A MimeMessagePart is considered to be holding text in it's body if the MediaType starts either "text/" or is equal to "message/rfc822"
Public Property | MessageParts | If this MimeMessagePart is a MultiPart message, then this property has a list of each of the Multiple parts that the message consists of. It is a null reference (Nothing in Visual Basic) if it is not a MultiPart message. Use IsMultiPart to check if this MimeMessagePart is a MultiPart message.
Public Property | Name | Returns the ContentDisposition's Name field, or FileName if not present
Public Property | Text | Gets this MessagePart's Body as text, or null if the IsMultiPart property is true.
Top

See Also

Reference

MimeMessagePart Class
CSharpTest.Net.Http Namespace
Boolean MimeMultiPartData.TryGetMessagePart(String,MimeMessagePart)
MimeMessagePart MimeMultiPartData.Item

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
MimeMessagePart Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : MimeMessagePart Class

Glossary Item Box

For a list of all members of this type, see MimeMessagePart members.

Public Properties

 | Name | Description
Public Property | Body | This is the parsed body of this MimeMessagePart. It is parsed in that way, if the body was ContentTransferEncoded, it has been decoded to the correct bytes. It will be a null reference (Nothing in Visual Basic) if this MimeMessagePart is a MultiPart message. Use IsMultiPart to check if this MimeMessagePart is a MultiPart message.
Public Property | BodyEncoding | This is the encoding used to parse the message body if the MimeMessagePart is not a MultiPart message. It is derived from the ContentType character set property.
Public Property | ContentDescription | A human readable description of the body a null reference (Nothing in Visual Basic) if no Content-Description header was present in the message.
Public Property | ContentDisposition | Used to describe if a MimeMessagePart is to be displayed or to be though of as an attachment. Also contains information about filename if such was sent. a null reference (Nothing in Visual Basic) if no Content-Disposition header field was present in the message
Public Property | ContentId | ID of the content part (like an attached image). Used with MultiPart messages. a null reference (Nothing in Visual Basic) if no Content-ID header field was present in the message.
Public Property | ContentTransferEncoding | This header describes the Content encoding during transfer. If no Content-Transfer-Encoding header was present in the message, it is set to the default of ContentTransferEncoding.SevenBit in accordance to the RFC.
Public Property | ContentType | The Content-Type header field. If not set, the ContentType is created by the default "text/plain; charset=us-ascii" which is defined in RFC 2045 section 5.2. If set, the default is overridden.
Public Property | FileName | Returns the ContentDisposition's FileName field, or Name if not present
Public Property | Headers | Returns the collection of headers for a message part
Public Property | IsAttachment | A MimeMessagePart is considered to be an attachment, if - it is not holding text and is not a MultiPart message or - it has a Content-Disposition header that says it is an attachment
Public Property | IsMultiPart | Describes if this MimeMessagePart is a MultiPart message The MimeMessagePart is a MultiPart message if the ContentType media type property starts with "multipart/"
Public Property | IsText | A MimeMessagePart is considered to be holding text in it's body if the MediaType starts either "text/" or is equal to "message/rfc822"
Public Property | MessageParts | If this MimeMessagePart is a MultiPart message, then this property has a list of each of the Multiple parts that the message consists of. It is a null reference (Nothing in Visual Basic) if it is not a MultiPart message. Use IsMultiPart to check if this MimeMessagePart is a MultiPart message.
Public Property | Name | Returns the ContentDisposition's Name field, or FileName if not present
Public Property | Text | Gets this MessagePart's Body as text, or null if the IsMultiPart property is true.
Top

See Also

Reference

MimeMessagePart Class
CSharpTest.Net.Http Namespace
Boolean MimeMultiPartData.TryGetMessagePart(String,MimeMessagePart)
MimeMessagePart MimeMultiPartData.Item

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Body Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : Body Property

Glossary Item Box

This is the parsed body of this MimeMessagePart.
It is parsed in that way, if the body was ContentTransferEncoded, it has been decoded to the correct bytes.

It will be a null reference (Nothing in Visual Basic) if this MimeMessagePart is a MultiPart message.
Use IsMultiPart to check if this MimeMessagePart is a MultiPart message.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Body As Byte()
C#
public byte[] Body {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BodyEncoding Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : BodyEncoding Property

Glossary Item Box

This is the encoding used to parse the message body if the MimeMessagePart
is not a MultiPart message. It is derived from the ContentType character set property.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property BodyEncoding As Encoding
C#
public Encoding BodyEncoding {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentDescription Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : ContentDescription Property

Glossary Item Box

A human readable description of the body

a null reference (Nothing in Visual Basic) if no Content-Description header was present in the message.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContentDescription As String
C#
public string ContentDescription {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentDisposition Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : ContentDisposition Property

Glossary Item Box

Used to describe if a MimeMessagePart is to be displayed or to be though of as an attachment.
Also contains information about filename if such was sent.

a null reference (Nothing in Visual Basic) if no Content-Disposition header field was present in the message

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContentDisposition As ContentDisposition
C#
public ContentDisposition ContentDisposition {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentId Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : ContentId Property

Glossary Item Box

ID of the content part (like an attached image). Used with MultiPart messages.

a null reference (Nothing in Visual Basic) if no Content-ID header field was present in the message.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContentId As String
C#
public string ContentId {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentTransferEncoding Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : ContentTransferEncoding Property

Glossary Item Box

This header describes the Content encoding during transfer.

If no Content-Transfer-Encoding header was present in the message, it is set to the default of ContentTransferEncoding.SevenBit in accordance to the RFC.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContentTransferEncoding As ContentTransferEncoding
C#
public ContentTransferEncoding ContentTransferEncoding {get;}

Remarks

See RFC 2045 section 6 for details

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members
ContentTransferEncoding

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentType Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : ContentType Property

Glossary Item Box

The Content-Type header field.

If not set, the ContentType is created by the default "text/plain; charset=us-ascii" which is defined in RFC 2045 section 5.2.

If set, the default is overridden.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContentType As ContentType
C#
public ContentType ContentType {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Used By

ICollection MimeMultiPartData.GetAttachments()
Dictionary MimeMultiPartData.ToDictionary()

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : FileName Property

Glossary Item Box

Returns the ContentDisposition's FileName field, or Name if not present

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileName As String
C#
public string FileName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Used By

Boolean MimeMultiPartData.TryGetMessagePart(String,MimeMessagePart)
ICollection MimeMultiPartData.GetAttachments()
Dictionary MimeMultiPartData.ToDictionary()


%%PageItemTitle%%

[image]
CSharpTest.Net
Headers Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : Headers Property

Glossary Item Box

Returns the collection of headers for a message part

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Headers As NameValueCollection
C#
public NameValueCollection Headers {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsAttachment Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : IsAttachment Property

Glossary Item Box

A MimeMessagePart is considered to be an attachment, if
- it is not holding text and is not a MultiPart message
or
- it has a Content-Disposition header that says it is an attachment

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsAttachment As Boolean
C#
public bool IsAttachment {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsMultiPart Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : IsMultiPart Property

Glossary Item Box

Describes if this MimeMessagePart is a MultiPart message

The MimeMessagePart is a MultiPart message if the ContentType media type property starts with "multipart/"

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsMultiPart As Boolean
C#
public bool IsMultiPart {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Used By

ICollection MimeMultiPartData.GetAttachments()
Dictionary MimeMultiPartData.ToDictionary()

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsText Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : IsText Property

Glossary Item Box

A MimeMessagePart is considered to be holding text in it's body if the MediaType starts either "text/" or is equal to "message/rfc822"

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsText As Boolean
C#
public bool IsText {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MessageParts Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : MessageParts Property

Glossary Item Box

If this MimeMessagePart is a MultiPart message, then this property has a list of each of the Multiple parts that the message consists of.

It is a null reference (Nothing in Visual Basic) if it is not a MultiPart message.
Use IsMultiPart to check if this MimeMessagePart is a MultiPart message.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MessageParts As ICollection(Of MimeMessagePart)
C#
public ICollection<MimeMessagePart> MessageParts {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Used By

IEnumerator MimeMultiPartData.GetEnumerator()
Boolean MimeMultiPartData.TryGetMessagePart(String,MimeMessagePart)
ICollection MimeMultiPartData.GetAttachments()
Dictionary MimeMultiPartData.ToDictionary()

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : Name Property

Glossary Item Box

Returns the ContentDisposition's Name field, or FileName if not present

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Name As String
C#
public string Name {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Used By

Boolean MimeMultiPartData.TryGetMessagePart(String,MimeMessagePart)
ICollection MimeMultiPartData.GetAttachments()
Dictionary MimeMultiPartData.ToDictionary()

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Text Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMessagePart Class : Text Property

Glossary Item Box

Gets this MessagePart's Body as text, or null if the IsMultiPart property is true.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Text As String
C#
public string Text {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMessagePart Class
MimeMessagePart Members

Used By

Dictionary MimeMultiPartData.ToDictionary()

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MimeMultiPartData Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : MimeMultiPartData Class

Glossary Item Box

Parses a raw HTML form where ContentType = "multipart/form-data", including one or more attachments. Caution advised as this is entirely in-memory for the moment and not a viable option for large files.

Object Model

MimeMultiPartData ClassMimeMessagePart Class

Syntax

Visual Basic (Declaration)
Public NotInheritable Class MimeMultiPartData
C#
public sealed class MimeMultiPartData

Inheritance Hierarchy

System.Object
CSharpTest.Net.Http.MimeMultiPartData

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Members
CSharpTest.Net.Http Namespace

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
MimeMultiPartData Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : MimeMultiPartData Class

Glossary Item Box

The following tables list the members exposed by MimeMultiPartData.

Public Constructors

 | Name | Description
Public Constructor | MimeMultiPartData Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | ContentTransferEncoding | This header describes the Content encoding during transfer. If no Content-Transfer-Encoding header was present in the message, it is set to the default of ContentTransferEncoding.SevenBit in accordance to the RFC.
Public Property | ContentType | The Content-Type header field. If not set, the ContentType is created by the default "text/plain; charset=us-ascii" which is defined in RFC 2045 section 5.2.
Public Property | Count | Total number of message parts / Form data found.
Public Property | Headers | The headers originally provided.
Public Property | Item | Returns a element by name, or ArgumentOutOfRangeException
Public Property | Keys | Returns the unique names for all the message parts
Top

Public Methods

 | Name | Description
Public Method | GetAllPartsByName | Gets all parts for a given name, used in the case of multi-file upload controls.
Public Method | GetAttachments | Gets all the parts that are not of type "text/plain" and/or have a filename value set in content disposition.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | ToDictionary | Gets a dictionary of all name/value pairs of parts that have a content-type of "text/plain" and do not have a filename value set in content disposition.
Public Method | TryGetMessagePart | Returns true if the element was found and the out parameter messagePart set successfully
Top

See Also

Reference

MimeMultiPartData Class
CSharpTest.Net.Http Namespace

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MimeMultiPartData Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : MimeMultiPartData Constructor

Glossary Item Box

Overload List

Overload | Description
MimeMultiPartData Constructor(Stream,String) | Constructs the form data from the input stream and http "Content-Type" header.
MimeMultiPartData Constructor(Stream,NameValueCollection) | Constructs the form data from the input stream and the http headers.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members


%%PageItemTitle%%

[image]
CSharpTest.Net
MimeMultiPartData Constructor(Stream,String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class > MimeMultiPartData Constructor : MimeMultiPartData Constructor(Stream,String)

input
contentType

Glossary Item Box

Constructs the form data from the input stream and http "Content-Type" header.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal input As Stream, _
   ByVal contentType As String _
)
C#
public MimeMultiPartData(
   Stream input,
   string contentType
)

Parameters

input
contentType

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members
Overload List

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MimeMultiPartData Constructor(Stream,NameValueCollection)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class > MimeMultiPartData Constructor : MimeMultiPartData Constructor(Stream,NameValueCollection)

input
headers

Glossary Item Box

Constructs the form data from the input stream and the http headers.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal input As Stream, _
   ByVal headers As NameValueCollection _
)
C#
public MimeMultiPartData(
   Stream input,
   NameValueCollection headers
)

Parameters

input
headers

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members
Overload List

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
MimeMultiPartData Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : MimeMultiPartData Class

Glossary Item Box

For a list of all members of this type, see MimeMultiPartData members.

Public Methods

 | Name | Description
Public Method | GetAllPartsByName | Gets all parts for a given name, used in the case of multi-file upload controls.
Public Method | GetAttachments | Gets all the parts that are not of type "text/plain" and/or have a filename value set in content disposition.
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection.
Public Method | ToDictionary | Gets a dictionary of all name/value pairs of parts that have a content-type of "text/plain" and do not have a filename value set in content disposition.
Public Method | TryGetMessagePart | Returns true if the element was found and the out parameter messagePart set successfully
Top

See Also

Reference

MimeMultiPartData Class
CSharpTest.Net.Http Namespace

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetAllPartsByName Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : GetAllPartsByName Method

name

Glossary Item Box

Gets all parts for a given name, used in the case of multi-file upload controls.

Syntax

Visual Basic (Declaration)
Public Function GetAllPartsByName( _
   ByVal name As String _
) As IEnumerable(Of MimeMessagePart)
C#
public IEnumerable<MimeMessagePart> GetAllPartsByName(
   string name
)

Parameters

name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetAttachments Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : GetAttachments Method

Glossary Item Box

Gets all the parts that are not of type "text/plain" and/or have a filename value set in content disposition.

Syntax

Visual Basic (Declaration)
Public Function GetAttachments() As ICollection(Of MimeMessagePart)
C#
public ICollection<MimeMessagePart> GetAttachments()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of MimeMessagePart)
C#
public IEnumerator<MimeMessagePart> GetEnumerator()

Return Value

A IEnumerator that can be used to iterate through the collection.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToDictionary Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : ToDictionary Method

Glossary Item Box

Gets a dictionary of all name/value pairs of parts that have a content-type of "text/plain" and do not have a filename value set in content disposition.

Syntax

Visual Basic (Declaration)
Public Function ToDictionary() As Dictionary(Of String,String)
C#
public Dictionary<string,string> ToDictionary()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetMessagePart Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : TryGetMessagePart Method

name
messagePart

Glossary Item Box

Returns true if the element was found and the out parameter messagePart set successfully

Syntax

Visual Basic (Declaration)
Public Function TryGetMessagePart( _
   ByVal name As String, _
   ByRef messagePart As MimeMessagePart _
) As Boolean
C#
public bool TryGetMessagePart(
   string name,
   out MimeMessagePart messagePart
)

Parameters

name
messagePart

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members
MimeMessagePart

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
MimeMultiPartData Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : MimeMultiPartData Class

Glossary Item Box

For a list of all members of this type, see MimeMultiPartData members.

Public Properties

 | Name | Description
Public Property | ContentTransferEncoding | This header describes the Content encoding during transfer. If no Content-Transfer-Encoding header was present in the message, it is set to the default of ContentTransferEncoding.SevenBit in accordance to the RFC.
Public Property | ContentType | The Content-Type header field. If not set, the ContentType is created by the default "text/plain; charset=us-ascii" which is defined in RFC 2045 section 5.2.
Public Property | Count | Total number of message parts / Form data found.
Public Property | Headers | The headers originally provided.
Public Property | Item | Returns a element by name, or ArgumentOutOfRangeException
Public Property | Keys | Returns the unique names for all the message parts
Top

See Also

Reference

MimeMultiPartData Class
CSharpTest.Net.Http Namespace

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentTransferEncoding Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : ContentTransferEncoding Property

Glossary Item Box

This header describes the Content encoding during transfer.

If no Content-Transfer-Encoding header was present in the message, it is set to the default of ContentTransferEncoding.SevenBit in accordance to the RFC.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContentTransferEncoding As ContentTransferEncoding
C#
public ContentTransferEncoding ContentTransferEncoding {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members
ContentTransferEncoding

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentType Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : ContentType Property

Glossary Item Box

The Content-Type header field.

If not set, the ContentType is created by the default "text/plain; charset=us-ascii" which is defined in RFC 2045 section 5.2.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContentType As ContentType
C#
public ContentType ContentType {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : Count Property

Glossary Item Box

Total number of message parts / Form data found.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Headers Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : Headers Property

Glossary Item Box

The headers originally provided.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Headers As NameValueCollection
C#
public NameValueCollection Headers {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : Item Property

name

Glossary Item Box

Returns a element by name, or ArgumentOutOfRangeException

Syntax

Visual Basic (Declaration)
Public ReadOnly Default Property Item( _
   ByVal name As String _
) As MimeMessagePart
C#
public MimeMessagePart this[
   string name
]; {get;}

Parameters

name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members
MimeMessagePart

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace > MimeMultiPartData Class : Keys Property

Glossary Item Box

Returns the unique names for all the message parts

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As ICollection(Of String)
C#
public ICollection<string> Keys {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MimeMultiPartData Class
MimeMultiPartData Members

Source Code

Library/Http/MimeMessage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContentTransferEncoding Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Http Namespace : ContentTransferEncoding Enumeration

Glossary Item Box

System.Enum that describes the ContentTransferEncoding header field

Syntax

Visual Basic (Declaration)
Public Enum ContentTransferEncoding
   Inherits System.Enum
C#
public enum ContentTransferEncoding : System.Enum

Members

Member | Description
Base64 | Base64 Encoding
Binary | Binary Encoding
EightBit | 8 bit Encoding
QuotedPrintable | Quoted Printable Encoding
SevenBit | 7 bit Encoding

Remarks

See RFC 2045 section 6 for more details

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Http.ContentTransferEncoding

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Http Namespace
ContentTransferEncoding MimeMultiPartData.ContentTransferEncoding
ContentTransferEncoding MimeMessagePart.ContentTransferEncoding


%%ItemTitle%%

CSharpTest.Net.Interfaces Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Interfaces Namespace

Glossary Item Box

Classes

 | Class | Description
Class | DelegateFactory<T> | A factory that creates a new instance of an object each time Create() is called.
Class | InstanceFactory<T> | A factory that always returns the same instance of an object each time Create() is called.
Class | NewFactory<T> | A factory that creates a new instance of an object each time Create() is called.
Class | Singleton<T> | A static singleton and factory that uses a globally common instance.

Interfaces

 | Interface | Description
Interface | ICloneable<T> | Provides a strongly typed shallow copy of the current object
Interface | IFactory<T> | Generic factory for instances of type T
Interface | ITransactable | Supplies a common interface to transaction based objects

Delegates

 | Delegate | Description
Delegate | FactoryMethod<T> | A delegate that takes no arguemnts and returns a single value

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

T
[image]
CSharpTest.Net
DelegateFactory<T> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : DelegateFactory<T> Class

Glossary Item Box

A factory that creates a new instance of an object each time Create() is called.

Syntax

Visual Basic (Declaration)
Public Class DelegateFactory(Of T)
   Implements IFactory(Of T)
C#
public class DelegateFactory<T> : IFactory<T>

Type Parameters

T

Inheritance Hierarchy

System.Object
CSharpTest.Net.Interfaces.DelegateFactory<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DelegateFactory<T> Members
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DelegateFactory<T> Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : DelegateFactory<T> Class

Glossary Item Box

The following tables list the members exposed by DelegateFactory<T>.

Public Constructors

 | Name | Description
Public Constructor | DelegateFactory<T> Constructor | A factory that delegates instance creation
Top

Public Methods

 | Name | Description
Public Method | Create | Returns an instance of T
Top

See Also

Reference

DelegateFactory<T> Class
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DelegateFactory<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > DelegateFactory<T> Class : DelegateFactory<T> Constructor

method

Glossary Item Box

A factory that delegates instance creation

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal method As CSharpTest.Net.Interfaces.FactoryMethod(Of T) _
)
C#
public DelegateFactory<T>(
   CSharpTest.Net.Interfaces.FactoryMethod<T> method
)

Parameters

method

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DelegateFactory<T> Class
DelegateFactory<T> Members

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DelegateFactory<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : DelegateFactory<T> Class

Glossary Item Box

For a list of all members of this type, see DelegateFactory<T> members.

Public Methods

 | Name | Description
Public Method | Create | Returns an instance of T
Top

See Also

Reference

DelegateFactory<T> Class
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > DelegateFactory<T> Class : Create Method

Glossary Item Box

Returns an instance of T

Syntax

Visual Basic (Declaration)
Public Function Create() As T
C#
public T Create()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DelegateFactory<T> Class
DelegateFactory<T> Members

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
InstanceFactory<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : InstanceFactory<T> Class

Glossary Item Box

A factory that always returns the same instance of an object each time Create() is called.

Syntax

Visual Basic (Declaration)
Public Class InstanceFactory(Of T)
   Implements IFactory(Of T)
C#
public class InstanceFactory<T> : IFactory<T>

Type Parameters

T

Example

Library/Library.Test/TestFactories.cs

C# Copy Code
TestObject obj = new TestObject();
IFactory<TestObject> factory = new InstanceFactory<TestObject>(obj);
Assert.IsTrue(ReferenceEquals(obj, factory.Create()));
Assert.IsTrue(ReferenceEquals(factory.Create(), factory.Create()));
VB.NET Copy Code
Dim obj As New TestObject()
Dim factory As IFactory(Of TestObject) = New InstanceFactory(Of TestObject)(obj)
Assert.IsTrue(ReferenceEquals(obj, factory.Create()))
Assert.IsTrue(ReferenceEquals(factory.Create(), factory.Create()))

Inheritance Hierarchy

System.Object
CSharpTest.Net.Interfaces.InstanceFactory<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

InstanceFactory<T> Members
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
InstanceFactory<T> Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : InstanceFactory<T> Class

Glossary Item Box

The following tables list the members exposed by InstanceFactory<T>.

Public Constructors

 | Name | Description
Public Constructor | InstanceFactory<T> Constructor | Provide the instance of T
Top

Public Methods

 | Name | Description
Public Method | Create | Returns the instance of T given to the constructor
Top

See Also

Reference

InstanceFactory<T> Class
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InstanceFactory<T> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > InstanceFactory<T> Class : InstanceFactory<T> Constructor

instance

Glossary Item Box

Provide the instance of T

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal instance As T _
)
C#
public InstanceFactory<T>(
   T instance
)

Parameters

instance

Example

Library/Library.Test/TestFactories.cs

C# Copy Code
TestObject obj = new TestObject();
IFactory<TestObject> factory = new InstanceFactory<TestObject>(obj);
Assert.IsTrue(ReferenceEquals(obj, factory.Create()));
Assert.IsTrue(ReferenceEquals(factory.Create(), factory.Create()));
VB.NET Copy Code
Dim obj As New TestObject()
Dim factory As IFactory(Of TestObject) = New InstanceFactory(Of TestObject)(obj)
Assert.IsTrue(ReferenceEquals(obj, factory.Create()))
Assert.IsTrue(ReferenceEquals(factory.Create(), factory.Create()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

InstanceFactory<T> Class
InstanceFactory<T> Members

Used By

Boolean SecureTransfer.Client.Download(String,Stream)

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
InstanceFactory<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : InstanceFactory<T> Class

Glossary Item Box

For a list of all members of this type, see InstanceFactory<T> members.

Public Methods

 | Name | Description
Public Method | Create | Returns the instance of T given to the constructor
Top

See Also

Reference

InstanceFactory<T> Class
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > InstanceFactory<T> Class : Create Method

Glossary Item Box

Returns the instance of T given to the constructor

Syntax

Visual Basic (Declaration)
Public Function Create() As T
C#
public T Create()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

InstanceFactory<T> Class
InstanceFactory<T> Members

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
NewFactory<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : NewFactory<T> Class

Glossary Item Box

A factory that creates a new instance of an object each time Create() is called.

Syntax

Visual Basic (Declaration)
Public Class NewFactory(Of T As {New})
   Implements IFactory(Of T)
C#
public class NewFactory<T> : IFactory<T>
where T: new()

Type Parameters

T

Example

Library/Library.Test/TestFactories.cs

C# Copy Code
IFactory<TestObject> factory = new NewFactory<TestObject>();
Assert.IsFalse(ReferenceEquals(factory.Create(), factory.Create()));
VB.NET Copy Code
Dim factory As IFactory(Of TestObject) = New NewFactory(Of TestObject)()
Assert.IsFalse(ReferenceEquals(factory.Create(), factory.Create()))

Inheritance Hierarchy

System.Object
CSharpTest.Net.Interfaces.NewFactory<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

NewFactory<T> Members
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
NewFactory<T> Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : NewFactory<T> Class

Glossary Item Box

The following tables list the members exposed by NewFactory<T>.

Public Constructors

 | Name | Description
Public Constructor | NewFactory<T> Constructor |
Top

Public Methods

 | Name | Description
Public Method | Create | Returns a new instance of T
Top

See Also

Reference

NewFactory<T> Class
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NewFactory<T> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > NewFactory<T> Class : NewFactory<T> Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public NewFactory<T>()

Example

Library/Library.Test/TestFactories.cs

C# Copy Code
IFactory<TestObject> factory = new NewFactory<TestObject>();
Assert.IsFalse(ReferenceEquals(factory.Create(), factory.Create()));
VB.NET Copy Code
Dim factory As IFactory(Of TestObject) = New NewFactory(Of TestObject)()
Assert.IsFalse(ReferenceEquals(factory.Create(), factory.Create()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

NewFactory<T> Class
NewFactory<T> Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
NewFactory<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : NewFactory<T> Class

Glossary Item Box

For a list of all members of this type, see NewFactory<T> members.

Public Methods

 | Name | Description
Public Method | Create | Returns a new instance of T
Top

See Also

Reference

NewFactory<T> Class
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > NewFactory<T> Class : Create Method

Glossary Item Box

Returns a new instance of T

Syntax

Visual Basic (Declaration)
Public Function Create() As T
C#
public T Create()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

NewFactory<T> Class
NewFactory<T> Members

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Singleton<T> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : Singleton<T> Class

Glossary Item Box

A static singleton and factory that uses a globally common instance.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class Singleton(Of T As {New})
C#
public static class Singleton<T>
where T: new()

Type Parameters

T

Inheritance Hierarchy

System.Object
CSharpTest.Net.Interfaces.Singleton<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Singleton<T> Members
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Singleton<T> Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : Singleton<T> Class

Glossary Item Box

The following tables list the members exposed by Singleton<T>.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | Factory | Returns a factory that returns the singleton instance
static (Shared in Visual Basic) | Instance | Returns the singleton instance of T
Top

See Also

Reference

Singleton<T> Class
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Singleton<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : Singleton<T> Class

Glossary Item Box

For a list of all members of this type, see Singleton<T> members.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | Factory | Returns a factory that returns the singleton instance
static (Shared in Visual Basic) | Instance | Returns the singleton instance of T
Top

See Also

Reference

Singleton<T> Class
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Factory Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > Singleton<T> Class : Factory Property

Glossary Item Box

Returns a factory that returns the singleton instance

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Factory As IFactory(Of T)
C#
public static IFactory<T> Factory {get;}

Example

Library/Library.Test/TestFactories.cs

C# Copy Code
try
{
    GC.KeepAlive(Singleton<BadObject>.Instance);
    Assert.Fail();
}
catch(ApplicationException ae)
{
    Assert.AreEqual("BadObject", ae.GetBaseException().Message);
}
try
{
    Singleton<BadObject>.Factory.Create();
    Assert.Fail();
}
catch (ApplicationException ae)
{
    Assert.AreEqual("BadObject", ae.GetBaseException().Message);
}
VB.NET Copy Code
Try
    GC.KeepAlive(Singleton(Of BadObject).Instance)
    Assert.Fail()
Catch ae As ApplicationException
    Assert.AreEqual("BadObject", ae.GetBaseException().Message)
End Try
Try
    Singleton(Of BadObject).Factory.Create()
    Assert.Fail()
Catch ae As ApplicationException
    Assert.AreEqual("BadObject", ae.GetBaseException().Message)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Singleton<T> Class
Singleton<T> Members
IFactory

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Instance Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > Singleton<T> Class : Instance Property

Glossary Item Box

Returns the singleton instance of T

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Instance As T
C#
public static T Instance {get;}

Example

Library/Library.Test/TestFactories.cs

C# Copy Code
try
{
    GC.KeepAlive(Singleton<BadObject>.Instance);
    Assert.Fail();
}
catch(ApplicationException ae)
{
    Assert.AreEqual("BadObject", ae.GetBaseException().Message);
}
try
{
    Singleton<BadObject>.Factory.Create();
    Assert.Fail();
}
catch (ApplicationException ae)
{
    Assert.AreEqual("BadObject", ae.GetBaseException().Message);
}
VB.NET Copy Code
Try
    GC.KeepAlive(Singleton(Of BadObject).Instance)
    Assert.Fail()
Catch ae As ApplicationException
    Assert.AreEqual("BadObject", ae.GetBaseException().Message)
End Try
Try
    Singleton(Of BadObject).Factory.Create()
    Assert.Fail()
Catch ae As ApplicationException
    Assert.AreEqual("BadObject", ae.GetBaseException().Message)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Singleton<T> Class
Singleton<T> Members

Source Code

Library/Interfaces/DefaultFactories.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
ICloneable<T> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : ICloneable<T> Interface

Glossary Item Box

Provides a strongly typed shallow copy of the current object

Syntax

Visual Basic (Declaration)
Public Interface ICloneable(Of T As ICloneable(Of T))
C#
public interface ICloneable<T>
where T: ICloneable<T>

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICloneable<T> Members
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/ICloneable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ICloneable<T> Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : ICloneable<T> Interface

Glossary Item Box

The following tables list the members exposed by ICloneable<T>.

Public Methods

 | Name | Description
Method | Clone | Returns a shallow clone of this object.
Top

See Also

Reference

ICloneable<T> Interface
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/ICloneable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ICloneable<T> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : ICloneable<T> Interface

Glossary Item Box

For a list of all members of this type, see ICloneable<T> members.

Public Methods

 | Name | Description
Method | Clone | Returns a shallow clone of this object.
Top

See Also

Reference

ICloneable<T> Interface
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/ICloneable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > ICloneable<T> Interface : Clone Method

Glossary Item Box

Returns a shallow clone of this object.

Syntax

Visual Basic (Declaration)
Function Clone() As T
C#
T Clone()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ICloneable<T> Interface
ICloneable<T> Members

Source Code

Library/Interfaces/ICloneable.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
IFactory<T> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : IFactory<T> Interface

Glossary Item Box

Generic factory for instances of type T

Syntax

Visual Basic (Declaration)
Public Interface IFactory(Of T)
C#
public interface IFactory<T>

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IFactory<T> Members
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/IFactory.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IFactory<T> Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : IFactory<T> Interface

Glossary Item Box

The following tables list the members exposed by IFactory<T>.

Public Methods

 | Name | Description
Method | Create | Creates an instance of an object assignable to type T
Top

See Also

Reference

IFactory<T> Interface
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/IFactory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IFactory<T> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : IFactory<T> Interface

Glossary Item Box

For a list of all members of this type, see IFactory<T> members.

Public Methods

 | Name | Description
Method | Create | Creates an instance of an object assignable to type T
Top

See Also

Reference

IFactory<T> Interface
CSharpTest.Net.Interfaces Namespace

Source Code

Library/Interfaces/IFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > IFactory<T> Interface : Create Method

Glossary Item Box

Creates an instance of an object assignable to type T

Syntax

Visual Basic (Declaration)
Function Create() As T
C#
T Create()

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        Assert.IsTrue(stream.CanRead);
        Assert.IsTrue(stream.CanWrite);
        Assert.IsTrue(stream.CanSeek);
    }
    using (stream = ((IFactory<Stream>)cache).Create())
    {
        Assert.IsTrue(stream.CanRead);
        Assert.IsTrue(stream.CanWrite);
        Assert.IsTrue(stream.CanSeek);
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.IsTrue(stream.CanRead);
        Assert.IsFalse(stream.CanWrite);
        Assert.IsTrue(stream.CanSeek);
    }
    using (stream = cache.Open(FileAccess.Write))
    {
        Assert.IsFalse(stream.CanRead);
        Assert.IsTrue(stream.CanWrite);
        Assert.IsTrue(stream.CanSeek);
    }
}
VB.NET Copy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        Assert.IsTrue(stream.CanRead)
        Assert.IsTrue(stream.CanWrite)
        Assert.IsTrue(stream.CanSeek)
    End Using
    Using stream = (DirectCast(cache, IFactory(Of Stream))).Create()
        Assert.IsTrue(stream.CanRead)
        Assert.IsTrue(stream.CanWrite)
        Assert.IsTrue(stream.CanSeek)
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.IsTrue(stream.CanRead)
        Assert.IsFalse(stream.CanWrite)
        Assert.IsTrue(stream.CanSeek)
    End Using
    Using stream = cache.Open(FileAccess.Write)
        Assert.IsFalse(stream.CanRead)
        Assert.IsTrue(stream.CanWrite)
        Assert.IsTrue(stream.CanSeek)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IFactory<T> Interface
IFactory<T> Members

Used By

TestCollection.TestAddRemove()
TestCollection.TestAddReverseRemove()
TestCollection.TestClear()
TestCollection.TestContains()
TestCollection.TestCopyTo()
TestCollection.TestIsReadOnly()
TestCollection.TestGetEnumerator()
TestCollection.TestGetEnumerator2()
TestDictionary.TestAddRemoveByKey()
TestDictionary.TestKeys()
TestDictionary.TestValues()
Stream StreamCache.Open(FileAccess)
ILockStrategy LockCounterFactory.Create()

Source Code

Library/Interfaces/IFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ITransactable Interface
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : ITransactable Interface

Glossary Item Box

Supplies a common interface to transaction based objects

Syntax

Visual Basic (Declaration)
Public Interface ITransactable
C#
public interface ITransactable

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
SharedMemoryStream shared = new SharedMemoryStream();
FragmentedFile.CreateNew(shared, 512, 100, 2).Dispose();

using (FragmentedFile ff = new FragmentedFile(shared, 512, 100, 2))
{
    long id;
    byte[] bytes = MakeBytes(255);
    using (Stream write = ff.Create(out id))
    using (ITransactable trans = (ITransactable)write)
    {
        write.Write(bytes, 0, bytes.Length);
        trans.Commit();
        Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)));
        trans.Rollback();
    }

    AssertThrows<InvalidDataException>(delegate() { ff.Open(id, FileAccess.Read); });
}
VB.NET Copy Code
Dim [shared] As New SharedMemoryStream()
FragmentedFile.CreateNew([shared], 512, 100, 2).Dispose()

Using ff As New FragmentedFile([shared], 512, 100, 2)
    Dim id As Long
    Dim bytes As Byte() = MakeBytes(255)
    Using write As Stream = ff.Create(id)
        Using trans As ITransactable = DirectCast(write, ITransactable)
            write.Write(bytes, 0, bytes.Length)
            trans.Commit()
            Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)))
            trans.Rollback()
        End Using
    End Using

    AssertThrows(Of InvalidDataException)(Function() Do
        ff.Open(id, FileAccess.Read)
    End Function)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ITransactable Members
CSharpTest.Net.Interfaces Namespace

Used By

BPlusTree.Rollback()

Source Code

Library/Interfaces/ITransactable.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ITransactable Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : ITransactable Interface

Glossary Item Box

The following tables list the members exposed by ITransactable.

Public Methods

 | Name | Description
Method | Commit | Completes the operation
Method | Rollback | Aborts the operation and reverts pending changes
Top

See Also

Reference

ITransactable Interface
CSharpTest.Net.Interfaces Namespace

Used By

BPlusTree.Rollback()

Source Code

Library/Interfaces/ITransactable.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ITransactable Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : ITransactable Interface

Glossary Item Box

For a list of all members of this type, see ITransactable members.

Public Methods

 | Name | Description
Method | Commit | Completes the operation
Method | Rollback | Aborts the operation and reverts pending changes
Top

See Also

Reference

ITransactable Interface
CSharpTest.Net.Interfaces Namespace

Used By

BPlusTree.Rollback()

Source Code

Library/Interfaces/ITransactable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Commit Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > ITransactable Interface : Commit Method

Glossary Item Box

Completes the operation

Syntax

Visual Basic (Declaration)
Sub Commit()
C#
void Commit()

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
SharedMemoryStream shared = new SharedMemoryStream();
FragmentedFile.CreateNew(shared, 512, 100, 2).Dispose();

using (FragmentedFile ff = new FragmentedFile(shared, 512, 100, 2))
{
    long id;
    byte[] bytes = MakeBytes(255);
    using (Stream write = ff.Create(out id))
    using (ITransactable trans = (ITransactable)write)
    {
        write.Write(bytes, 0, bytes.Length);
        trans.Commit();
        Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)));
        trans.Rollback();
    }

    AssertThrows<InvalidDataException>(delegate() { ff.Open(id, FileAccess.Read); });
}
VB.NET Copy Code
Dim [shared] As New SharedMemoryStream()
FragmentedFile.CreateNew([shared], 512, 100, 2).Dispose()

Using ff As New FragmentedFile([shared], 512, 100, 2)
    Dim id As Long
    Dim bytes As Byte() = MakeBytes(255)
    Using write As Stream = ff.Create(id)
        Using trans As ITransactable = DirectCast(write, ITransactable)
            write.Write(bytes, 0, bytes.Length)
            trans.Commit()
            Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)))
            trans.Rollback()
        End Using
    End Using

    AssertThrows(Of InvalidDataException)(Function() Do
        ff.Open(id, FileAccess.Read)
    End Function)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ITransactable Interface
ITransactable Members

Source Code

Library/Interfaces/ITransactable.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Rollback Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace > ITransactable Interface : Rollback Method

Glossary Item Box

Aborts the operation and reverts pending changes

Syntax

Visual Basic (Declaration)
Sub Rollback()
C#
void Rollback()

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
SharedMemoryStream shared = new SharedMemoryStream();
FragmentedFile.CreateNew(shared, 512, 100, 2).Dispose();

using (FragmentedFile ff = new FragmentedFile(shared, 512, 100, 2))
{
    long id;
    byte[] bytes = MakeBytes(255);
    using (Stream write = ff.Create(out id))
    using (ITransactable trans = (ITransactable)write)
    {
        write.Write(bytes, 0, bytes.Length);
        trans.Commit();
        Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)));
        trans.Rollback();
    }

    AssertThrows<InvalidDataException>(delegate() { ff.Open(id, FileAccess.Read); });
}
VB.NET Copy Code
Dim [shared] As New SharedMemoryStream()
FragmentedFile.CreateNew([shared], 512, 100, 2).Dispose()

Using ff As New FragmentedFile([shared], 512, 100, 2)
    Dim id As Long
    Dim bytes As Byte() = MakeBytes(255)
    Using write As Stream = ff.Create(id)
        Using trans As ITransactable = DirectCast(write, ITransactable)
            write.Write(bytes, 0, bytes.Length)
            trans.Commit()
            Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)))
            trans.Rollback()
        End Using
    End Using

    AssertThrows(Of InvalidDataException)(Function() Do
        ff.Open(id, FileAccess.Read)
    End Function)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ITransactable Interface
ITransactable Members

Used By

BPlusTree.Rollback()

Source Code

Library/Interfaces/ITransactable.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
FactoryMethod<T> Delegate
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Interfaces Namespace : FactoryMethod<T> Delegate

Glossary Item Box

A delegate that takes no arguemnts and returns a single value

Syntax

Visual Basic (Declaration)
Public Delegate Function FactoryMethod(Of T)() As T
C#
public delegate T FactoryMethod<T>()

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FactoryMethod<T> Members
CSharpTest.Net.Interfaces Namespace


%%ItemTitle%%

CSharpTest.Net.IO Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.IO Namespace

Glossary Item Box

Classes

 | Class | Description
Class | AggregateStream | Provides a base-class that aggregates another stream object
Class | BackgroundWriter | Provides a single-threaded writer to a stream
Class | BaseStream | Provides a base-class for a stream object that is neither readable or writable
Class | ClampedStream | Provides a stream that clamps the usage of the input stream to a specific range, length or offset
Class | CombinedStream | Creates a single 'pseudo' stream out of multiple input streams
Class | DisposingStream | Servers a dual-role, it can prevent an aggregated stream from disposing, or it can manage other objects that need to be disposed when the stream is disposed.
Class | FileStreamFactory | Provides a default implementation of an IFactory for creating streams on a single file.
Class | FindFile | Provides an efficient file/directory enumeration that behaves several orders faster than Directory.GetXxxx() methods.
Class | FindFile.FileFoundEventArgs | Provides access to the file or folder information durring enumeration, DO NOT keep a reference to this class as it's meaning will change durring enumeration.
Class | FragmentedFile | Provides a means of storing multitudes of small files inside one big one. I doubt this is a good name for it, but it works. Anyway, the file is broken into fixed size blocks and each block can be chained to another to allow the sub-allocation to grow larger than the block size. This is the primary storage vehicle for the BPlusTree implementation.
Class | IOStream | A collection of Stream helpers
Class | MarshallingStream | A stream that marshals bytes from unmanaged memory
Class | NonClosingStream | Provides a stream wrapper that will not close/dispose the underlying stream
Class | ReplaceFile | Creates a temp file based on the given file being replaced and when a call to Commit() is made the target file is replaced with the current contents of the temporary file. Use the TransactFile if you MUST be certain to succeed then Commit(), otherwise this implementation provides a 'good-enough' transaction and is optimized for larger files.
Class | SegmentedMemoryStream | Creates a stream over an array of byte arrays in memory to reduce use of the LOH and array resizing operation.
Class | SharedMemoryStream | A memory stream that can be cloned to create an instance for another thread to access the same memory pool.
Class | StreamCache | Provides a simple means of caching several streams on a single file and for a thread to quickly exclusive access to one of those streams. This class provides the base implementation used by FileStreamCache and FragmentedFile.
Class | TcpClientEventArgs | Provides a buffered state of the client connection
Class | TcpServer | Hosts an TcpListener on a dedicated set of worker threads, providing a clean shutdown on dispose.
Class | TempDirectory | Provides a class for managing a temporary directory and making reasonable a attempt to remove it upon disposal.
Class | TempFile | Provides a class for managing a temporary file and making reasonable a attempt to remove it upon disposal.
Class | TransactedCompoundFile | Similar behavior to the FragmentedFile; however, a much improved implementation. Allows for file-level commit/rollback or write-by-write commits to disk. By default provides data-protection against process-crashes but not OS crashes. Use FileOptions.WriteThrough to protect against OS crashes and power outtages.
Class | TransactedCompoundFile.Options | Advanced Options used to construct a TransactedCompoundFile
Class | TransactFile | Creates a temp file based on the given file being replaced and when a call to Commit() is made the target file is replaced with the current contents of the temporary file.

Structures

 | Structure | Description
Structure | Crc32 | Provides a simple CRC32 checksum for a set of bytes
Structure | Crc64 | Provides a simple CRC64 checksum for a set of bytes using algorithm (CRC-64/XZ)
Structure | FindFile.Info | Provides a simple struct to capture file info, given by FindFile.FileFoundEventArgs.GetInfo method

Enumerations

 | Enumeration | Description
Enumeration | TransactedCompoundFile.LoadingRule | Defines the loading rule to apply when using a transacted file that was interrupted durring the commit process.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
AggregateStream Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : AggregateStream Class

Glossary Item Box

Provides a base-class that aggregates another stream object

Syntax

Visual Basic (Declaration)
Public MustInherit Class AggregateStream
   Inherits System.IO.Stream
C#
public abstract class AggregateStream : System.IO.Stream

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.AggregateStream
CSharpTest.Net.Crypto.HashStream
CSharpTest.Net.IO.DisposingStream
CSharpTest.Net.IO.NonClosingStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AggregateStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : AggregateStream Class

Glossary Item Box

The following tables list the members exposed by AggregateStream.

Protected Constructors

 | Name | Description
Protected Constructor | AggregateStream Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Protected Properties

 | Name | Description
Protected Property | Stream | Allows modifying the underlying stream
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Overridden. Disposes of this.Stream
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes of this.Stream
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | Overridden. When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | Overridden. When overridden in a derived class, sets the length of the current stream.
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

AggregateStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AggregateStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : AggregateStream Constructor

Glossary Item Box

Overload List

Overload | Description
AggregateStream Constructor() | Creates the wrapper without an underlying stream
AggregateStream Constructor(Stream) | Creates the wrapper with the underlying stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AggregateStream Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class > AggregateStream Constructor : AggregateStream Constructor()

Glossary Item Box

Creates the wrapper without an underlying stream

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected AggregateStream()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
AggregateStream Constructor(Stream)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class > AggregateStream Constructor : AggregateStream Constructor(Stream)

io

Glossary Item Box

Creates the wrapper with the underlying stream

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal io As Stream _
)
C#
protected AggregateStream(
   Stream io
)

Parameters

io

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Overload List


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AggregateStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : AggregateStream Class

Glossary Item Box

For a list of all members of this type, see AggregateStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Overridden. Disposes of this.Stream
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes of this.Stream
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | Overridden. When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | Overridden. When overridden in a derived class, sets the length of the current stream.
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

AggregateStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Close Method

Glossary Item Box

Disposes of this.Stream

Syntax

Visual Basic (Declaration)
Public Overrides Sub Close()
C#
public override void Close()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in Close

Source Code

Library/IO/AggregateStream.cs

Used By

Hash HashStream.Close()
NonClosingStream.Close()


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Dispose Method

Glossary Item Box

Disposes of this.Stream

Overload List

Overload | Description
Dispose(Boolean) | Disposes of this.Stream
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of this.Stream

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Flush Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Flush Method

Glossary Item Box

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Flush()
C#
public override void Flush()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in Flush

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Read Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Syntax

Visual Basic (Declaration)
Public Overrides Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int Read(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in Read

Source Code

Library/IO/AggregateStream.cs

Used By

Int32 HashStream.Read(Byte[],Int32,Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : ReadByte Method

Glossary Item Box

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function ReadByte() As Integer
C#
public override int ReadByte()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in ReadByte

Source Code

Library/IO/AggregateStream.cs

Used By

Int32 HashStream.ReadByte()


%%PageItemTitle%%

[image]
CSharpTest.Net
Seek Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Seek Method

offset
origin

Glossary Item Box

When overridden in a derived class, sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function Seek( _
   ByVal offset As Long, _
   ByVal origin As SeekOrigin _
) As Long
C#
public override long Seek(
   long offset,
   SeekOrigin origin
)

Parameters

offset
origin

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in Seek

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetLength Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : SetLength Method

value

Glossary Item Box

When overridden in a derived class, sets the length of the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Sub SetLength( _
   ByVal value As Long _
)
C#
public override void SetLength(
   long value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in SetLength

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Write Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
)
C#
public override void Write(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in Write

Source Code

Library/IO/AggregateStream.cs

Used By

HashStream.Write(Byte[],Int32,Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : WriteByte Method

value

Glossary Item Box

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Syntax

Visual Basic (Declaration)
Public Overrides Sub WriteByte( _
   ByVal value As Byte _
)
C#
public override void WriteByte(
   byte value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in WriteByte

Source Code

Library/IO/AggregateStream.cs

Used By

HashStream.WriteByte(Byte)


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
AggregateStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : AggregateStream Class

Glossary Item Box

For a list of all members of this type, see AggregateStream members.

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Protected Properties

 | Name | Description
Protected Property | Stream | Allows modifying the underlying stream
Top

See Also

Reference

AggregateStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanRead Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : CanRead Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanRead As Boolean
C#
public override bool CanRead {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in CanRead

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanSeek Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : CanSeek Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanSeek As Boolean
C#
public override bool CanSeek {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in CanSeek

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanWrite Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : CanWrite Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanWrite As Boolean
C#
public override bool CanWrite {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in CanWrite

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Length Property

Glossary Item Box

When overridden in a derived class, gets the length in bytes of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property Length As Long
C#
public override long Length {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in Length

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Position Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Position Property

Glossary Item Box

When overridden in a derived class, gets or sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Property Position As Long
C#
public override long Position {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members
Base Implementation in Position

Source Code

Library/IO/AggregateStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Stream Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > AggregateStream Class : Stream Property

Glossary Item Box

Allows modifying the underlying stream

Syntax

Visual Basic (Declaration)
Protected Overridable Property Stream As Stream
C#
protected virtual Stream Stream {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AggregateStream Class
AggregateStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BackgroundWriter Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : BackgroundWriter Class

Glossary Item Box

Provides a single-threaded writer to a stream

Syntax

Visual Basic (Declaration)
Public Class BackgroundWriter
   Inherits CSharpTest.Net.Bases.Disposable
C#
public class BackgroundWriter : CSharpTest.Net.Bases.Disposable

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io, false))
{
    wtr.Dispose();
    Assert.IsFalse(io.Disposed);
    io.Write(new byte[1], 0, 1);
}
VB.NET Copy Code
Using io As New TestStream()
    Using wtr As New BackgroundWriter(io, False)
        wtr.Dispose()
        Assert.IsFalse(io.Disposed)
        io.Write(New Byte(1) {}, 0, 1)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Disposable
CSharpTest.Net.IO.BackgroundWriter

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BackgroundWriter Class Members
See Also Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : BackgroundWriter Class

Glossary Item Box

The following tables list the members exposed by BackgroundWriter.

Public Constructors

 | Name | Description
Public Constructor | BackgroundWriter Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | BeginFlush | Enqueues a flush command and returns immediately
Public Method | Close | Stops the worker thread after completing the pending writes.
Public Method | Dispose | Overloaded. Overridden. Closes the worker thread
Public Method | Flush | Waits for all pending writes and flushes the stream prior to returning
Public Method | Perform | Overloaded. Perform an action on the worker thread with the stream
Public Method | Read | Returns a number of bytes up to length that is pending a write at the position specified and copies those bytes into buffer the offset provided.
Public Method | Write | Overloaded. Write a series of bytes to the stream at the current position
Top

Protected Methods

 | Name | Description
Protected Method | Assert | Raises the ObjectDisposedException if this object has already been disposed (Inherited from CSharpTest.Net.Bases.Disposable)
Top

Public Events

 | Name | Description
Public Event | Disposed | Raised when the object is disposed (Inherited from CSharpTest.Net.Bases.Disposable)
Top

See Also

Reference

BackgroundWriter Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BackgroundWriter Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class : BackgroundWriter Constructor

Glossary Item Box

Overload List

Overload | Description
BackgroundWriter Constructor(Stream) | Create the writer and thread
BackgroundWriter Constructor(Stream,Boolean) | Create the writer and thread

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
BackgroundWriter Constructor(Stream)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > BackgroundWriter Constructor : BackgroundWriter Constructor(Stream)

stream

Glossary Item Box

Create the writer and thread

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream _
)
C#
public BackgroundWriter(
   Stream stream
)

Parameters

stream

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (ManualResetEvent mre = new ManualResetEvent(false))
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Perform(s => s.Write(new byte[100], 0, 100), mre);
    Assert.IsTrue(mre.WaitOne(60000, false));
    Assert.AreEqual(100, io.Position);
    Assert.AreEqual(100, io.Length);
}
VB.NET Copy Code
Using mre As New ManualResetEvent(False)
    Using io As New TestStream()
        Using wtr As New BackgroundWriter(io)
            wtr.Perform(Function(s) s.Write(New Byte(100) {}, 0, 100), mre)
            Assert.IsTrue(mre.WaitOne(60000, False))
            Assert.AreEqual(100, io.Position)
            Assert.AreEqual(100, io.Length)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BackgroundWriter Constructor(Stream,Boolean)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > BackgroundWriter Constructor : BackgroundWriter Constructor(Stream,Boolean)

stream
closeStream

Glossary Item Box

Create the writer and thread

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream, _
   ByVal closeStream As Boolean _
)
C#
public BackgroundWriter(
   Stream stream,
   bool closeStream
)

Parameters

stream
closeStream

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io, false))
{
    wtr.Dispose();
    Assert.IsFalse(io.Disposed);
    io.Write(new byte[1], 0, 1);
}
VB.NET Copy Code
Using io As New TestStream()
    Using wtr As New BackgroundWriter(io, False)
        wtr.Dispose()
        Assert.IsFalse(io.Disposed)
        io.Write(New Byte(1) {}, 0, 1)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BackgroundWriter Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : BackgroundWriter Class

Glossary Item Box

For a list of all members of this type, see BackgroundWriter members.

Public Methods

 | Name | Description
Public Method | BeginFlush | Enqueues a flush command and returns immediately
Public Method | Close | Stops the worker thread after completing the pending writes.
Public Method | Dispose | Overloaded. Overridden. Closes the worker thread
Public Method | Flush | Waits for all pending writes and flushes the stream prior to returning
Public Method | Perform | Overloaded. Perform an action on the worker thread with the stream
Public Method | Read | Returns a number of bytes up to length that is pending a write at the position specified and copies those bytes into buffer the offset provided.
Public Method | Write | Overloaded. Write a series of bytes to the stream at the current position
Top

Protected Methods

 | Name | Description
Protected Method | Assert | Raises the ObjectDisposedException if this object has already been disposed (Inherited from CSharpTest.Net.Bases.Disposable)
Top

See Also

Reference

BackgroundWriter Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BeginFlush Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class : BeginFlush Method

Glossary Item Box

Enqueues a flush command and returns immediately

Syntax

Visual Basic (Declaration)
Public Sub BeginFlush()
C#
public void BeginFlush()

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (ManualResetEvent mre = new ManualResetEvent(false))
using (TempFile temp = new TempFile())
using (TestStream io = new TestStream(temp.Open()))
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    const int sz = 1000;
    const int iter = 10000;
    var bytes = new byte[sz];
    for (int i = 0; i < iter; i++)
        wtr.Write(bytes, 0, sz);
    wtr.BeginFlush();
    Assert.IsFalse(io.Flushed);

    wtr.Perform(s => mre.Set());
    Assert.IsTrue(mre.WaitOne(60000, false));

    Assert.IsTrue(io.Flushed);
    Assert.AreEqual(sz * iter, io.Position);
    Assert.AreEqual(sz * iter, io.Length);
}
VB.NET Copy Code
Using mre As New ManualResetEvent(False)
    Using temp As New TempFile()
        Using io As New TestStream(temp.Open())
            Using wtr As New BackgroundWriter(io)
                Const  sz As Integer = 1000
                Const  iter As Integer = 10000
                Dim bytes As var = New Byte(sz) {}
                Dim i As Integer = 0
                While i < iter
                    wtr.Write(bytes, 0, sz)
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While
                wtr.BeginFlush()
                Assert.IsFalse(io.Flushed)

                wtr.Perform(Function(s) mre.[Set]())
                Assert.IsTrue(mre.WaitOne(60000, False))

                Assert.IsTrue(io.Flushed)
                Assert.AreEqual(sz * iter, io.Position)
                Assert.AreEqual(sz * iter, io.Length)
            End Using
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class : Close Method

Glossary Item Box

Stops the worker thread after completing the pending writes.

Syntax

Visual Basic (Declaration)
Public Sub Close()
C#
public void Close()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class : Dispose Method

Glossary Item Box

Closes the worker thread

Overload List

Overload | Description
Dispose(Boolean) | Closes the worker thread
Dispose() | disposes of the object if it has not already been disposed (Inherited from CSharpTest.Net.Bases.Disposable)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Closes the worker thread

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Flush Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class : Flush Method

Glossary Item Box

Waits for all pending writes and flushes the stream prior to returning

Syntax

Visual Basic (Declaration)
Public Sub Flush()
C#
public void Flush()

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Perform(s => s.Write(new byte[100], 0, 100));
    wtr.Flush();
    Assert.AreEqual(100, io.Position);
    Assert.AreEqual(100, io.Length);
}
VB.NET Copy Code
Using io As New TestStream()
    Using wtr As New BackgroundWriter(io)
        wtr.Perform(Function(s) s.Write(New Byte(100) {}, 0, 100))
        wtr.Flush()
        Assert.AreEqual(100, io.Position)
        Assert.AreEqual(100, io.Length)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Perform Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class : Perform Method

Glossary Item Box

Perform an action on the worker thread with the stream

Overload List

Overload | Description
Perform(Action<Stream>) | Perform an action on the worker thread with the stream
Perform(Action<Stream>,EventWaitHandle) | Perform an action on the worker thread with the stream and sets the signal

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Perform(Action<Stream>) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > Perform Method : Perform(Action<Stream>) Method

ioAction

Glossary Item Box

Perform an action on the worker thread with the stream

Syntax

Visual Basic (Declaration)
Public Overloads Sub Perform( _
   ByVal ioAction As Action(Of Stream) _
)
C#
public void Perform(
   Action<Stream> ioAction
)

Parameters

ioAction

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Perform(s => s.Write(new byte[100], 0, 100));
    wtr.Flush();
    Assert.AreEqual(100, io.Position);
    Assert.AreEqual(100, io.Length);
}
VB.NET Copy Code
Using io As New TestStream()
    Using wtr As New BackgroundWriter(io)
        wtr.Perform(Function(s) s.Write(New Byte(100) {}, 0, 100))
        wtr.Flush()
        Assert.AreEqual(100, io.Position)
        Assert.AreEqual(100, io.Length)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List

Used By

BackgroundWriter.BeginFlush()

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Perform(Action<Stream>,EventWaitHandle) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > Perform Method : Perform(Action<Stream>,EventWaitHandle) Method

ioAction
signal

Glossary Item Box

Perform an action on the worker thread with the stream and sets the signal

Syntax

Visual Basic (Declaration)
Public Overloads Sub Perform( _
   ByVal ioAction As Action(Of Stream), _
   ByVal signal As EventWaitHandle _
)
C#
public void Perform(
   Action<Stream> ioAction,
   EventWaitHandle signal
)

Parameters

ioAction
signal

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (ManualResetEvent mre = new ManualResetEvent(false))
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Perform(s => s.Write(new byte[100], 0, 100), mre);
    Assert.IsTrue(mre.WaitOne(60000, false));
    Assert.AreEqual(100, io.Position);
    Assert.AreEqual(100, io.Length);
}
VB.NET Copy Code
Using mre As New ManualResetEvent(False)
    Using io As New TestStream()
        Using wtr As New BackgroundWriter(io)
            wtr.Perform(Function(s) s.Write(New Byte(100) {}, 0, 100), mre)
            Assert.IsTrue(mre.WaitOne(60000, False))
            Assert.AreEqual(100, io.Position)
            Assert.AreEqual(100, io.Length)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List

Used By

BackgroundWriter.Flush()

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class : Read Method

position
buffer
offset
length

Glossary Item Box

Returns a number of bytes up to length that is pending a write at the position specified and copies those bytes into buffer the offset provided.

Syntax

Visual Basic (Declaration)
Public Function Read( _
   ByVal position As Long, _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer _
) As Integer
C#
public int Read(
   long position,
   byte[] buffer,
   int offset,
   int length
)

Parameters

position
buffer
offset
length

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Write(0L, new byte[100], 0, 100);
    wtr.Perform(s => Thread.Sleep(50));
    wtr.Write(100L, new byte[] { 99 }, 0, 1);
    wtr.Write(100L, new byte[] { 42, 43 }, 0, 2);

    // Read scans the pending writes for writes at the provided offset and returns the last result
    byte[] read = new byte[100];
    Assert.AreEqual(2, wtr.Read(100L, read, 0, 100));
    Assert.AreEqual(42, (int)read[0]);
    Assert.AreEqual(43, (int)read[1]);
}
VB.NET Copy Code
Using io As New TestStream()
    Using wtr As New BackgroundWriter(io)
        wtr.Write(0L, New Byte(100) {}, 0, 100)
        wtr.Perform(Function(s) Thread.Sleep(50))
        wtr.Write(100L, New Byte() {99}, 0, 1)
        wtr.Write(100L, New Byte() {42, 43}, 0, 2)

        ' Read scans the pending writes for writes at the provided offset and returns the last result
        Dim read As Byte() = New Byte(100) {}
        Assert.AreEqual(2, wtr.Read(100L, read, 0, 100))
        Assert.AreEqual(42, DirectCast(read(0), Integer))
        Assert.AreEqual(43, DirectCast(read(1), Integer))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class : Write Method

Glossary Item Box

Write a series of bytes to the stream at the current position

Overload List

Overload | Description
Write(Byte[],Int32,Int32) | Write a series of bytes to the stream at the current position
Write(Byte[],Int32,Int32,EventWaitHandle) | Write a series of bytes to the stream at the current position and sets the signal
Write(Int64,Byte[],Int32,Int32) | Write a series of bytes to the stream at the specified position
Write(Int64,Byte[],Int32,Int32,EventWaitHandle) | Write a series of bytes to the stream at the specified position and sets the signal

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Byte[],Int32,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > Write Method : Write(Byte[],Int32,Int32) Method

buffer
offset
length

Glossary Item Box

Write a series of bytes to the stream at the current position

Syntax

Visual Basic (Declaration)
Public Overloads Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer _
)
C#
public void Write(
   byte[] buffer,
   int offset,
   int length
)

Parameters

buffer
offset
length

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (ManualResetEvent mre = new ManualResetEvent(false))
using (TempFile temp = new TempFile())
using (TestStream io = new TestStream(temp.Open()))
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    const int sz = 1000;
    const int iter = 10000;
    var bytes = new byte[sz];
    for (int i = 0; i < iter; i++)
        wtr.Write(bytes, 0, sz);
    wtr.BeginFlush();
    Assert.IsFalse(io.Flushed);

    wtr.Perform(s => mre.Set());
    Assert.IsTrue(mre.WaitOne(60000, false));

    Assert.IsTrue(io.Flushed);
    Assert.AreEqual(sz * iter, io.Position);
    Assert.AreEqual(sz * iter, io.Length);
}
VB.NET Copy Code
Using mre As New ManualResetEvent(False)
    Using temp As New TempFile()
        Using io As New TestStream(temp.Open())
            Using wtr As New BackgroundWriter(io)
                Const  sz As Integer = 1000
                Const  iter As Integer = 10000
                Dim bytes As var = New Byte(sz) {}
                Dim i As Integer = 0
                While i < iter
                    wtr.Write(bytes, 0, sz)
                    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                End While
                wtr.BeginFlush()
                Assert.IsFalse(io.Flushed)

                wtr.Perform(Function(s) mre.[Set]())
                Assert.IsTrue(mre.WaitOne(60000, False))

                Assert.IsTrue(io.Flushed)
                Assert.AreEqual(sz * iter, io.Position)
                Assert.AreEqual(sz * iter, io.Length)
            End Using
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Byte[],Int32,Int32,EventWaitHandle) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > Write Method : Write(Byte[],Int32,Int32,EventWaitHandle) Method

buffer
offset
length
signal

Glossary Item Box

Write a series of bytes to the stream at the current position and sets the signal

Syntax

Visual Basic (Declaration)
Public Overloads Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer, _
   ByVal signal As EventWaitHandle _
)
C#
public void Write(
   byte[] buffer,
   int offset,
   int length,
   EventWaitHandle signal
)

Parameters

buffer
offset
length
signal

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (ManualResetEvent mre = new ManualResetEvent(false))
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Write(new byte[100], 0, 100, mre);
    Assert.IsTrue(mre.WaitOne(60000, false));
    Assert.AreEqual(100, io.Position);
    Assert.AreEqual(100, io.Length);
}
VB.NET Copy Code
Using mre As New ManualResetEvent(False)
    Using io As New TestStream()
        Using wtr As New BackgroundWriter(io)
            wtr.Write(New Byte(100) {}, 0, 100, mre)
            Assert.IsTrue(mre.WaitOne(60000, False))
            Assert.AreEqual(100, io.Position)
            Assert.AreEqual(100, io.Length)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int64,Byte[],Int32,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > Write Method : Write(Int64,Byte[],Int32,Int32) Method

position
buffer
offset
length

Glossary Item Box

Write a series of bytes to the stream at the specified position

Syntax

Visual Basic (Declaration)
Public Overloads Sub Write( _
   ByVal position As Long, _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer _
)
C#
public void Write(
   long position,
   byte[] buffer,
   int offset,
   int length
)

Parameters

position
buffer
offset
length

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Write(0L, new byte[100], 0, 100);
    wtr.Perform(s => Thread.Sleep(50));
    wtr.Write(100L, new byte[] { 99 }, 0, 1);
    wtr.Write(100L, new byte[] { 42, 43 }, 0, 2);

    // Read scans the pending writes for writes at the provided offset and returns the last result
    byte[] read = new byte[100];
    Assert.AreEqual(2, wtr.Read(100L, read, 0, 100));
    Assert.AreEqual(42, (int)read[0]);
    Assert.AreEqual(43, (int)read[1]);
}
VB.NET Copy Code
Using io As New TestStream()
    Using wtr As New BackgroundWriter(io)
        wtr.Write(0L, New Byte(100) {}, 0, 100)
        wtr.Perform(Function(s) Thread.Sleep(50))
        wtr.Write(100L, New Byte() {99}, 0, 1)
        wtr.Write(100L, New Byte() {42, 43}, 0, 2)

        ' Read scans the pending writes for writes at the provided offset and returns the last result
        Dim read As Byte() = New Byte(100) {}
        Assert.AreEqual(2, wtr.Read(100L, read, 0, 100))
        Assert.AreEqual(42, DirectCast(read(0), Integer))
        Assert.AreEqual(43, DirectCast(read(1), Integer))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int64,Byte[],Int32,Int32,EventWaitHandle) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BackgroundWriter Class > Write Method : Write(Int64,Byte[],Int32,Int32,EventWaitHandle) Method

position
buffer
offset
length
signal

Glossary Item Box

Write a series of bytes to the stream at the specified position and sets the signal

Syntax

Visual Basic (Declaration)
Public Overloads Sub Write( _
   ByVal position As Long, _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer, _
   ByVal signal As EventWaitHandle _
)
C#
public void Write(
   long position,
   byte[] buffer,
   int offset,
   int length,
   EventWaitHandle signal
)

Parameters

position
buffer
offset
length
signal

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestBackgroundWriter.cs

C# Copy Code
using (ManualResetEvent mre = new ManualResetEvent(false))
using (TestStream io = new TestStream())
using (BackgroundWriter wtr = new BackgroundWriter(io))
{
    wtr.Write(new byte[100], 0, 100);
    wtr.Write(1, new byte[] { 42 }, 0, 1, mre);
    Assert.IsTrue(mre.WaitOne(60000, false));
    Assert.AreEqual(2, io.Position);
    Assert.AreEqual(100, io.Length);
    io.Position = 1;
    Assert.AreEqual(42, io.ReadByte());
}
VB.NET Copy Code
Using mre As New ManualResetEvent(False)
    Using io As New TestStream()
        Using wtr As New BackgroundWriter(io)
            wtr.Write(New Byte(100) {}, 0, 100)
            wtr.Write(1, New Byte() {42}, 0, 1, mre)
            Assert.IsTrue(mre.WaitOne(60000, False))
            Assert.AreEqual(2, io.Position)
            Assert.AreEqual(100, io.Length)
            io.Position = 1
            Assert.AreEqual(42, io.ReadByte())
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BackgroundWriter Class
BackgroundWriter Members
Overload List

Used By

BackgroundWriter.Write(Byte[],Int32,Int32)
BackgroundWriter.Write(Byte[],Int32,Int32,EventWaitHandle)
BackgroundWriter.Write(Int64,Byte[],Int32,Int32)

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BaseStream Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : BaseStream Class

Glossary Item Box

Provides a base-class for a stream object that is neither readable or writable

Syntax

Visual Basic (Declaration)
Public MustInherit Class BaseStream
   Inherits System.IO.Stream
C#
public abstract class BaseStream : System.IO.Stream

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.BaseStream
CSharpTest.Net.IO.CombinedStream
CSharpTest.Net.IO.MarshallingStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BaseStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : BaseStream Class

Glossary Item Box

The following tables list the members exposed by BaseStream.

Protected Constructors

 | Name | Description
Protected Constructor | BaseStream Constructor |
Top

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | Overridden. When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | Overridden. When overridden in a derived class, sets the length of the current stream.
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

BaseStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BaseStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : BaseStream Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected BaseStream()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BaseStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : BaseStream Class

Glossary Item Box

For a list of all members of this type, see BaseStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | Overridden. When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | Overridden. When overridden in a derived class, sets the length of the current stream.
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

BaseStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Flush Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : Flush Method

Glossary Item Box

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Flush()
C#
public override void Flush()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in Flush

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : Read Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Syntax

Visual Basic (Declaration)
Public Overrides Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int Read(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Exceptions

Exception | Description
System.NotSupportedException | The exception that is thrown when an invoked method is not supported, or when there is an attempt to read, seek, or write to a stream that does not support the invoked functionality.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in Read

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : ReadByte Method

Glossary Item Box

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function ReadByte() As Integer
C#
public override int ReadByte()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in ReadByte

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Seek Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : Seek Method

offset
origin

Glossary Item Box

When overridden in a derived class, sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function Seek( _
   ByVal offset As Long, _
   ByVal origin As SeekOrigin _
) As Long
C#
public override long Seek(
   long offset,
   SeekOrigin origin
)

Parameters

offset
origin

Exceptions

Exception | Description
System.NotSupportedException | The exception that is thrown when an invoked method is not supported, or when there is an attempt to read, seek, or write to a stream that does not support the invoked functionality.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in Seek

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetLength Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : SetLength Method

value

Glossary Item Box

When overridden in a derived class, sets the length of the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Sub SetLength( _
   ByVal value As Long _
)
C#
public override void SetLength(
   long value
)

Parameters

value

Exceptions

Exception | Description
System.NotSupportedException | The exception that is thrown when an invoked method is not supported, or when there is an attempt to read, seek, or write to a stream that does not support the invoked functionality.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in SetLength

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : Write Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
)
C#
public override void Write(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Exceptions

Exception | Description
System.NotSupportedException | The exception that is thrown when an invoked method is not supported, or when there is an attempt to read, seek, or write to a stream that does not support the invoked functionality.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in Write

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : WriteByte Method

value

Glossary Item Box

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Syntax

Visual Basic (Declaration)
Public Overrides Sub WriteByte( _
   ByVal value As Byte _
)
C#
public override void WriteByte(
   byte value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in WriteByte

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BaseStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : BaseStream Class

Glossary Item Box

For a list of all members of this type, see BaseStream members.

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

BaseStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanRead Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : CanRead Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanRead As Boolean
C#
public override bool CanRead {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in CanRead

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanSeek Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : CanSeek Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanSeek As Boolean
C#
public override bool CanSeek {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in CanSeek

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanWrite Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : CanWrite Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanWrite As Boolean
C#
public override bool CanWrite {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in CanWrite

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : Length Property

Glossary Item Box

When overridden in a derived class, gets the length in bytes of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property Length As Long
C#
public override long Length {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in Length

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Position Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > BaseStream Class : Position Property

Glossary Item Box

When overridden in a derived class, gets or sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Property Position As Long
C#
public override long Position {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BaseStream Class
BaseStream Members
Base Implementation in Position

Source Code

Library/IO/BaseStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClampedStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : ClampedStream Class

Glossary Item Box

Provides a stream that clamps the usage of the input stream to a specific range, length or offset

Syntax

Visual Basic (Declaration)
Public Class ClampedStream
   Inherits System.IO.Stream
C#
public class ClampedStream : System.IO.Stream

Example

Library/Library.Test/TestClampedStream.cs

C# Copy Code
using (MemoryStream ms = new MemoryStream(SequencedBytes(20)))
using (Stream s = new ClampedStream(ms, 10, 5))
{
    byte[] test = new byte[200];
    Assert.AreEqual(5, s.Read(test, 0, 200));
    Array.Resize(ref test, 5);
    Assert.AreEqual(new byte[] { 10, 11, 12, 13, 14 }, test);
    s.Position = 0;
    s.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5);
    s.Position = 0;
    Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5 }, IOStream.ReadAllBytes(s));
}
VB.NET Copy Code
Using ms As New MemoryStream(SequencedBytes(20))
    Using s As Stream = New ClampedStream(ms, 10, 5)
        Dim test As Byte() = New Byte(200) {}
        Assert.AreEqual(5, s.Read(test, 0, 200))
        Array.Resize(test, 5)
        Assert.AreEqual(New Byte() {10, 11, 12, 13, 14}, test)
        s.Position = 0
        s.Write(New Byte() {1, 2, 3, 4, 5}, 0, 5)
        s.Position = 0
        Assert.AreEqual(New Byte() {1, 2, 3, 4, 5}, IOStream.ReadAllBytes(s))
    End Using
End Using

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.ClampedStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ClampedStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : ClampedStream Class

Glossary Item Box

The following tables list the members exposed by ClampedStream.

Public Constructors

 | Name | Description
Public Constructor | ClampedStream Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Overridden. Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | Overridden. When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | Overridden. When overridden in a derived class, sets the length of the current stream.
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

ClampedStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClampedStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : ClampedStream Constructor

Glossary Item Box

Overload List

Overload | Description
ClampedStream Constructor(Stream,Int64,Int64) | Creates a stream that limits the users ability to modify data to the specified range
ClampedStream Constructor(Stream,Int64,Int64,Boolean) | Creates a stream that limits the users ability to modify data to the specified range

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ClampedStream Constructor(Stream,Int64,Int64)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class > ClampedStream Constructor : ClampedStream Constructor(Stream,Int64,Int64)

rawStream
The stream to use for read/write
start
The position in the stream that should start the range of allowed bytes
length
The maximum length that can be read from the stream

Glossary Item Box

Creates a stream that limits the users ability to modify data to the specified range

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal rawStream As Stream, _
   ByVal start As Long, _
   ByVal length As Long _
)
C#
public ClampedStream(
   Stream rawStream,
   long start,
   long length
)

Parameters

rawStream
The stream to use for read/write
start
The position in the stream that should start the range of allowed bytes
length
The maximum length that can be read from the stream

Example

Library/Library.Test/TestClampedStream.cs

C# Copy Code
using (MemoryStream ms = new MemoryStream(SequencedBytes(20)))
using (Stream s = new ClampedStream(ms, 10, 5))
{
    byte[] test = new byte[200];
    Assert.AreEqual(5, s.Read(test, 0, 200));
    Array.Resize(ref test, 5);
    Assert.AreEqual(new byte[] { 10, 11, 12, 13, 14 }, test);
    s.Position = 0;
    s.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5);
    s.Position = 0;
    Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5 }, IOStream.ReadAllBytes(s));
}
VB.NET Copy Code
Using ms As New MemoryStream(SequencedBytes(20))
    Using s As Stream = New ClampedStream(ms, 10, 5)
        Dim test As Byte() = New Byte(200) {}
        Assert.AreEqual(5, s.Read(test, 0, 200))
        Array.Resize(test, 5)
        Assert.AreEqual(New Byte() {10, 11, 12, 13, 14}, test)
        s.Position = 0
        s.Write(New Byte() {1, 2, 3, 4, 5}, 0, 5)
        s.Position = 0
        Assert.AreEqual(New Byte() {1, 2, 3, 4, 5}, IOStream.ReadAllBytes(s))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Overload List

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClampedStream Constructor(Stream,Int64,Int64,Boolean)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class > ClampedStream Constructor : ClampedStream Constructor(Stream,Int64,Int64,Boolean)

rawStream
The stream to use for read/write
start
The position in the stream that should start the range of allowed bytes
length
The maximum length that can be read from the stream
disposeOfStream
True to dispose of the rawStream when this stream is disposed

Glossary Item Box

Creates a stream that limits the users ability to modify data to the specified range

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal rawStream As Stream, _
   ByVal start As Long, _
   ByVal length As Long, _
   ByVal disposeOfStream As Boolean _
)
C#
public ClampedStream(
   Stream rawStream,
   long start,
   long length,
   bool disposeOfStream
)

Parameters

rawStream
The stream to use for read/write
start
The position in the stream that should start the range of allowed bytes
length
The maximum length that can be read from the stream
disposeOfStream
True to dispose of the rawStream when this stream is disposed

Example

Library/Library.Test/TestClampedStream.cs

C# Copy Code
MemoryStream ms = new MemoryStream();
BufferedStream bs = new BufferedStream(ms, 1024);

using (Stream s = new ClampedStream(bs, 0, long.MaxValue, false))
{
    s.WriteByte(1);
    Assert.AreEqual(0, ms.Position);
    s.Flush();
    Assert.AreEqual(1, ms.Position);
    ms.Position = 0;
    Assert.AreEqual(1, ms.ReadByte());
}
VB.NET Copy Code
Dim ms As New MemoryStream()
Dim bs As New BufferedStream(ms, 1024)

Using s As Stream = New ClampedStream(bs, 0, Long.MaxValue, False)
    s.WriteByte(1)
    Assert.AreEqual(0, ms.Position)
    s.Flush()
    Assert.AreEqual(1, ms.Position)
    ms.Position = 0
    Assert.AreEqual(1, ms.ReadByte())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Overload List

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ClampedStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : ClampedStream Class

Glossary Item Box

For a list of all members of this type, see ClampedStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Overridden. Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | Overridden. When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | Overridden. When overridden in a derived class, sets the length of the current stream.
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

ClampedStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : Close Method

Glossary Item Box

Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Close()
C#
public override void Close()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in Close

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : Dispose Method

Glossary Item Box

Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

Overload List

Overload | Description
Dispose(Boolean) | Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Flush Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : Flush Method

Glossary Item Box

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Flush()
C#
public override void Flush()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in Flush

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : Read Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Syntax

Visual Basic (Declaration)
Public Overrides Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int Read(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in Read

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : ReadByte Method

Glossary Item Box

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function ReadByte() As Integer
C#
public override int ReadByte()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in ReadByte

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Seek Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : Seek Method

offset
origin

Glossary Item Box

When overridden in a derived class, sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function Seek( _
   ByVal offset As Long, _
   ByVal origin As SeekOrigin _
) As Long
C#
public override long Seek(
   long offset,
   SeekOrigin origin
)

Parameters

offset
origin

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in Seek

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetLength Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : SetLength Method

value

Glossary Item Box

When overridden in a derived class, sets the length of the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Sub SetLength( _
   ByVal value As Long _
)
C#
public override void SetLength(
   long value
)

Parameters

value

Exceptions

Exception | Description
System.NotSupportedException | Thrown when length != long.MaxValue

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in SetLength

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : Write Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
)
C#
public override void Write(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Exceptions

Exception | Description
System.InvalidOperationException | The exception that is thrown when a method call is invalid for the object's current state.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in Write

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : WriteByte Method

value

Glossary Item Box

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Syntax

Visual Basic (Declaration)
Public Overrides Sub WriteByte( _
   ByVal value As Byte _
)
C#
public override void WriteByte(
   byte value
)

Parameters

value

Exceptions

Exception | Description
System.InvalidOperationException | The exception that is thrown when a method call is invalid for the object's current state.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in WriteByte

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ClampedStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : ClampedStream Class

Glossary Item Box

For a list of all members of this type, see ClampedStream members.

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

ClampedStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanRead Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : CanRead Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanRead As Boolean
C#
public override bool CanRead {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in CanRead

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanSeek Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : CanSeek Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanSeek As Boolean
C#
public override bool CanSeek {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in CanSeek

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanWrite Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : CanWrite Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanWrite As Boolean
C#
public override bool CanWrite {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in CanWrite

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : Length Property

Glossary Item Box

When overridden in a derived class, gets the length in bytes of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property Length As Long
C#
public override long Length {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in Length

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Position Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ClampedStream Class : Position Property

Glossary Item Box

When overridden in a derived class, gets or sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Property Position As Long
C#
public override long Position {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ClampedStream Class
ClampedStream Members
Base Implementation in Position

Source Code

Library/IO/ClampedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CombinedStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : CombinedStream Class

Glossary Item Box

Creates a single 'pseudo' stream out of multiple input streams

Syntax

Visual Basic (Declaration)
Public Class CombinedStream
   Inherits BaseStream
C#
public class CombinedStream : BaseStream

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
DisposableFlag f1 = new DisposableFlag();
DisposableFlag f2 = new DisposableFlag();
Assert.IsFalse(f1.Disposed || f2.Disposed);

Stream ms1 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1);
Stream ms2 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2);

using (Stream cs = new CombinedStream(ms1, ms2))
{ }

Assert.IsTrue(f1.Disposed && f2.Disposed);//even though not read, we did dispose?
VB.NET Copy Code
Dim f1 As New DisposableFlag()
Dim f2 As New DisposableFlag()
Assert.IsFalse(f1.Disposed OrElse f2.Disposed)

Dim ms1 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1)
Dim ms2 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2)

Using cs As Stream = New CombinedStream(ms1, ms2)
End Using

Assert.IsTrue(f1.Disposed AndAlso f2.Disposed)
'even though not read, we did dispose?

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.BaseStream
CSharpTest.Net.IO.CombinedStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CombinedStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/CombinedStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
CombinedStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : CombinedStream Class

Glossary Item Box

The following tables list the members exposed by CombinedStream.

Public Constructors

 | Name | Description
Public Constructor | CombinedStream Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | CanRead | Overridden.
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes of all remaining streams.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. Reads from the next stream available
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

CombinedStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/CombinedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CombinedStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > CombinedStream Class : CombinedStream Constructor

Glossary Item Box

Overload List

Overload | Description
CombinedStream Constructor(Stream[]) | Creates a single 'pseudo' stream out of multiple input streams
CombinedStream Constructor(IEnumerable<Stream>) | Creates a single 'pseudo' stream out of multiple input streams

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CombinedStream Class
CombinedStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CombinedStream Constructor(Stream[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > CombinedStream Class > CombinedStream Constructor : CombinedStream Constructor(Stream[])

streams

Glossary Item Box

Creates a single 'pseudo' stream out of multiple input streams

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray streams() As Stream _
)
C#
public CombinedStream(
   params Stream[] streams
)

Parameters

streams

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
DisposableFlag f1 = new DisposableFlag();
DisposableFlag f2 = new DisposableFlag();
Assert.IsFalse(f1.Disposed || f2.Disposed);

Stream ms1 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1);
Stream ms2 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2);

using (Stream cs = new CombinedStream(ms1, ms2))
{ }

Assert.IsTrue(f1.Disposed && f2.Disposed);//even though not read, we did dispose?
VB.NET Copy Code
Dim f1 As New DisposableFlag()
Dim f2 As New DisposableFlag()
Assert.IsFalse(f1.Disposed OrElse f2.Disposed)

Dim ms1 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1)
Dim ms2 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2)

Using cs As Stream = New CombinedStream(ms1, ms2)
End Using

Assert.IsTrue(f1.Disposed AndAlso f2.Disposed)
'even though not read, we did dispose?

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CombinedStream Class
CombinedStream Members
Overload List

Used By

Stream SaltedData.CombineStream(Salt,Stream)

Source Code

Library/IO/CombinedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CombinedStream Constructor(IEnumerable<Stream>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > CombinedStream Class > CombinedStream Constructor : CombinedStream Constructor(IEnumerable<Stream>)

streams

Glossary Item Box

Creates a single 'pseudo' stream out of multiple input streams

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal streams As IEnumerable(Of Stream) _
)
C#
public CombinedStream(
   IEnumerable<Stream> streams
)

Parameters

streams

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CombinedStream Class
CombinedStream Members
Overload List

Source Code

Library/IO/CombinedStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
CombinedStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : CombinedStream Class

Glossary Item Box

For a list of all members of this type, see CombinedStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes of all remaining streams.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. Reads from the next stream available
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

CombinedStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/CombinedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > CombinedStream Class : Dispose Method

Glossary Item Box

Disposes of all remaining streams.

Overload List

Overload | Description
Dispose(Boolean) | Disposes of all remaining streams.
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CombinedStream Class
CombinedStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > CombinedStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of all remaining streams.

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CombinedStream Class
CombinedStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > CombinedStream Class : Read Method

buffer
offset
count

Glossary Item Box

Reads from the next stream available

Syntax

Visual Basic (Declaration)
Public Overrides Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int Read(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CombinedStream Class
CombinedStream Members
Base Implementation in Read

Source Code

Library/IO/CombinedStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
CombinedStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : CombinedStream Class

Glossary Item Box

For a list of all members of this type, see CombinedStream members.

Public Properties

 | Name | Description
Public Property | CanRead | Overridden.
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

CombinedStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/CombinedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanRead Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > CombinedStream Class : CanRead Property

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanRead As Boolean
C#
public override bool CanRead {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CombinedStream Class
CombinedStream Members
Base Implementation in CanRead

Source Code

Library/IO/CombinedStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : DisposingStream Class

Glossary Item Box

Servers a dual-role, it can prevent an aggregated stream from disposing, or it can manage other objects that need to be disposed when the stream is disposed.

Syntax

Visual Basic (Declaration)
Public Class DisposingStream
   Inherits AggregateStream
C#
public class DisposingStream : AggregateStream

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
DisposableFlag f1 = new DisposableFlag();
DisposableFlag f2 = new DisposableFlag();
Assert.IsFalse(f1.Disposed || f2.Disposed);

Stream ms1 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1);
Stream ms2 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2);

using (Stream cs = new CombinedStream(ms1, ms2))
{ }

Assert.IsTrue(f1.Disposed && f2.Disposed);//even though not read, we did dispose?
VB.NET Copy Code
Dim f1 As New DisposableFlag()
Dim f2 As New DisposableFlag()
Assert.IsFalse(f1.Disposed OrElse f2.Disposed)

Dim ms1 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1)
Dim ms2 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2)

Using cs As Stream = New CombinedStream(ms1, ms2)
End Using

Assert.IsTrue(f1.Disposed AndAlso f2.Disposed)
'even though not read, we did dispose?

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.AggregateStream
CSharpTest.Net.IO.DisposingStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisposingStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/DisposingStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DisposingStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : DisposingStream Class

Glossary Item Box

The following tables list the members exposed by DisposingStream.

Public Constructors

 | Name | Description
Public Constructor | DisposingStream Constructor | Create the wrapper on the provided stream, add disposables via WithDosposeOf(...)
Top

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Protected Properties

 | Name | Description
Protected Property | Stream | Allows modifying the underlying stream (Inherited from CSharpTest.Net.IO.AggregateStream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes of the stream and then all objects in the disposable list
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | WithDisposeOf | Adds an object to this stream that will be disposed when the stream is disposed.
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

DisposingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/DisposingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DisposingStream Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > DisposingStream Class : DisposingStream Constructor

stream

Glossary Item Box

Create the wrapper on the provided stream, add disposables via WithDosposeOf(...)

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream _
)
C#
public DisposingStream(
   Stream stream
)

Parameters

stream

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
DisposableFlag f1 = new DisposableFlag();
DisposableFlag f2 = new DisposableFlag();
Assert.IsFalse(f1.Disposed || f2.Disposed);

Stream ms1 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1);
Stream ms2 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2);

using (Stream cs = new CombinedStream(ms1, ms2))
{ }

Assert.IsTrue(f1.Disposed && f2.Disposed);//even though not read, we did dispose?
VB.NET Copy Code
Dim f1 As New DisposableFlag()
Dim f2 As New DisposableFlag()
Assert.IsFalse(f1.Disposed OrElse f2.Disposed)

Dim ms1 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1)
Dim ms2 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2)

Using cs As Stream = New CombinedStream(ms1, ms2)
End Using

Assert.IsTrue(f1.Disposed AndAlso f2.Disposed)
'even though not read, we did dispose?

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisposingStream Class
DisposingStream Members

Used By

Stream AsymmetricKey.Encrypt(Stream)
Stream AsymmetricKey.Decrypt(Stream)
Stream AESCryptoKey.Encrypt(Stream)
Stream AESCryptoKey.Decrypt(Stream)
Stream PasswordKey.Encrypt(Stream)
Stream PasswordKey.Decrypt(Stream,Salt.Size)

Source Code

Library/IO/DisposingStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DisposingStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : DisposingStream Class

Glossary Item Box

For a list of all members of this type, see DisposingStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Disposes of the stream and then all objects in the disposable list
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | WithDisposeOf | Adds an object to this stream that will be disposed when the stream is disposed.
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

DisposingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/DisposingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > DisposingStream Class : Dispose Method

Glossary Item Box

Disposes of the stream and then all objects in the disposable list

Overload List

Overload | Description
Dispose(Boolean) | Disposes of the stream and then all objects in the disposable list
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisposingStream Class
DisposingStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > DisposingStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of the stream and then all objects in the disposable list

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisposingStream Class
DisposingStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
WithDisposeOf Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > DisposingStream Class : WithDisposeOf Method

disposable

Glossary Item Box

Adds an object to this stream that will be disposed when the stream is disposed.

Syntax

Visual Basic (Declaration)
Public Function WithDisposeOf( _
   ByVal disposable As IDisposable _
) As DisposingStream
C#
public DisposingStream WithDisposeOf(
   IDisposable disposable
)

Parameters

disposable

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
DisposableFlag f1 = new DisposableFlag();
DisposableFlag f2 = new DisposableFlag();
Assert.IsFalse(f1.Disposed || f2.Disposed);

Stream ms1 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1);
Stream ms2 = new DisposingStream(new MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2);

using (Stream cs = new CombinedStream(ms1, ms2))
{ }

Assert.IsTrue(f1.Disposed && f2.Disposed);//even though not read, we did dispose?
VB.NET Copy Code
Dim f1 As New DisposableFlag()
Dim f2 As New DisposableFlag()
Assert.IsFalse(f1.Disposed OrElse f2.Disposed)

Dim ms1 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("Hello"))).WithDisposeOf(f1)
Dim ms2 As Stream = New DisposingStream(New MemoryStream(Encoding.ASCII.GetBytes("There"))).WithDisposeOf(f2)

Using cs As Stream = New CombinedStream(ms1, ms2)
End Using

Assert.IsTrue(f1.Disposed AndAlso f2.Disposed)
'even though not read, we did dispose?

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DisposingStream Class
DisposingStream Members

Used By

Stream AsymmetricKey.Encrypt(Stream)
Stream AsymmetricKey.Decrypt(Stream)
Stream AESCryptoKey.Encrypt(Stream)
Stream AESCryptoKey.Decrypt(Stream)
Stream PasswordKey.Encrypt(Stream)
Stream PasswordKey.Decrypt(Stream,Salt.Size)

Source Code

Library/IO/DisposingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStreamFactory Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FileStreamFactory Class

Glossary Item Box

Provides a default implementation of an IFactory for creating streams on a single file.

Syntax

Visual Basic (Declaration)
Public Class FileStreamFactory
   Implements CSharpTest.Net.Interfaces.IFactory(Of Stream)
C#
public class FileStreamFactory : CSharpTest.Net.Interfaces.IFactory<Stream>

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
using (TempFile tempFile = new TempFile())
{
    FileStreamFactory factory = new FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
    using (DisposingList<Stream> open = new DisposingList<Stream>())
    {
        for( int i = 0; i < 50; i++ )
            open.Add(factory.Create());
    }
}
VB.NET Copy Code
Using tempFile As New TempFile()
    Dim factory As New FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
    Using open As New DisposingList(Of Stream)()
        Dim i As Integer = 0
        While i < 50
            open.Add(factory.Create())
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.FileStreamFactory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FileStreamFactory Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FileStreamFactory Class

Glossary Item Box

The following tables list the members exposed by FileStreamFactory.

Public Constructors

 | Name | Description
Public Constructor | FileStreamFactory Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | FileName | The FileName that this factory produces streams for
Top

Public Methods

 | Name | Description
Public Method | Create | Creates the file stream
Top

See Also

Reference

FileStreamFactory Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStreamFactory Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FileStreamFactory Class : FileStreamFactory Constructor

Glossary Item Box

Overload List

Overload | Description
FileStreamFactory Constructor(String,FileMode) | Creates an IFactory for creating streams on a single file
FileStreamFactory Constructor(String,FileMode,FileAccess) | Creates an IFactory for creating streams on a single file
FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare) | Creates an IFactory for creating streams on a single file
FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare,Int32) | Creates an IFactory for creating streams on a single file
FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare,Int32,FileOptions) | Creates an IFactory for creating streams on a single file

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Class
FileStreamFactory Members


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStreamFactory Constructor(String,FileMode)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FileStreamFactory Class > FileStreamFactory Constructor : FileStreamFactory Constructor(String,FileMode)

filename
mode

Glossary Item Box

Creates an IFactory for creating streams on a single file

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String, _
   ByVal mode As FileMode _
)
C#
public FileStreamFactory(
   string filename,
   FileMode mode
)

Parameters

filename
mode

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (TempFile tempFile = new TempFile())
{
    using (StreamCache cache = new StreamCache(new FileStreamFactory(tempFile.TempPath, FileMode.Open)))
    {
        using (stream = cache.Open())
        {
            stream.SetLength(100);
            stream.WriteByte(1);
        }
    }

    Assert.AreEqual(100, tempFile.Length);
    using (stream = tempFile.Open())
        Assert.AreEqual(1, stream.ReadByte());
}
VB.NET Copy Code
Dim stream As Stream
Using tempFile As New TempFile()
    Using cache As New StreamCache(New FileStreamFactory(tempFile.TempPath, FileMode.Open))
        Using stream = cache.Open()
            stream.SetLength(100)
            stream.WriteByte(1)
        End Using
    End Using

    Assert.AreEqual(100, tempFile.Length)
    Using stream = tempFile.Open()
        Assert.AreEqual(1, stream.ReadByte())
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Class
FileStreamFactory Members
Overload List

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStreamFactory Constructor(String,FileMode,FileAccess)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FileStreamFactory Class > FileStreamFactory Constructor : FileStreamFactory Constructor(String,FileMode,FileAccess)

filename
mode
access

Glossary Item Box

Creates an IFactory for creating streams on a single file

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String, _
   ByVal mode As FileMode, _
   ByVal access As FileAccess _
)
C#
public FileStreamFactory(
   string filename,
   FileMode mode,
   FileAccess access
)

Parameters

filename
mode
access

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Class
FileStreamFactory Members
Overload List

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FileStreamFactory Class > FileStreamFactory Constructor : FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare)

filename
mode
access
share

Glossary Item Box

Creates an IFactory for creating streams on a single file

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String, _
   ByVal mode As FileMode, _
   ByVal access As FileAccess, _
   ByVal share As FileShare _
)
C#
public FileStreamFactory(
   string filename,
   FileMode mode,
   FileAccess access,
   FileShare share
)

Parameters

filename
mode
access
share

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
using (TempFile tempFile = new TempFile())
{
    FileStreamFactory factory = new FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
    using (DisposingList<Stream> open = new DisposingList<Stream>())
    {
        for( int i = 0; i < 50; i++ )
            open.Add(factory.Create());
    }
}
VB.NET Copy Code
Using tempFile As New TempFile()
    Dim factory As New FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
    Using open As New DisposingList(Of Stream)()
        Dim i As Integer = 0
        While i < 50
            open.Add(factory.Create())
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Class
FileStreamFactory Members
Overload List

Used By

Boolean SecureTransfer.Client.Download(String,String)
FragmentedFile FragmentedFile.CreateNew(String,Int32,Int32,Int32,FileOptions)

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FileStreamFactory Class > FileStreamFactory Constructor : FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare,Int32)

filename
mode
access
share
bufferSize

Glossary Item Box

Creates an IFactory for creating streams on a single file

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String, _
   ByVal mode As FileMode, _
   ByVal access As FileAccess, _
   ByVal share As FileShare, _
   ByVal bufferSize As Integer _
)
C#
public FileStreamFactory(
   string filename,
   FileMode mode,
   FileAccess access,
   FileShare share,
   int bufferSize
)

Parameters

filename
mode
access
share
bufferSize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Class
FileStreamFactory Members
Overload List

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare,Int32,FileOptions)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FileStreamFactory Class > FileStreamFactory Constructor : FileStreamFactory Constructor(String,FileMode,FileAccess,FileShare,Int32,FileOptions)

filename
mode
access
share
bufferSize
options

Glossary Item Box

Creates an IFactory for creating streams on a single file

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String, _
   ByVal mode As FileMode, _
   ByVal access As FileAccess, _
   ByVal share As FileShare, _
   ByVal bufferSize As Integer, _
   ByVal options As FileOptions _
)
C#
public FileStreamFactory(
   string filename,
   FileMode mode,
   FileAccess access,
   FileShare share,
   int bufferSize,
   FileOptions options
)

Parameters

filename
mode
access
share
bufferSize
options

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
using(TempFile tempFile = new TempFile())
{
    FileStreamFactory factory = new FileStreamFactory(tempFile.TempPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 1024, FileOptions.Asynchronous);
    Assert.AreEqual(tempFile.TempPath, factory.FileName);
    using (FileStream s = (FileStream)factory.Create())
        Assert.IsTrue(s.CanRead && s.CanWrite && s.IsAsync);
}
VB.NET Copy Code
Using tempFile As New TempFile()
    Dim factory As New FileStreamFactory(tempFile.TempPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 1024, FileOptions.Asynchronous)
    Assert.AreEqual(tempFile.TempPath, factory.FileName)
    Using s As FileStream = DirectCast(factory.Create(), FileStream)
        Assert.IsTrue(s.CanRead AndAlso s.CanWrite AndAlso s.IsAsync)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Class
FileStreamFactory Members
Overload List

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
FileStreamFactory Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FileStreamFactory Class

Glossary Item Box

For a list of all members of this type, see FileStreamFactory members.

Public Methods

 | Name | Description
Public Method | Create | Creates the file stream
Top

See Also

Reference

FileStreamFactory Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FileStreamFactory Class : Create Method

Glossary Item Box

Creates the file stream

Syntax

Visual Basic (Declaration)
Public Function Create() As Stream
C#
public Stream Create()

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
using (TempFile tempFile = new TempFile())
{
    FileStreamFactory factory = new FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
    using (DisposingList<Stream> open = new DisposingList<Stream>())
    {
        for( int i = 0; i < 50; i++ )
            open.Add(factory.Create());
    }
}
VB.NET Copy Code
Using tempFile As New TempFile()
    Dim factory As New FileStreamFactory(tempFile.TempPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
    Using open As New DisposingList(Of Stream)()
        Dim i As Integer = 0
        While i < 50
            open.Add(factory.Create())
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Class
FileStreamFactory Members

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
FileStreamFactory Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FileStreamFactory Class

Glossary Item Box

For a list of all members of this type, see FileStreamFactory members.

Public Properties

 | Name | Description
Public Property | FileName | The FileName that this factory produces streams for
Top

See Also

Reference

FileStreamFactory Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FileStreamFactory Class : FileName Property

Glossary Item Box

The FileName that this factory produces streams for

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileName As String
C#
public string FileName {get;}

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
using(TempFile tempFile = new TempFile())
{
    FileStreamFactory factory = new FileStreamFactory(tempFile.TempPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 1024, FileOptions.Asynchronous);
    Assert.AreEqual(tempFile.TempPath, factory.FileName);
    using (FileStream s = (FileStream)factory.Create())
        Assert.IsTrue(s.CanRead && s.CanWrite && s.IsAsync);
}
VB.NET Copy Code
Using tempFile As New TempFile()
    Dim factory As New FileStreamFactory(tempFile.TempPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 1024, FileOptions.Asynchronous)
    Assert.AreEqual(tempFile.TempPath, factory.FileName)
    Using s As FileStream = DirectCast(factory.Create(), FileStream)
        Assert.IsTrue(s.CanRead AndAlso s.CanWrite AndAlso s.IsAsync)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStreamFactory Class
FileStreamFactory Members

Source Code

Library/IO/FileStreamFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile Class

Glossary Item Box

Provides an efficient file/directory enumeration that behaves several orders faster than Directory.GetXxxx() methods.

Syntax

Visual Basic (Declaration)
Public Class FindFile
C#
public class FindFile

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
string child2 = Path.Combine(TestFolder, @"child1\child2");

DirectorySecurity acl = Directory.GetAccessControl(child2);
byte[] original = acl.GetSecurityDescriptorBinaryForm();
acl.AddAccessRule(
    new FileSystemAccessRule(
        new SecurityIdentifier(WellKnownSidType.WorldSid, null),
        FileSystemRights.ListDirectory,
        AccessControlType.Deny)
    );
Directory.SetAccessControl(child2, acl);
try
{
    //By default it ignores AccessDenied
    FindFile ff = new FindFile(child2, "*", false, false);
    ff.FileFound += (o, e) => Assert.Fail("Should not find a file");
    ff.Find();

    //Now raise the AccessDenied
    ff.RaiseOnAccessDenied = true;
    try
    {
        ff.Find();
        Assert.Fail("Should throw Access Denied.");
    }
    catch(System.ComponentModel.Win32Exception we)
    { Assert.AreEqual(5, we.NativeErrorCode); }
}
finally
{
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All);
    Directory.SetAccessControl(child2, acl);
}
VB.NET Copy Code
Dim child2 As String = Path.Combine(TestFolder, "child1\child2")

Dim acl As DirectorySecurity = Directory.GetAccessControl(child2)
Dim original As Byte() = acl.GetSecurityDescriptorBinaryForm()
acl.AddAccessRule(New FileSystemAccessRule(New SecurityIdentifier(WellKnownSidType.WorldSid, Nothing), FileSystemRights.ListDirectory, AccessControlType.Deny))
Directory.SetAccessControl(child2, acl)
Try
    'By default it ignores AccessDenied
    Dim ff As New FindFile(child2, "*", False, False)
    ff.FileFound += Function(o, e) Assert.Fail("Should not find a file")
    ff.Find()

    'Now raise the AccessDenied
    ff.RaiseOnAccessDenied = True
    Try
        ff.Find()
        Assert.Fail("Should throw Access Denied.")
    Catch we As System.ComponentModel.Win32Exception
        Assert.AreEqual(5, we.NativeErrorCode)
    End Try
Finally
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All)
    Directory.SetAccessControl(child2, acl)
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.FindFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FindFile Class Members
See Also Fields Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile Class

Glossary Item Box

The following tables list the members exposed by FindFile.

Public Constructors

 | Name | Description
Public Constructor | FindFile Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | UncPrefix | Returns the Unc path prefix used
Top

Public Properties

 | Name | Description
Public Property | BaseDirectory | Gets or sets the base directory to search within
Public Property | FilePattern | Gets or sets the file pattern to match while enumerating files and folders.
Public Property | IncludeFiles | Gets or sets the IncludeFiles flag
Public Property | IncludeFolders | Gets or sets the IncludeFolders flag
Public Property | MaxPath | Gets or sets the maximum number of allowed characters in a complete path, default = 4kb
Public Property | RaiseOnAccessDenied | Gets or sets the RaiseOnAccessDenied flag, when set to true an 'Access Denied' can be raised
Public Property | Recursive | Gets or sets the Recursive flag
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | AllFilesAndFoldersIn | Enumerates the files and folders anywhere under the directory specified
static (Shared in Visual Basic) | AllFilesIn | Enumerates the files anywhere under the directory specified
static (Shared in Visual Basic) | AllFoldersIn | Enumerates the folders anywhere under the directory specified
static (Shared in Visual Basic) | FilesAndFoldersIn | Enumerates the files and folders directly in the directory specified
static (Shared in Visual Basic) | FilesIn | Enumerates the files directly in the directory specified
Public Method | Find | Overloaded. Performs the search raising the FileFound event for each entry matching the request
static (Shared in Visual Basic) | FoldersIn | Enumerates the folders directly in the directory specified
Top

Public Events

 | Name | Description
Public Event | FileFound | The event-handler to raise when a file or folder is found.
Top

See Also

Reference

FindFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : FindFile Constructor

Glossary Item Box

Overload List

Overload | Description
FindFile Constructor() | Creates a FindFile instance.
FindFile Constructor(String) | Creates a FindFile instance.
FindFile Constructor(String,String) | Creates a FindFile instance.
FindFile Constructor(String,String,Boolean) | Creates a FindFile instance.
FindFile Constructor(String,String,Boolean,Boolean) | Creates a FindFile instance.
FindFile Constructor(String,String,Boolean,Boolean,Boolean) | Creates a FindFile instance.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class > FindFile Constructor : FindFile Constructor()

Glossary Item Box

Creates a FindFile instance.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public FindFile()

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile();
Assert.AreEqual("", ff.BaseDirectory);
Assert.AreEqual("*", ff.FilePattern);
Assert.AreEqual(true, ff.Recursive);
Assert.AreEqual(true, ff.IncludeFiles);
Assert.AreEqual(true, ff.IncludeFolders);
Assert.AreEqual(false, ff.RaiseOnAccessDenied);
Assert.AreEqual(4096, ff.MaxPath);

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder);
Assert.AreEqual("a.*", ff.FilePattern = "a.*");
Assert.AreEqual(false, ff.Recursive = false);
Assert.AreEqual(false, ff.IncludeFiles = false);
Assert.AreEqual(false, ff.IncludeFolders = false);
Assert.AreEqual(true, ff.RaiseOnAccessDenied = true);
Assert.AreEqual(1024, ff.MaxPath = 1024);

ff.FileFound += (o, e) => Assert.Fail("Should not find anything.");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile()
Assert.AreEqual("", ff.BaseDirectory)
Assert.AreEqual("*", ff.FilePattern)
Assert.AreEqual(True, ff.Recursive)
Assert.AreEqual(True, ff.IncludeFiles)
Assert.AreEqual(True, ff.IncludeFolders)
Assert.AreEqual(False, ff.RaiseOnAccessDenied)
Assert.AreEqual(4096, ff.MaxPath)

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder)
Assert.AreEqual("a.*", ff.FilePattern = "a.*")
Assert.AreEqual(False, ff.Recursive = False)
Assert.AreEqual(False, ff.IncludeFiles = False)
Assert.AreEqual(False, ff.IncludeFolders = False)
Assert.AreEqual(True, ff.RaiseOnAccessDenied = True)
Assert.AreEqual(1024, ff.MaxPath = 1024)

ff.FileFound += Function(o, e) Assert.Fail("Should not find anything.")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members
Overload List

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class > FindFile Constructor : FindFile Constructor(String)

rootDirectory

Glossary Item Box

Creates a FindFile instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal rootDirectory As String _
)
C#
public FindFile(
   string rootDirectory
)

Parameters

rootDirectory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members
Overload List

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile Constructor(String,String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class > FindFile Constructor : FindFile Constructor(String,String)

rootDirectory
filePattern

Glossary Item Box

Creates a FindFile instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal rootDirectory As String, _
   ByVal filePattern As String _
)
C#
public FindFile(
   string rootDirectory,
   string filePattern
)

Parameters

rootDirectory
filePattern

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile("ZZZ:\\WTF", "*");
ff.FileFound += (o, e) => Assert.Fail("Should not find a file");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile("ZZZ:\WTF", "*")
ff.FileFound += Function(o, e) Assert.Fail("Should not find a file")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members
Overload List

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile Constructor(String,String,Boolean)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class > FindFile Constructor : FindFile Constructor(String,String,Boolean)

rootDirectory
filePattern
recursive

Glossary Item Box

Creates a FindFile instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal rootDirectory As String, _
   ByVal filePattern As String, _
   ByVal recursive As Boolean _
)
C#
public FindFile(
   string rootDirectory,
   string filePattern,
   bool recursive
)

Parameters

rootDirectory
filePattern
recursive

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile(Path.Combine(TestFolder, "foo"), "*", false);
ff.FileFound += (o, e) => Assert.Fail("Should not find a file");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile(Path.Combine(TestFolder, "foo"), "*", False)
ff.FileFound += Function(o, e) Assert.Fail("Should not find a file")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members
Overload List

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile Constructor(String,String,Boolean,Boolean)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class > FindFile Constructor : FindFile Constructor(String,String,Boolean,Boolean)

rootDirectory
filePattern
recursive
includeFolders

Glossary Item Box

Creates a FindFile instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal rootDirectory As String, _
   ByVal filePattern As String, _
   ByVal recursive As Boolean, _
   ByVal includeFolders As Boolean _
)
C#
public FindFile(
   string rootDirectory,
   string filePattern,
   bool recursive,
   bool includeFolders
)

Parameters

rootDirectory
filePattern
recursive
includeFolders

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
string child2 = Path.Combine(TestFolder, @"child1\child2");

DirectorySecurity acl = Directory.GetAccessControl(child2);
byte[] original = acl.GetSecurityDescriptorBinaryForm();
acl.AddAccessRule(
    new FileSystemAccessRule(
        new SecurityIdentifier(WellKnownSidType.WorldSid, null),
        FileSystemRights.ListDirectory,
        AccessControlType.Deny)
    );
Directory.SetAccessControl(child2, acl);
try
{
    //By default it ignores AccessDenied
    FindFile ff = new FindFile(child2, "*", false, false);
    ff.FileFound += (o, e) => Assert.Fail("Should not find a file");
    ff.Find();

    //Now raise the AccessDenied
    ff.RaiseOnAccessDenied = true;
    try
    {
        ff.Find();
        Assert.Fail("Should throw Access Denied.");
    }
    catch(System.ComponentModel.Win32Exception we)
    { Assert.AreEqual(5, we.NativeErrorCode); }
}
finally
{
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All);
    Directory.SetAccessControl(child2, acl);
}
VB.NET Copy Code
Dim child2 As String = Path.Combine(TestFolder, "child1\child2")

Dim acl As DirectorySecurity = Directory.GetAccessControl(child2)
Dim original As Byte() = acl.GetSecurityDescriptorBinaryForm()
acl.AddAccessRule(New FileSystemAccessRule(New SecurityIdentifier(WellKnownSidType.WorldSid, Nothing), FileSystemRights.ListDirectory, AccessControlType.Deny))
Directory.SetAccessControl(child2, acl)
Try
    'By default it ignores AccessDenied
    Dim ff As New FindFile(child2, "*", False, False)
    ff.FileFound += Function(o, e) Assert.Fail("Should not find a file")
    ff.Find()

    'Now raise the AccessDenied
    ff.RaiseOnAccessDenied = True
    Try
        ff.Find()
        Assert.Fail("Should throw Access Denied.")
    Catch we As System.ComponentModel.Win32Exception
        Assert.AreEqual(5, we.NativeErrorCode)
    End Try
Finally
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All)
    Directory.SetAccessControl(child2, acl)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members
Overload List

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile Constructor(String,String,Boolean,Boolean,Boolean)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class > FindFile Constructor : FindFile Constructor(String,String,Boolean,Boolean,Boolean)

rootDirectory
filePattern
recursive
includeFolders
includeFiles

Glossary Item Box

Creates a FindFile instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal rootDirectory As String, _
   ByVal filePattern As String, _
   ByVal recursive As Boolean, _
   ByVal includeFolders As Boolean, _
   ByVal includeFiles As Boolean _
)
C#
public FindFile(
   string rootDirectory,
   string filePattern,
   bool recursive,
   bool includeFolders,
   bool includeFiles
)

Parameters

rootDirectory
filePattern
recursive
includeFolders
includeFiles

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members
Overload List

Used By

FindFile.FilesIn(String,Action)
FindFile.FoldersIn(String,Action)
FindFile.FilesAndFoldersIn(String,Action)
FindFile.AllFilesIn(String,Action)
FindFile.AllFoldersIn(String,Action)
FindFile.AllFilesAndFoldersIn(String,Action)

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
FindFile Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile Class

Glossary Item Box

For a list of all members of this type, see FindFile members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | AllFilesAndFoldersIn | Enumerates the files and folders anywhere under the directory specified
static (Shared in Visual Basic) | AllFilesIn | Enumerates the files anywhere under the directory specified
static (Shared in Visual Basic) | AllFoldersIn | Enumerates the folders anywhere under the directory specified
static (Shared in Visual Basic) | FilesAndFoldersIn | Enumerates the files and folders directly in the directory specified
static (Shared in Visual Basic) | FilesIn | Enumerates the files directly in the directory specified
Public Method | Find | Overloaded. Performs the search raising the FileFound event for each entry matching the request
static (Shared in Visual Basic) | FoldersIn | Enumerates the folders directly in the directory specified
Top

See Also

Reference

FindFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AllFilesAndFoldersIn Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : AllFilesAndFoldersIn Method

directory
e

Glossary Item Box

Enumerates the files and folders anywhere under the directory specified

Syntax

Visual Basic (Declaration)
Public Shared Sub AllFilesAndFoldersIn( _
   ByVal directory As String, _
   ByVal e As Action(Of FindFile.FileFoundEventArgs) _
)
C#
public static void AllFilesAndFoldersIn(
   string directory,
   Action<FindFile.FileFoundEventArgs> e
)

Parameters

directory
e

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AllFilesIn Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : AllFilesIn Method

directory
e

Glossary Item Box

Enumerates the files anywhere under the directory specified

Syntax

Visual Basic (Declaration)
Public Shared Sub AllFilesIn( _
   ByVal directory As String, _
   ByVal e As Action(Of FindFile.FileFoundEventArgs) _
)
C#
public static void AllFilesIn(
   string directory,
   Action<FindFile.FileFoundEventArgs> e
)

Parameters

directory
e

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AllFoldersIn Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : AllFoldersIn Method

directory
e

Glossary Item Box

Enumerates the folders anywhere under the directory specified

Syntax

Visual Basic (Declaration)
Public Shared Sub AllFoldersIn( _
   ByVal directory As String, _
   ByVal e As Action(Of FindFile.FileFoundEventArgs) _
)
C#
public static void AllFoldersIn(
   string directory,
   Action<FindFile.FileFoundEventArgs> e
)

Parameters

directory
e

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FilesAndFoldersIn Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : FilesAndFoldersIn Method

directory
e

Glossary Item Box

Enumerates the files and folders directly in the directory specified

Syntax

Visual Basic (Declaration)
Public Shared Sub FilesAndFoldersIn( _
   ByVal directory As String, _
   ByVal e As Action(Of FindFile.FileFoundEventArgs) _
)
C#
public static void FilesAndFoldersIn(
   string directory,
   Action<FindFile.FileFoundEventArgs> e
)

Parameters

directory
e

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FilesIn Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : FilesIn Method

directory
e

Glossary Item Box

Enumerates the files directly in the directory specified

Syntax

Visual Basic (Declaration)
Public Shared Sub FilesIn( _
   ByVal directory As String, _
   ByVal e As Action(Of FindFile.FileFoundEventArgs) _
)
C#
public static void FilesIn(
   string directory,
   Action<FindFile.FileFoundEventArgs> e
)

Parameters

directory
e

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Find Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : Find Method

Glossary Item Box

Performs the search raising the FileFound event for each entry matching the request

Overload List

Overload | Description
Find(String) | Performs the search raising the FileFound event for each entry matching the request
Find() | Performs the search raising the FileFound event for each entry matching the request

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Find(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class > Find Method : Find(String) Method

pattern

Glossary Item Box

Performs the search raising the FileFound event for each entry matching the request

Syntax

Visual Basic (Declaration)
Public Overloads Sub Find( _
   ByVal pattern As String _
)
C#
public void Find(
   string pattern
)

Parameters

pattern

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members
Overload List

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Find() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class > Find Method : Find() Method

Glossary Item Box

Performs the search raising the FileFound event for each entry matching the request

Syntax

Visual Basic (Declaration)
Public Overloads Sub Find()
C#
public void Find()

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
string child2 = Path.Combine(TestFolder, @"child1\child2");

DirectorySecurity acl = Directory.GetAccessControl(child2);
byte[] original = acl.GetSecurityDescriptorBinaryForm();
acl.AddAccessRule(
    new FileSystemAccessRule(
        new SecurityIdentifier(WellKnownSidType.WorldSid, null),
        FileSystemRights.ListDirectory,
        AccessControlType.Deny)
    );
Directory.SetAccessControl(child2, acl);
try
{
    //By default it ignores AccessDenied
    FindFile ff = new FindFile(child2, "*", false, false);
    ff.FileFound += (o, e) => Assert.Fail("Should not find a file");
    ff.Find();

    //Now raise the AccessDenied
    ff.RaiseOnAccessDenied = true;
    try
    {
        ff.Find();
        Assert.Fail("Should throw Access Denied.");
    }
    catch(System.ComponentModel.Win32Exception we)
    { Assert.AreEqual(5, we.NativeErrorCode); }
}
finally
{
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All);
    Directory.SetAccessControl(child2, acl);
}
VB.NET Copy Code
Dim child2 As String = Path.Combine(TestFolder, "child1\child2")

Dim acl As DirectorySecurity = Directory.GetAccessControl(child2)
Dim original As Byte() = acl.GetSecurityDescriptorBinaryForm()
acl.AddAccessRule(New FileSystemAccessRule(New SecurityIdentifier(WellKnownSidType.WorldSid, Nothing), FileSystemRights.ListDirectory, AccessControlType.Deny))
Directory.SetAccessControl(child2, acl)
Try
    'By default it ignores AccessDenied
    Dim ff As New FindFile(child2, "*", False, False)
    ff.FileFound += Function(o, e) Assert.Fail("Should not find a file")
    ff.Find()

    'Now raise the AccessDenied
    ff.RaiseOnAccessDenied = True
    Try
        ff.Find()
        Assert.Fail("Should throw Access Denied.")
    Catch we As System.ComponentModel.Win32Exception
        Assert.AreEqual(5, we.NativeErrorCode)
    End Try
Finally
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All)
    Directory.SetAccessControl(child2, acl)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members
Overload List

Used By

FindFile.FilesIn(String,Action)
FindFile.FoldersIn(String,Action)
FindFile.FilesAndFoldersIn(String,Action)
FindFile.AllFilesIn(String,Action)
FindFile.AllFoldersIn(String,Action)
FindFile.AllFilesAndFoldersIn(String,Action)
FindFile.Find(String)

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FoldersIn Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : FoldersIn Method

directory
e

Glossary Item Box

Enumerates the folders directly in the directory specified

Syntax

Visual Basic (Declaration)
Public Shared Sub FoldersIn( _
   ByVal directory As String, _
   ByVal e As Action(Of FindFile.FileFoundEventArgs) _
)
C#
public static void FoldersIn(
   string directory,
   Action<FindFile.FileFoundEventArgs> e
)

Parameters

directory
e

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
FindFile Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile Class

Glossary Item Box

For a list of all members of this type, see FindFile members.

Public Properties

 | Name | Description
Public Property | BaseDirectory | Gets or sets the base directory to search within
Public Property | FilePattern | Gets or sets the file pattern to match while enumerating files and folders.
Public Property | IncludeFiles | Gets or sets the IncludeFiles flag
Public Property | IncludeFolders | Gets or sets the IncludeFolders flag
Public Property | MaxPath | Gets or sets the maximum number of allowed characters in a complete path, default = 4kb
Public Property | RaiseOnAccessDenied | Gets or sets the RaiseOnAccessDenied flag, when set to true an 'Access Denied' can be raised
Public Property | Recursive | Gets or sets the Recursive flag
Top

See Also

Reference

FindFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BaseDirectory Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : BaseDirectory Property

Glossary Item Box

Gets or sets the base directory to search within

Syntax

Visual Basic (Declaration)
Public Property BaseDirectory As String
C#
public string BaseDirectory {get; set;}

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile();
Assert.AreEqual("", ff.BaseDirectory);
Assert.AreEqual("*", ff.FilePattern);
Assert.AreEqual(true, ff.Recursive);
Assert.AreEqual(true, ff.IncludeFiles);
Assert.AreEqual(true, ff.IncludeFolders);
Assert.AreEqual(false, ff.RaiseOnAccessDenied);
Assert.AreEqual(4096, ff.MaxPath);

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder);
Assert.AreEqual("a.*", ff.FilePattern = "a.*");
Assert.AreEqual(false, ff.Recursive = false);
Assert.AreEqual(false, ff.IncludeFiles = false);
Assert.AreEqual(false, ff.IncludeFolders = false);
Assert.AreEqual(true, ff.RaiseOnAccessDenied = true);
Assert.AreEqual(1024, ff.MaxPath = 1024);

ff.FileFound += (o, e) => Assert.Fail("Should not find anything.");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile()
Assert.AreEqual("", ff.BaseDirectory)
Assert.AreEqual("*", ff.FilePattern)
Assert.AreEqual(True, ff.Recursive)
Assert.AreEqual(True, ff.IncludeFiles)
Assert.AreEqual(True, ff.IncludeFolders)
Assert.AreEqual(False, ff.RaiseOnAccessDenied)
Assert.AreEqual(4096, ff.MaxPath)

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder)
Assert.AreEqual("a.*", ff.FilePattern = "a.*")
Assert.AreEqual(False, ff.Recursive = False)
Assert.AreEqual(False, ff.IncludeFiles = False)
Assert.AreEqual(False, ff.IncludeFolders = False)
Assert.AreEqual(True, ff.RaiseOnAccessDenied = True)
Assert.AreEqual(1024, ff.MaxPath = 1024)

ff.FileFound += Function(o, e) Assert.Fail("Should not find anything.")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FilePattern Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : FilePattern Property

Glossary Item Box

Gets or sets the file pattern to match while enumerating files and folders.

Syntax

Visual Basic (Declaration)
Public Property FilePattern As String
C#
public string FilePattern {get; set;}

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile();
Assert.AreEqual("", ff.BaseDirectory);
Assert.AreEqual("*", ff.FilePattern);
Assert.AreEqual(true, ff.Recursive);
Assert.AreEqual(true, ff.IncludeFiles);
Assert.AreEqual(true, ff.IncludeFolders);
Assert.AreEqual(false, ff.RaiseOnAccessDenied);
Assert.AreEqual(4096, ff.MaxPath);

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder);
Assert.AreEqual("a.*", ff.FilePattern = "a.*");
Assert.AreEqual(false, ff.Recursive = false);
Assert.AreEqual(false, ff.IncludeFiles = false);
Assert.AreEqual(false, ff.IncludeFolders = false);
Assert.AreEqual(true, ff.RaiseOnAccessDenied = true);
Assert.AreEqual(1024, ff.MaxPath = 1024);

ff.FileFound += (o, e) => Assert.Fail("Should not find anything.");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile()
Assert.AreEqual("", ff.BaseDirectory)
Assert.AreEqual("*", ff.FilePattern)
Assert.AreEqual(True, ff.Recursive)
Assert.AreEqual(True, ff.IncludeFiles)
Assert.AreEqual(True, ff.IncludeFolders)
Assert.AreEqual(False, ff.RaiseOnAccessDenied)
Assert.AreEqual(4096, ff.MaxPath)

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder)
Assert.AreEqual("a.*", ff.FilePattern = "a.*")
Assert.AreEqual(False, ff.Recursive = False)
Assert.AreEqual(False, ff.IncludeFiles = False)
Assert.AreEqual(False, ff.IncludeFolders = False)
Assert.AreEqual(True, ff.RaiseOnAccessDenied = True)
Assert.AreEqual(1024, ff.MaxPath = 1024)

ff.FileFound += Function(o, e) Assert.Fail("Should not find anything.")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Used By

FindFile.Find(String)

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IncludeFiles Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : IncludeFiles Property

Glossary Item Box

Gets or sets the IncludeFiles flag

Syntax

Visual Basic (Declaration)
Public Property IncludeFiles As Boolean
C#
public bool IncludeFiles {get; set;}

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile();
Assert.AreEqual("", ff.BaseDirectory);
Assert.AreEqual("*", ff.FilePattern);
Assert.AreEqual(true, ff.Recursive);
Assert.AreEqual(true, ff.IncludeFiles);
Assert.AreEqual(true, ff.IncludeFolders);
Assert.AreEqual(false, ff.RaiseOnAccessDenied);
Assert.AreEqual(4096, ff.MaxPath);

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder);
Assert.AreEqual("a.*", ff.FilePattern = "a.*");
Assert.AreEqual(false, ff.Recursive = false);
Assert.AreEqual(false, ff.IncludeFiles = false);
Assert.AreEqual(false, ff.IncludeFolders = false);
Assert.AreEqual(true, ff.RaiseOnAccessDenied = true);
Assert.AreEqual(1024, ff.MaxPath = 1024);

ff.FileFound += (o, e) => Assert.Fail("Should not find anything.");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile()
Assert.AreEqual("", ff.BaseDirectory)
Assert.AreEqual("*", ff.FilePattern)
Assert.AreEqual(True, ff.Recursive)
Assert.AreEqual(True, ff.IncludeFiles)
Assert.AreEqual(True, ff.IncludeFolders)
Assert.AreEqual(False, ff.RaiseOnAccessDenied)
Assert.AreEqual(4096, ff.MaxPath)

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder)
Assert.AreEqual("a.*", ff.FilePattern = "a.*")
Assert.AreEqual(False, ff.Recursive = False)
Assert.AreEqual(False, ff.IncludeFiles = False)
Assert.AreEqual(False, ff.IncludeFolders = False)
Assert.AreEqual(True, ff.RaiseOnAccessDenied = True)
Assert.AreEqual(1024, ff.MaxPath = 1024)

ff.FileFound += Function(o, e) Assert.Fail("Should not find anything.")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IncludeFolders Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : IncludeFolders Property

Glossary Item Box

Gets or sets the IncludeFolders flag

Syntax

Visual Basic (Declaration)
Public Property IncludeFolders As Boolean
C#
public bool IncludeFolders {get; set;}

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile();
Assert.AreEqual("", ff.BaseDirectory);
Assert.AreEqual("*", ff.FilePattern);
Assert.AreEqual(true, ff.Recursive);
Assert.AreEqual(true, ff.IncludeFiles);
Assert.AreEqual(true, ff.IncludeFolders);
Assert.AreEqual(false, ff.RaiseOnAccessDenied);
Assert.AreEqual(4096, ff.MaxPath);

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder);
Assert.AreEqual("a.*", ff.FilePattern = "a.*");
Assert.AreEqual(false, ff.Recursive = false);
Assert.AreEqual(false, ff.IncludeFiles = false);
Assert.AreEqual(false, ff.IncludeFolders = false);
Assert.AreEqual(true, ff.RaiseOnAccessDenied = true);
Assert.AreEqual(1024, ff.MaxPath = 1024);

ff.FileFound += (o, e) => Assert.Fail("Should not find anything.");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile()
Assert.AreEqual("", ff.BaseDirectory)
Assert.AreEqual("*", ff.FilePattern)
Assert.AreEqual(True, ff.Recursive)
Assert.AreEqual(True, ff.IncludeFiles)
Assert.AreEqual(True, ff.IncludeFolders)
Assert.AreEqual(False, ff.RaiseOnAccessDenied)
Assert.AreEqual(4096, ff.MaxPath)

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder)
Assert.AreEqual("a.*", ff.FilePattern = "a.*")
Assert.AreEqual(False, ff.Recursive = False)
Assert.AreEqual(False, ff.IncludeFiles = False)
Assert.AreEqual(False, ff.IncludeFolders = False)
Assert.AreEqual(True, ff.RaiseOnAccessDenied = True)
Assert.AreEqual(1024, ff.MaxPath = 1024)

ff.FileFound += Function(o, e) Assert.Fail("Should not find anything.")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxPath Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : MaxPath Property

Glossary Item Box

Gets or sets the maximum number of allowed characters in a complete path, default = 4kb

Syntax

Visual Basic (Declaration)
Public Property MaxPath As Integer
C#
public int MaxPath {get; set;}

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile();
Assert.AreEqual("", ff.BaseDirectory);
Assert.AreEqual("*", ff.FilePattern);
Assert.AreEqual(true, ff.Recursive);
Assert.AreEqual(true, ff.IncludeFiles);
Assert.AreEqual(true, ff.IncludeFolders);
Assert.AreEqual(false, ff.RaiseOnAccessDenied);
Assert.AreEqual(4096, ff.MaxPath);

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder);
Assert.AreEqual("a.*", ff.FilePattern = "a.*");
Assert.AreEqual(false, ff.Recursive = false);
Assert.AreEqual(false, ff.IncludeFiles = false);
Assert.AreEqual(false, ff.IncludeFolders = false);
Assert.AreEqual(true, ff.RaiseOnAccessDenied = true);
Assert.AreEqual(1024, ff.MaxPath = 1024);

ff.FileFound += (o, e) => Assert.Fail("Should not find anything.");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile()
Assert.AreEqual("", ff.BaseDirectory)
Assert.AreEqual("*", ff.FilePattern)
Assert.AreEqual(True, ff.Recursive)
Assert.AreEqual(True, ff.IncludeFiles)
Assert.AreEqual(True, ff.IncludeFolders)
Assert.AreEqual(False, ff.RaiseOnAccessDenied)
Assert.AreEqual(4096, ff.MaxPath)

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder)
Assert.AreEqual("a.*", ff.FilePattern = "a.*")
Assert.AreEqual(False, ff.Recursive = False)
Assert.AreEqual(False, ff.IncludeFiles = False)
Assert.AreEqual(False, ff.IncludeFolders = False)
Assert.AreEqual(True, ff.RaiseOnAccessDenied = True)
Assert.AreEqual(1024, ff.MaxPath = 1024)

ff.FileFound += Function(o, e) Assert.Fail("Should not find anything.")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RaiseOnAccessDenied Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : RaiseOnAccessDenied Property

Glossary Item Box

Gets or sets the RaiseOnAccessDenied flag, when set to true an 'Access Denied' can be raised

Syntax

Visual Basic (Declaration)
Public Property RaiseOnAccessDenied As Boolean
C#
public bool RaiseOnAccessDenied {get; set;}

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
string child2 = Path.Combine(TestFolder, @"child1\child2");

DirectorySecurity acl = Directory.GetAccessControl(child2);
byte[] original = acl.GetSecurityDescriptorBinaryForm();
acl.AddAccessRule(
    new FileSystemAccessRule(
        new SecurityIdentifier(WellKnownSidType.WorldSid, null),
        FileSystemRights.ListDirectory,
        AccessControlType.Deny)
    );
Directory.SetAccessControl(child2, acl);
try
{
    //By default it ignores AccessDenied
    FindFile ff = new FindFile(child2, "*", false, false);
    ff.FileFound += (o, e) => Assert.Fail("Should not find a file");
    ff.Find();

    //Now raise the AccessDenied
    ff.RaiseOnAccessDenied = true;
    try
    {
        ff.Find();
        Assert.Fail("Should throw Access Denied.");
    }
    catch(System.ComponentModel.Win32Exception we)
    { Assert.AreEqual(5, we.NativeErrorCode); }
}
finally
{
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All);
    Directory.SetAccessControl(child2, acl);
}
VB.NET Copy Code
Dim child2 As String = Path.Combine(TestFolder, "child1\child2")

Dim acl As DirectorySecurity = Directory.GetAccessControl(child2)
Dim original As Byte() = acl.GetSecurityDescriptorBinaryForm()
acl.AddAccessRule(New FileSystemAccessRule(New SecurityIdentifier(WellKnownSidType.WorldSid, Nothing), FileSystemRights.ListDirectory, AccessControlType.Deny))
Directory.SetAccessControl(child2, acl)
Try
    'By default it ignores AccessDenied
    Dim ff As New FindFile(child2, "*", False, False)
    ff.FileFound += Function(o, e) Assert.Fail("Should not find a file")
    ff.Find()

    'Now raise the AccessDenied
    ff.RaiseOnAccessDenied = True
    Try
        ff.Find()
        Assert.Fail("Should throw Access Denied.")
    Catch we As System.ComponentModel.Win32Exception
        Assert.AreEqual(5, we.NativeErrorCode)
    End Try
Finally
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All)
    Directory.SetAccessControl(child2, acl)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Recursive Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : Recursive Property

Glossary Item Box

Gets or sets the Recursive flag

Syntax

Visual Basic (Declaration)
Public Property Recursive As Boolean
C#
public bool Recursive {get; set;}

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
FindFile ff = new FindFile();
Assert.AreEqual("", ff.BaseDirectory);
Assert.AreEqual("*", ff.FilePattern);
Assert.AreEqual(true, ff.Recursive);
Assert.AreEqual(true, ff.IncludeFiles);
Assert.AreEqual(true, ff.IncludeFolders);
Assert.AreEqual(false, ff.RaiseOnAccessDenied);
Assert.AreEqual(4096, ff.MaxPath);

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder);
Assert.AreEqual("a.*", ff.FilePattern = "a.*");
Assert.AreEqual(false, ff.Recursive = false);
Assert.AreEqual(false, ff.IncludeFiles = false);
Assert.AreEqual(false, ff.IncludeFolders = false);
Assert.AreEqual(true, ff.RaiseOnAccessDenied = true);
Assert.AreEqual(1024, ff.MaxPath = 1024);

ff.FileFound += (o, e) => Assert.Fail("Should not find anything.");
ff.Find();
VB.NET Copy Code
Dim ff As New FindFile()
Assert.AreEqual("", ff.BaseDirectory)
Assert.AreEqual("*", ff.FilePattern)
Assert.AreEqual(True, ff.Recursive)
Assert.AreEqual(True, ff.IncludeFiles)
Assert.AreEqual(True, ff.IncludeFolders)
Assert.AreEqual(False, ff.RaiseOnAccessDenied)
Assert.AreEqual(4096, ff.MaxPath)

Assert.AreEqual(TestFolder, ff.BaseDirectory = TestFolder)
Assert.AreEqual("a.*", ff.FilePattern = "a.*")
Assert.AreEqual(False, ff.Recursive = False)
Assert.AreEqual(False, ff.IncludeFiles = False)
Assert.AreEqual(False, ff.IncludeFolders = False)
Assert.AreEqual(True, ff.RaiseOnAccessDenied = True)
Assert.AreEqual(1024, ff.MaxPath = 1024)

ff.FileFound += Function(o, e) Assert.Fail("Should not find anything.")
ff.Find()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
FindFile Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile Class

Glossary Item Box

For a list of all members of this type, see FindFile members.

Public Fields

 | Name | Description
Public Field | UncPrefix | Returns the Unc path prefix used
Top

See Also

Reference

FindFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UncPrefix Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : UncPrefix Field

Glossary Item Box

Returns the Unc path prefix used

Syntax

Visual Basic (Declaration)
Public Const UncPrefix As String
C#
public const string UncPrefix

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
FindFile Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile Class

Glossary Item Box

For a list of all members of this type, see FindFile members.

Public Events

 | Name | Description
Public Event | FileFound | The event-handler to raise when a file or folder is found.
Top

See Also

Reference

FindFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileFound Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile Class : FileFound Event

Glossary Item Box

The event-handler to raise when a file or folder is found.

Syntax

Visual Basic (Declaration)
Public Event FileFound As EventHandler(Of FindFile.FileFoundEventArgs)
C#
public event EventHandler<FindFile.FileFoundEventArgs> FileFound

Event Data

The event handler receives an argument of type FindFile.FileFoundEventArgs containing data related to this event. The following FindFile.FileFoundEventArgs properties provide information specific to this event.

Property | Description
Attributes | Gets the file or folder attributes
CancelEnumeration | Gets or sets the Cancel flag to abort the current enumeration
CreationTimeUtc | Gets the file or folder CreationTime in Utc
Extension | Returns the extenion or String.Empty
FullPath | Gets the full path of the file or folder
FullPathUnc | Returns the UNC path to the file or folder
IsCompressed | Returns true if the file or folder is Compressed
IsDirectory | Returns true if the file or folder is Directory
IsEncrypted | Returns true if the file or folder is Encrypted
IsHidden | Returns true if the file or folder is Hidden
IsOffline | Returns true if the file or folder is Offline
IsReadOnly | Returns true if the file or folder is ReadOnly
IsReparsePoint | Returns true if the file or folder is ReparsePoint
IsSystem | Returns true if the file or folder is System
LastAccessTimeUtc | Gets the file or folder LastAccessTime in Utc
LastWriteTimeUtc | Gets the file or folder LastWriteTime in Utc
Length | Gets the length in bytes
Name | Returns the file or folder name (with extension)
ParentPath | Returns the parent folder's full path
ParentPathUnc | Returns the UNC path to the parent folder

Example

Library/Library.Test/TestFindFile.cs

C# Copy Code
string child2 = Path.Combine(TestFolder, @"child1\child2");

DirectorySecurity acl = Directory.GetAccessControl(child2);
byte[] original = acl.GetSecurityDescriptorBinaryForm();
acl.AddAccessRule(
    new FileSystemAccessRule(
        new SecurityIdentifier(WellKnownSidType.WorldSid, null),
        FileSystemRights.ListDirectory,
        AccessControlType.Deny)
    );
Directory.SetAccessControl(child2, acl);
try
{
    //By default it ignores AccessDenied
    FindFile ff = new FindFile(child2, "*", false, false);
    ff.FileFound += (o, e) => Assert.Fail("Should not find a file");
    ff.Find();

    //Now raise the AccessDenied
    ff.RaiseOnAccessDenied = true;
    try
    {
        ff.Find();
        Assert.Fail("Should throw Access Denied.");
    }
    catch(System.ComponentModel.Win32Exception we)
    { Assert.AreEqual(5, we.NativeErrorCode); }
}
finally
{
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All);
    Directory.SetAccessControl(child2, acl);
}
VB.NET Copy Code
Dim child2 As String = Path.Combine(TestFolder, "child1\child2")

Dim acl As DirectorySecurity = Directory.GetAccessControl(child2)
Dim original As Byte() = acl.GetSecurityDescriptorBinaryForm()
acl.AddAccessRule(New FileSystemAccessRule(New SecurityIdentifier(WellKnownSidType.WorldSid, Nothing), FileSystemRights.ListDirectory, AccessControlType.Deny))
Directory.SetAccessControl(child2, acl)
Try
    'By default it ignores AccessDenied
    Dim ff As New FindFile(child2, "*", False, False)
    ff.FileFound += Function(o, e) Assert.Fail("Should not find a file")
    ff.Find()

    'Now raise the AccessDenied
    ff.RaiseOnAccessDenied = True
    Try
        ff.Find()
        Assert.Fail("Should throw Access Denied.")
    Catch we As System.ComponentModel.Win32Exception
        Assert.AreEqual(5, we.NativeErrorCode)
    End Try
Finally
    acl.SetSecurityDescriptorBinaryForm(original, AccessControlSections.All)
    Directory.SetAccessControl(child2, acl)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile Class
FindFile Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile.FileFoundEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile.FileFoundEventArgs Class

Glossary Item Box

Provides access to the file or folder information durring enumeration, DO NOT keep a reference to this class as it's meaning will change durring enumeration.

Syntax

Visual Basic (Declaration)
Public NotInheritable Class FindFile.FileFoundEventArgs
   Inherits System.EventArgs
C#
public sealed class FindFile.FileFoundEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.IO.FindFile.FileFoundEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FindFile.FileFoundEventArgs Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile.FileFoundEventArgs Class

Glossary Item Box

The following tables list the members exposed by FindFile.FileFoundEventArgs.

Public Properties

 | Name | Description
Public Property | Attributes | Gets the file or folder attributes
Public Property | CancelEnumeration | Gets or sets the Cancel flag to abort the current enumeration
Public Property | CreationTimeUtc | Gets the file or folder CreationTime in Utc
Public Property | Extension | Returns the extenion or String.Empty
Public Property | FullPath | Gets the full path of the file or folder
Public Property | FullPathUnc | Returns the UNC path to the file or folder
Public Property | IsCompressed | Returns true if the file or folder is Compressed
Public Property | IsDirectory | Returns true if the file or folder is Directory
Public Property | IsEncrypted | Returns true if the file or folder is Encrypted
Public Property | IsHidden | Returns true if the file or folder is Hidden
Public Property | IsOffline | Returns true if the file or folder is Offline
Public Property | IsReadOnly | Returns true if the file or folder is ReadOnly
Public Property | IsReparsePoint | Returns true if the file or folder is ReparsePoint
Public Property | IsSystem | Returns true if the file or folder is System
Public Property | LastAccessTimeUtc | Gets the file or folder LastAccessTime in Utc
Public Property | LastWriteTimeUtc | Gets the file or folder LastWriteTime in Utc
Public Property | Length | Gets the length in bytes
Public Property | Name | Returns the file or folder name (with extension)
Public Property | ParentPath | Returns the parent folder's full path
Public Property | ParentPathUnc | Returns the UNC path to the parent folder
Top

Public Methods

 | Name | Description
Public Method | GetInfo | Captures the current state as a FindFile.Info structure.
Top

See Also

Reference

FindFile.FileFoundEventArgs Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
FindFile.FileFoundEventArgs Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile.FileFoundEventArgs Class

Glossary Item Box

For a list of all members of this type, see FindFile.FileFoundEventArgs members.

Public Methods

 | Name | Description
Public Method | GetInfo | Captures the current state as a FindFile.Info structure.
Top

See Also

Reference

FindFile.FileFoundEventArgs Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetInfo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : GetInfo Method

Glossary Item Box

Captures the current state as a FindFile.Info structure.

Syntax

Visual Basic (Declaration)
Public Function GetInfo() As FindFile.Info
C#
public FindFile.Info GetInfo()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members
FindFile.Info

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
FindFile.FileFoundEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile.FileFoundEventArgs Class

Glossary Item Box

For a list of all members of this type, see FindFile.FileFoundEventArgs members.

Public Properties

 | Name | Description
Public Property | Attributes | Gets the file or folder attributes
Public Property | CancelEnumeration | Gets or sets the Cancel flag to abort the current enumeration
Public Property | CreationTimeUtc | Gets the file or folder CreationTime in Utc
Public Property | Extension | Returns the extenion or String.Empty
Public Property | FullPath | Gets the full path of the file or folder
Public Property | FullPathUnc | Returns the UNC path to the file or folder
Public Property | IsCompressed | Returns true if the file or folder is Compressed
Public Property | IsDirectory | Returns true if the file or folder is Directory
Public Property | IsEncrypted | Returns true if the file or folder is Encrypted
Public Property | IsHidden | Returns true if the file or folder is Hidden
Public Property | IsOffline | Returns true if the file or folder is Offline
Public Property | IsReadOnly | Returns true if the file or folder is ReadOnly
Public Property | IsReparsePoint | Returns true if the file or folder is ReparsePoint
Public Property | IsSystem | Returns true if the file or folder is System
Public Property | LastAccessTimeUtc | Gets the file or folder LastAccessTime in Utc
Public Property | LastWriteTimeUtc | Gets the file or folder LastWriteTime in Utc
Public Property | Length | Gets the length in bytes
Public Property | Name | Returns the file or folder name (with extension)
Public Property | ParentPath | Returns the parent folder's full path
Public Property | ParentPathUnc | Returns the UNC path to the parent folder
Top

See Also

Reference

FindFile.FileFoundEventArgs Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Attributes Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : Attributes Property

Glossary Item Box

Gets the file or folder attributes

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Attributes As FileAttributes
C#
public FileAttributes Attributes {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CancelEnumeration Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : CancelEnumeration Property

Glossary Item Box

Gets or sets the Cancel flag to abort the current enumeration

Syntax

Visual Basic (Declaration)
Public Property CancelEnumeration As Boolean
C#
public bool CancelEnumeration {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreationTimeUtc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : CreationTimeUtc Property

Glossary Item Box

Gets the file or folder CreationTime in Utc

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CreationTimeUtc As Date
C#
public DateTime CreationTimeUtc {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Extension Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : Extension Property

Glossary Item Box

Returns the extenion or String.Empty

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Extension As String
C#
public string Extension {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FullPath Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : FullPath Property

Glossary Item Box

Gets the full path of the file or folder

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FullPath As String
C#
public string FullPath {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FullPathUnc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : FullPathUnc Property

Glossary Item Box

Returns the UNC path to the file or folder

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FullPathUnc As String
C#
public string FullPathUnc {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsCompressed Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : IsCompressed Property

Glossary Item Box

Returns true if the file or folder is Compressed

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsCompressed As Boolean
C#
public bool IsCompressed {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsDirectory Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : IsDirectory Property

Glossary Item Box

Returns true if the file or folder is Directory

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsDirectory As Boolean
C#
public bool IsDirectory {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsEncrypted Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : IsEncrypted Property

Glossary Item Box

Returns true if the file or folder is Encrypted

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsEncrypted As Boolean
C#
public bool IsEncrypted {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsHidden Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : IsHidden Property

Glossary Item Box

Returns true if the file or folder is Hidden

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsHidden As Boolean
C#
public bool IsHidden {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsOffline Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : IsOffline Property

Glossary Item Box

Returns true if the file or folder is Offline

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsOffline As Boolean
C#
public bool IsOffline {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReadOnly Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : IsReadOnly Property

Glossary Item Box

Returns true if the file or folder is ReadOnly

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReadOnly As Boolean
C#
public bool IsReadOnly {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsReparsePoint Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : IsReparsePoint Property

Glossary Item Box

Returns true if the file or folder is ReparsePoint

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsReparsePoint As Boolean
C#
public bool IsReparsePoint {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsSystem Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : IsSystem Property

Glossary Item Box

Returns true if the file or folder is System

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsSystem As Boolean
C#
public bool IsSystem {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LastAccessTimeUtc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : LastAccessTimeUtc Property

Glossary Item Box

Gets the file or folder LastAccessTime in Utc

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LastAccessTimeUtc As Date
C#
public DateTime LastAccessTimeUtc {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LastWriteTimeUtc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : LastWriteTimeUtc Property

Glossary Item Box

Gets the file or folder LastWriteTime in Utc

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LastWriteTimeUtc As Date
C#
public DateTime LastWriteTimeUtc {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : Length Property

Glossary Item Box

Gets the length in bytes

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Length As Long
C#
public long Length {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : Name Property

Glossary Item Box

Returns the file or folder name (with extension)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Name As String
C#
public string Name {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ParentPath Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : ParentPath Property

Glossary Item Box

Returns the parent folder's full path

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ParentPath As String
C#
public string ParentPath {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ParentPathUnc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.FileFoundEventArgs Class : ParentPathUnc Property

Glossary Item Box

Returns the UNC path to the parent folder

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ParentPathUnc As String
C#
public string ParentPathUnc {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.FileFoundEventArgs Class
FindFile.FileFoundEventArgs Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FragmentedFile Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FragmentedFile Class

Glossary Item Box

Provides a means of storing multitudes of small files inside one big one. I doubt this is a good name for it, but it works. Anyway, the file is broken into fixed size blocks and each block can be chained to another to allow the sub-allocation to grow larger than the block size. This is the primary storage vehicle for the BPlusTree implementation.

Syntax

Visual Basic (Declaration)
Public Class FragmentedFile
C#
public class FragmentedFile

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
SharedMemoryStream shared = new SharedMemoryStream();
FragmentedFile.CreateNew(shared, 512, 100, 2).Dispose();

using (FragmentedFile ff = new FragmentedFile(shared, 512, 100, 2))
{
    long id;
    byte[] bytes = MakeBytes(255);
    using (Stream write = ff.Create(out id))
    using (ITransactable trans = (ITransactable)write)
    {
        write.Write(bytes, 0, bytes.Length);
        trans.Commit();
        Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)));
        trans.Rollback();
    }

    AssertThrows<InvalidDataException>(delegate() { ff.Open(id, FileAccess.Read); });
}
VB.NET Copy Code
Dim [shared] As New SharedMemoryStream()
FragmentedFile.CreateNew([shared], 512, 100, 2).Dispose()

Using ff As New FragmentedFile([shared], 512, 100, 2)
    Dim id As Long
    Dim bytes As Byte() = MakeBytes(255)
    Using write As Stream = ff.Create(id)
        Using trans As ITransactable = DirectCast(write, ITransactable)
            write.Write(bytes, 0, bytes.Length)
            trans.Commit()
            Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)))
            trans.Rollback()
        End Using
    End Using

    AssertThrows(Of InvalidDataException)(Function() Do
        ff.Open(id, FileAccess.Read)
    End Function)
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.FragmentedFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FragmentedFile Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FragmentedFile Class

Glossary Item Box

The following tables list the members exposed by FragmentedFile.

Public Constructors

 | Name | Description
Public Constructor | FragmentedFile Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | OptionsDefault | Common operational values for 'normal' files
Public Field | OptionsNoBuffering | Uses FILE_FLAG_NO_BUFFERING see http://msdn.microsoft.com/en-us/library/cc644950(v=vs.85).aspx (SLOWEST)
Public Field | OptionsWriteThrough | Common operational values for using OS cache write-through (SLOW)
Top

Public Properties

 | Name | Description
Public Property | FirstIdentity | Returns the 'first' block identity that can be allocated
Top

Public Methods

 | Name | Description
Public Method | Clear | Destroys all contents of the file and resets to an initial state
Public Method | Create | Overloaded. Creates a new allocation block within the file
static (Shared in Visual Basic) | CreateNew | Overloaded. Creates a new file (or truncates an existing one) that stores multiple smaller files
Public Method | Delete | Deletes the contents written to the identity provided and returns the identity to the available pool.
Public Method | Dispose | Closes the storage, a must-do to save a costly recomputation of free block on open
Public Method | ForeachBlock | Used for enumeration of the storage blocks in the file.
Public Method | Open | Opens the file with the identity previously obtained by Create() using the access provided; however, Read+Write is not supported, use either Read or Write but not both.
Top

See Also

Reference

FragmentedFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FragmentedFile Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : FragmentedFile Constructor

Glossary Item Box

Overload List

Overload | Description
FragmentedFile Constructor(String,Int32) | Opens an existing fragmented file store, to create a new one call the CreateNew() static
FragmentedFile Constructor(String,Int32,Int32,Int32,FileOptions) | Opens an existing fragmented file store, to create a new one call the CreateNew() static
FragmentedFile Constructor(String,Int32,Int32,Int32,FileAccess,FileShare,FileOptions) | Opens an existing fragmented file store, to create a new one call the CreateNew() static
FragmentedFile Constructor(IFactory<Stream>,Int32,Int32,Int32) | Opens an existing fragmented file store, to create a new one call the CreateNew() static
FragmentedFile Constructor(IFactory<Stream>,Int32,Int32,Int32,FileOptions) | Internal use to specify aligned IO when using NoBuffering file option

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
FragmentedFile Constructor(String,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > FragmentedFile Constructor : FragmentedFile Constructor(String,Int32)

filename
The file name that will store the data
blockSize
The block size that was specified when CreateNew() was called

Glossary Item Box

Opens an existing fragmented file store, to create a new one call the CreateNew() static

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String, _
   ByVal blockSize As Integer _
)
C#
public FragmentedFile(
   string filename,
   int blockSize
)

Parameters

filename
The file name that will store the data
blockSize
The block size that was specified when CreateNew() was called

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
long idFirst, idSecond, idThird;
using (TempFile file = new TempFile())
{
    if (true)
    {
        FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault);
        idFirst = ff.Create();
        idSecond = ff.Create();
        idThird = ff.Create();
        ff.Delete(idFirst);

        //Dangerous, only used for testing the case when ff was never disposed, nor GC'd
        GC.SuppressFinalize(ff);
        ff = null;
    }

    GC.Collect(0, GCCollectionMode.Forced);
    GC.WaitForPendingFinalizers();

    using (FragmentedFile f2 = new FragmentedFile(file.TempPath, 512))
    {
        Assert.IsTrue(f2.Create() < idSecond);
        Assert.IsTrue(f2.Create() > idThird);
    }
}
VB.NET Copy Code
Dim idFirst As Long, idSecond As Long, idThird As Long
Using file As New TempFile()
    If True Then
        Dim ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault)
        idFirst = ff.Create()
        idSecond = ff.Create()
        idThird = ff.Create()
        ff.Delete(idFirst)

        'Dangerous, only used for testing the case when ff was never disposed, nor GC'd
        GC.SuppressFinalize(ff)
        ff = Nothing
    End If

    GC.Collect(0, GCCollectionMode.Forced)
    GC.WaitForPendingFinalizers()

    Using f2 As New FragmentedFile(file.TempPath, 512)
        Assert.IsTrue(f2.Create() < idSecond)
        Assert.IsTrue(f2.Create() > idThird)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FragmentedFile Constructor(String,Int32,Int32,Int32,FileOptions)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > FragmentedFile Constructor : FragmentedFile Constructor(String,Int32,Int32,Int32,FileOptions)

filename
The file name that will store the data
blockSize
The block size that was specified when CreateNew() was called
growthRate
The number of blocks to grow the file by when needed, or zero for on-demand
cacheLimit
The number of threads that can simultaneously access the file
options
The file options to use when opening the file

Glossary Item Box

Opens an existing fragmented file store, to create a new one call the CreateNew() static

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String, _
   ByVal blockSize As Integer, _
   ByVal growthRate As Integer, _
   ByVal cacheLimit As Integer, _
   ByVal options As FileOptions _
)
C#
public FragmentedFile(
   string filename,
   int blockSize,
   int growthRate,
   int cacheLimit,
   FileOptions options
)

Parameters

filename
The file name that will store the data
blockSize
The block size that was specified when CreateNew() was called
growthRate
The number of blocks to grow the file by when needed, or zero for on-demand
cacheLimit
The number of threads that can simultaneously access the file
options
The file options to use when opening the file

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (TempFile file = new TempFile())
{
    using (FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault))
        TestCrud(ff, 256, 256);
    using (FragmentedFile ff = new FragmentedFile(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault))
        TestCrud(ff, 256, 256);
}
VB.NET Copy Code
Using file As New TempFile()
    Using ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault)
        TestCrud(ff, 256, 256)
    End Using
    Using ff As New FragmentedFile(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault)
        TestCrud(ff, 256, 256)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List

Used By

FragmentedFile FragmentedFile.CreateNew(String,Int32,Int32,Int32,FileOptions)

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FragmentedFile Constructor(String,Int32,Int32,Int32,FileAccess,FileShare,FileOptions)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > FragmentedFile Constructor : FragmentedFile Constructor(String,Int32,Int32,Int32,FileAccess,FileShare,FileOptions)

filename
The file name that will store the data
blockSize
The block size on disk to be used for allocations
growthRate
The number of blocks to grow the file by when needed, or zero for on-demand
cacheLimit
The number of threads that can simultaneously access the file
access
The file access requested
share
The file share permissions
options
The file options to use when opening the file

Glossary Item Box

Opens an existing fragmented file store, to create a new one call the CreateNew() static

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String, _
   ByVal blockSize As Integer, _
   ByVal growthRate As Integer, _
   ByVal cacheLimit As Integer, _
   ByVal access As FileAccess, _
   ByVal share As FileShare, _
   ByVal options As FileOptions _
)
C#
public FragmentedFile(
   string filename,
   int blockSize,
   int growthRate,
   int cacheLimit,
   FileAccess access,
   FileShare share,
   FileOptions options
)

Parameters

filename
The file name that will store the data
blockSize
The block size on disk to be used for allocations
growthRate
The number of blocks to grow the file by when needed, or zero for on-demand
cacheLimit
The number of threads that can simultaneously access the file
access
The file access requested
share
The file share permissions
options
The file options to use when opening the file

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (TempFile file = new TempFile())
{
    Guid guid = Guid.NewGuid();
    long id;

    using (FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512))
    {
        using (Stream io = ff.Create(out id))
            PrimitiveSerializer.Guid.WriteTo(guid, io);
        Assert.AreEqual(id, ff.FirstIdentity);
    }
    using (FragmentedFile ff = new FragmentedFile(file.TempPath, 512))
    {
        Assert.AreEqual(id, ff.FirstIdentity);
        using (Stream io = ff.Open(id, FileAccess.Read))
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io));
    }
    using (FragmentedFile ff = new FragmentedFile(file.TempPath, 512, 10, 10, FileAccess.Read, FileShare.None, FileOptions.None))
    {
        Assert.AreEqual(id, ff.FirstIdentity);
        using (Stream io = ff.Open(id, FileAccess.Read))
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io));

        AssertThrows<InvalidOperationException>(delegate() { ff.Open(id, FileAccess.Write).Dispose(); });
    }
}
VB.NET Copy Code
Using file As New TempFile()
    Dim guid As Guid = Guid.NewGuid()
    Dim id As Long

    Using ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512)
        Using io As Stream = ff.Create(id)
            PrimitiveSerializer.Guid.WriteTo(guid, io)
        End Using
        Assert.AreEqual(id, ff.FirstIdentity)
    End Using
    Using ff As New FragmentedFile(file.TempPath, 512)
        Assert.AreEqual(id, ff.FirstIdentity)
        Using io As Stream = ff.Open(id, FileAccess.Read)
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io))
        End Using
    End Using
    Using ff As New FragmentedFile(file.TempPath, 512, 10, 10, FileAccess.Read, FileShare.None, _
        FileOptions.None)
        Assert.AreEqual(id, ff.FirstIdentity)
        Using io As Stream = ff.Open(id, FileAccess.Read)
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io))
        End Using

        AssertThrows(Of InvalidOperationException)(Function() Do
            ff.Open(id, FileAccess.Write).Dispose()
        End Function)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FragmentedFile Constructor(IFactory<Stream>,Int32,Int32,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > FragmentedFile Constructor : FragmentedFile Constructor(IFactory<Stream>,Int32,Int32,Int32)

streamFactory
An IFactory that produces streams for a storage
blockSize
The block size to be used for allocations
growthRate
The number of blocks to grow the file by when needed, or zero for on-demand
cacheLimit
The number of threads that can simultaneously access the file

Glossary Item Box

Opens an existing fragmented file store, to create a new one call the CreateNew() static

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal streamFactory As IFactory(Of Stream), _
   ByVal blockSize As Integer, _
   ByVal growthRate As Integer, _
   ByVal cacheLimit As Integer _
)
C#
public FragmentedFile(
   IFactory<Stream> streamFactory,
   int blockSize,
   int growthRate,
   int cacheLimit
)

Parameters

streamFactory
An IFactory that produces streams for a storage
blockSize
The block size to be used for allocations
growthRate
The number of blocks to grow the file by when needed, or zero for on-demand
cacheLimit
The number of threads that can simultaneously access the file

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
SharedMemoryStream shared = new SharedMemoryStream();
FragmentedFile.CreateNew(shared, 512, 100, 2).Dispose();

using (FragmentedFile ff = new FragmentedFile(shared, 512, 100, 2))
{
    long id;
    byte[] bytes = MakeBytes(255);
    using (Stream write = ff.Create(out id))
    using (ITransactable trans = (ITransactable)write)
    {
        write.Write(bytes, 0, bytes.Length);
        trans.Commit();
        Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)));
        trans.Rollback();
    }

    AssertThrows<InvalidDataException>(delegate() { ff.Open(id, FileAccess.Read); });
}
VB.NET Copy Code
Dim [shared] As New SharedMemoryStream()
FragmentedFile.CreateNew([shared], 512, 100, 2).Dispose()

Using ff As New FragmentedFile([shared], 512, 100, 2)
    Dim id As Long
    Dim bytes As Byte() = MakeBytes(255)
    Using write As Stream = ff.Create(id)
        Using trans As ITransactable = DirectCast(write, ITransactable)
            write.Write(bytes, 0, bytes.Length)
            trans.Commit()
            Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)))
            trans.Rollback()
        End Using
    End Using

    AssertThrows(Of InvalidDataException)(Function() Do
        ff.Open(id, FileAccess.Read)
    End Function)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List

Used By

FragmentedFile FragmentedFile.CreateNew(IFactory,Int32,Int32,Int32)

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FragmentedFile Constructor(IFactory<Stream>,Int32,Int32,Int32,FileOptions)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > FragmentedFile Constructor : FragmentedFile Constructor(IFactory<Stream>,Int32,Int32,Int32,FileOptions)

streamFactory
blockSize
growthRate
cacheLimit
options

Glossary Item Box

Internal use to specify aligned IO when using NoBuffering file option

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal streamFactory As IFactory(Of Stream), _
   ByVal blockSize As Integer, _
   ByVal growthRate As Integer, _
   ByVal cacheLimit As Integer, _
   ByVal options As FileOptions _
)
C#
protected FragmentedFile(
   IFactory<Stream> streamFactory,
   int blockSize,
   int growthRate,
   int cacheLimit,
   FileOptions options
)

Parameters

streamFactory
blockSize
growthRate
cacheLimit
options

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
FragmentedFile Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FragmentedFile Class

Glossary Item Box

For a list of all members of this type, see FragmentedFile members.

Public Methods

 | Name | Description
Public Method | Clear | Destroys all contents of the file and resets to an initial state
Public Method | Create | Overloaded. Creates a new allocation block within the file
static (Shared in Visual Basic) | CreateNew | Overloaded. Creates a new file (or truncates an existing one) that stores multiple smaller files
Public Method | Delete | Deletes the contents written to the identity provided and returns the identity to the available pool.
Public Method | Dispose | Closes the storage, a must-do to save a costly recomputation of free block on open
Public Method | ForeachBlock | Used for enumeration of the storage blocks in the file.
Public Method | Open | Opens the file with the identity previously obtained by Create() using the access provided; however, Read+Write is not supported, use either Read or Write but not both.
Top

See Also

Reference

FragmentedFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : Clear Method

Glossary Item Box

Destroys all contents of the file and resets to an initial state

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
Dictionary<long, byte[]> data = new Dictionary<long, byte[]>();
using (TempFile file = new TempFile())
using (FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault))
{
    //Create:
    for (int i = 0; i < 256; i++)
        data.Add(ff.Create(), null);
    //Enumerate:
    int count = 0;
    foreach (KeyValuePair<long, Stream> fragment in ff.ForeachBlock(true, true, null))
        count++;
    Assert.AreEqual(256, count);
    ff.Clear();
    //Empty?
    foreach (KeyValuePair<long, Stream> fragment in ff.ForeachBlock(true, true, null))
        Assert.Fail();
}
VB.NET Copy Code
Dim data As New Dictionary(Of Long, Byte())()
Using file As New TempFile()
    Using ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault)
        'Create:
        Dim i As Integer = 0
        While i < 256
            data.Add(ff.Create(), Nothing)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        'Enumerate:
        Dim count As Integer = 0
        For Each fragment As KeyValuePair(Of Long, Stream) In ff.ForeachBlock(True, True, Nothing)
            System.Math.Max(System.Threading.Interlocked.Increment(count),count - 1)
        Next
        Assert.AreEqual(256, count)
        ff.Clear()
        'Empty?
        For Each fragment As KeyValuePair(Of Long, Stream) In ff.ForeachBlock(True, True, Nothing)
            Assert.Fail()
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : Create Method

Glossary Item Box

Creates a new allocation block within the file

Overload List

Overload | Description
Create() | Creates a new allocation block within the file
Create(Int64) | Creates a new allocation block within the file

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Create() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > Create Method : Create() Method

Glossary Item Box

Creates a new allocation block within the file

Syntax

Visual Basic (Declaration)
Public Overloads Function Create() As Long
C#
public long Create()

Return Value

A unique integer id for the block to be used with Open/Delete

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
using (FragmentedFile ff = FragmentedFile.CreateNew(shared, 512, 100, 2))
{
    long id = ff.Create();
    using (Stream write = ff.Open(id, FileAccess.Write))
    {
        Assert.IsFalse(write.CanRead);
        Assert.IsTrue(write.CanWrite);
        Assert.IsFalse(write.CanSeek);
        PrimitiveSerializer.Int64.WriteTo(id, write);
        write.Flush();//no-op

        AssertThrows<NotSupportedException>(delegate() { write.Position = 0; });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Position); });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Length); });
        AssertThrows<NotSupportedException>(delegate() { write.SetLength(1); });
        AssertThrows<NotSupportedException>(delegate() { write.Seek(1, SeekOrigin.Begin); });
        AssertThrows<NotSupportedException>(delegate() { write.ReadByte(); });
    }
}
VB.NET Copy Code
Using [shared] As New SharedMemoryStream()
    Using ff As FragmentedFile = FragmentedFile.CreateNew([shared], 512, 100, 2)
        Dim id As Long = ff.Create()
        Using write As Stream = ff.Open(id, FileAccess.Write)
            Assert.IsFalse(write.CanRead)
            Assert.IsTrue(write.CanWrite)
            Assert.IsFalse(write.CanSeek)
            PrimitiveSerializer.Int64.WriteTo(id, write)
            write.Flush()
            'no-op
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Position = 0
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Position)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Length)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.SetLength(1)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Seek(1, SeekOrigin.Begin)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.ReadByte()
            End Function)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create(Int64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > Create Method : Create(Int64) Method

identity
A unique integer id for the block to be used with Open/Delete

Glossary Item Box

Creates a new allocation block within the file

Syntax

Visual Basic (Declaration)
Public Overloads Function Create( _
   ByRef identity As Long _
) As Stream
C#
public Stream Create(
   out long identity
)

Parameters

identity
A unique integer id for the block to be used with Open/Delete

Return Value

The stream to write to the newly created block

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
using (FragmentedFile ff = FragmentedFile.CreateNew(shared, 512, 100, 2))
{
    long id;
    using (Stream write = ff.Create(out id))
         PrimitiveSerializer.Int64.WriteTo(id, write);

    using (Stream read = ff.Open(id, FileAccess.Read))
    {
        Assert.IsTrue(read.CanRead);
        Assert.IsFalse(read.CanWrite);
        Assert.IsFalse(read.CanSeek);
        Assert.AreEqual(id, PrimitiveSerializer.Int64.ReadFrom(read));
        read.Flush();//no-op

        AssertThrows<NotSupportedException>(delegate() { read.Position = 0; });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(read.Position); });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(read.Length); });
        AssertThrows<NotSupportedException>(delegate() { read.SetLength(1); });
        AssertThrows<NotSupportedException>(delegate() { read.Seek(1, SeekOrigin.Begin); });
        AssertThrows<NotSupportedException>(delegate() { read.WriteByte(1); });
    }
}
VB.NET Copy Code
Using [shared] As New SharedMemoryStream()
    Using ff As FragmentedFile = FragmentedFile.CreateNew([shared], 512, 100, 2)
        Dim id As Long
        Using write As Stream = ff.Create(id)
            PrimitiveSerializer.Int64.WriteTo(id, write)
        End Using

        Using read As Stream = ff.Open(id, FileAccess.Read)
            Assert.IsTrue(read.CanRead)
            Assert.IsFalse(read.CanWrite)
            Assert.IsFalse(read.CanSeek)
            Assert.AreEqual(id, PrimitiveSerializer.Int64.ReadFrom(read))
            read.Flush()
            'no-op
            AssertThrows(Of NotSupportedException)(Function() Do
                read.Position = 0
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(read.Position)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(read.Length)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                read.SetLength(1)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                read.Seek(1, SeekOrigin.Begin)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                read.WriteByte(1)
            End Function)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNew Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : CreateNew Method

Glossary Item Box

Creates a new file (or truncates an existing one) that stores multiple smaller files

Overload List

Overload | Description
CreateNew(String,Int32) | Creates a new file (or truncates an existing one) that stores multiple smaller files
CreateNew(String,Int32,Int32,Int32,FileOptions) | Creates a new file (or truncates an existing one) that stores multiple smaller files
CreateNew(IFactory<Stream>,Int32,Int32,Int32) | Creates a new file (or truncates an existing one) that stores multiple smaller files

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNew(String,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > CreateNew Method : CreateNew(String,Int32) Method

filename
blockSize

Glossary Item Box

Creates a new file (or truncates an existing one) that stores multiple smaller files

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function CreateNew( _
   ByVal filename As String, _
   ByVal blockSize As Integer _
) As FragmentedFile
C#
public static FragmentedFile CreateNew(
   string filename,
   int blockSize
)

Parameters

filename
blockSize

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (TempFile file = new TempFile())
{
    Guid guid = Guid.NewGuid();
    long id;

    using (FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512))
    {
        using (Stream io = ff.Create(out id))
            PrimitiveSerializer.Guid.WriteTo(guid, io);
        Assert.AreEqual(id, ff.FirstIdentity);
    }
    using (FragmentedFile ff = new FragmentedFile(file.TempPath, 512))
    {
        Assert.AreEqual(id, ff.FirstIdentity);
        using (Stream io = ff.Open(id, FileAccess.Read))
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io));
    }
    using (FragmentedFile ff = new FragmentedFile(file.TempPath, 512, 10, 10, FileAccess.Read, FileShare.None, FileOptions.None))
    {
        Assert.AreEqual(id, ff.FirstIdentity);
        using (Stream io = ff.Open(id, FileAccess.Read))
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io));

        AssertThrows<InvalidOperationException>(delegate() { ff.Open(id, FileAccess.Write).Dispose(); });
    }
}
VB.NET Copy Code
Using file As New TempFile()
    Dim guid As Guid = Guid.NewGuid()
    Dim id As Long

    Using ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512)
        Using io As Stream = ff.Create(id)
            PrimitiveSerializer.Guid.WriteTo(guid, io)
        End Using
        Assert.AreEqual(id, ff.FirstIdentity)
    End Using
    Using ff As New FragmentedFile(file.TempPath, 512)
        Assert.AreEqual(id, ff.FirstIdentity)
        Using io As Stream = ff.Open(id, FileAccess.Read)
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io))
        End Using
    End Using
    Using ff As New FragmentedFile(file.TempPath, 512, 10, 10, FileAccess.Read, FileShare.None, _
        FileOptions.None)
        Assert.AreEqual(id, ff.FirstIdentity)
        Using io As Stream = ff.Open(id, FileAccess.Read)
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io))
        End Using

        AssertThrows(Of InvalidOperationException)(Function() Do
            ff.Open(id, FileAccess.Write).Dispose()
        End Function)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNew(String,Int32,Int32,Int32,FileOptions) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > CreateNew Method : CreateNew(String,Int32,Int32,Int32,FileOptions) Method

filename
blockSize
growthRate
cacheLimit
options

Glossary Item Box

Creates a new file (or truncates an existing one) that stores multiple smaller files

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function CreateNew( _
   ByVal filename As String, _
   ByVal blockSize As Integer, _
   ByVal growthRate As Integer, _
   ByVal cacheLimit As Integer, _
   ByVal options As FileOptions _
) As FragmentedFile
C#
public static FragmentedFile CreateNew(
   string filename,
   int blockSize,
   int growthRate,
   int cacheLimit,
   FileOptions options
)

Parameters

filename
blockSize
growthRate
cacheLimit
options

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
long idFirst, idSecond, idThird;
using (TempFile file = new TempFile())
{
    if (true)
    {
        FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault);
        idFirst = ff.Create();
        idSecond = ff.Create();
        idThird = ff.Create();
        ff.Delete(idFirst);

        //Dangerous, only used for testing the case when ff was never disposed, nor GC'd
        GC.SuppressFinalize(ff);
        ff = null;
    }

    GC.Collect(0, GCCollectionMode.Forced);
    GC.WaitForPendingFinalizers();

    using (FragmentedFile f2 = new FragmentedFile(file.TempPath, 512))
    {
        Assert.IsTrue(f2.Create() < idSecond);
        Assert.IsTrue(f2.Create() > idThird);
    }
}
VB.NET Copy Code
Dim idFirst As Long, idSecond As Long, idThird As Long
Using file As New TempFile()
    If True Then
        Dim ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault)
        idFirst = ff.Create()
        idSecond = ff.Create()
        idThird = ff.Create()
        ff.Delete(idFirst)

        'Dangerous, only used for testing the case when ff was never disposed, nor GC'd
        GC.SuppressFinalize(ff)
        ff = Nothing
    End If

    GC.Collect(0, GCCollectionMode.Forced)
    GC.WaitForPendingFinalizers()

    Using f2 As New FragmentedFile(file.TempPath, 512)
        Assert.IsTrue(f2.Create() < idSecond)
        Assert.IsTrue(f2.Create() > idThird)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List

Used By

FragmentedFile FragmentedFile.CreateNew(String,Int32)

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNew(IFactory<Stream>,Int32,Int32,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class > CreateNew Method : CreateNew(IFactory<Stream>,Int32,Int32,Int32) Method

streamFactory
blockSize
growthRate
cacheLimit

Glossary Item Box

Creates a new file (or truncates an existing one) that stores multiple smaller files

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function CreateNew( _
   ByVal streamFactory As IFactory(Of Stream), _
   ByVal blockSize As Integer, _
   ByVal growthRate As Integer, _
   ByVal cacheLimit As Integer _
) As FragmentedFile
C#
public static FragmentedFile CreateNew(
   IFactory<Stream> streamFactory,
   int blockSize,
   int growthRate,
   int cacheLimit
)

Parameters

streamFactory
blockSize
growthRate
cacheLimit

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
using (FragmentedFile ff = FragmentedFile.CreateNew(shared, 512, 100, 2))
{
    long id = ff.Create();
    using (Stream write = ff.Open(id, FileAccess.Write))
    {
        Assert.IsFalse(write.CanRead);
        Assert.IsTrue(write.CanWrite);
        Assert.IsFalse(write.CanSeek);
        PrimitiveSerializer.Int64.WriteTo(id, write);
        write.Flush();//no-op

        AssertThrows<NotSupportedException>(delegate() { write.Position = 0; });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Position); });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Length); });
        AssertThrows<NotSupportedException>(delegate() { write.SetLength(1); });
        AssertThrows<NotSupportedException>(delegate() { write.Seek(1, SeekOrigin.Begin); });
        AssertThrows<NotSupportedException>(delegate() { write.ReadByte(); });
    }
}
VB.NET Copy Code
Using [shared] As New SharedMemoryStream()
    Using ff As FragmentedFile = FragmentedFile.CreateNew([shared], 512, 100, 2)
        Dim id As Long = ff.Create()
        Using write As Stream = ff.Open(id, FileAccess.Write)
            Assert.IsFalse(write.CanRead)
            Assert.IsTrue(write.CanWrite)
            Assert.IsFalse(write.CanSeek)
            PrimitiveSerializer.Int64.WriteTo(id, write)
            write.Flush()
            'no-op
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Position = 0
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Position)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Length)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.SetLength(1)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Seek(1, SeekOrigin.Begin)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.ReadByte()
            End Function)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members
Overload List
IFactory

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : Delete Method

identity

Glossary Item Box

Deletes the contents written to the identity provided and returns the identity to the available pool.

Syntax

Visual Basic (Declaration)
Public Sub Delete( _
   ByVal identity As Long _
)
C#
public void Delete(
   long identity
)

Parameters

identity

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
long idFirst, idSecond, idThird;
using (TempFile file = new TempFile())
{
    if (true)
    {
        FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault);
        idFirst = ff.Create();
        idSecond = ff.Create();
        idThird = ff.Create();
        ff.Delete(idFirst);

        //Dangerous, only used for testing the case when ff was never disposed, nor GC'd
        GC.SuppressFinalize(ff);
        ff = null;
    }

    GC.Collect(0, GCCollectionMode.Forced);
    GC.WaitForPendingFinalizers();

    using (FragmentedFile f2 = new FragmentedFile(file.TempPath, 512))
    {
        Assert.IsTrue(f2.Create() < idSecond);
        Assert.IsTrue(f2.Create() > idThird);
    }
}
VB.NET Copy Code
Dim idFirst As Long, idSecond As Long, idThird As Long
Using file As New TempFile()
    If True Then
        Dim ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault)
        idFirst = ff.Create()
        idSecond = ff.Create()
        idThird = ff.Create()
        ff.Delete(idFirst)

        'Dangerous, only used for testing the case when ff was never disposed, nor GC'd
        GC.SuppressFinalize(ff)
        ff = Nothing
    End If

    GC.Collect(0, GCCollectionMode.Forced)
    GC.WaitForPendingFinalizers()

    Using f2 As New FragmentedFile(file.TempPath, 512)
        Assert.IsTrue(f2.Create() < idSecond)
        Assert.IsTrue(f2.Create() > idThird)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : Dispose Method

Glossary Item Box

Closes the storage, a must-do to save a costly recomputation of free block on open

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Exceptions

Exception | Description
System.IO.InvalidDataException |

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
SharedMemoryStream shared = new SharedMemoryStream();
FragmentedFile.CreateNew(shared, 512, 100, 2).Dispose();

using (FragmentedFile ff = new FragmentedFile(shared, 512, 100, 2))
{
    long id;
    byte[] bytes = MakeBytes(255);
    using (Stream write = ff.Create(out id))
    using (ITransactable trans = (ITransactable)write)
    {
        write.Write(bytes, 0, bytes.Length);
        trans.Commit();
        Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)));
        trans.Rollback();
    }

    AssertThrows<InvalidDataException>(delegate() { ff.Open(id, FileAccess.Read); });
}
VB.NET Copy Code
Dim [shared] As New SharedMemoryStream()
FragmentedFile.CreateNew([shared], 512, 100, 2).Dispose()

Using ff As New FragmentedFile([shared], 512, 100, 2)
    Dim id As Long
    Dim bytes As Byte() = MakeBytes(255)
    Using write As Stream = ff.Create(id)
        Using trans As ITransactable = DirectCast(write, ITransactable)
            write.Write(bytes, 0, bytes.Length)
            trans.Commit()
            Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)))
            trans.Rollback()
        End Using
    End Using

    AssertThrows(Of InvalidDataException)(Function() Do
        ff.Open(id, FileAccess.Read)
    End Function)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ForeachBlock Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : ForeachBlock Method

allocatedOnly
Allows enumeration of all stream, or of just the externally allocated streams
verifyReads
Determines if the checksum should be verified while reading the block bytes
ignoreException
A method that returns true to ignore the exception and continue processing

Glossary Item Box

Used for enumeration of the storage blocks in the file.

Syntax

Visual Basic (Declaration)
Public Function ForeachBlock( _
   ByVal allocatedOnly As Boolean, _
   ByVal verifyReads As Boolean, _
   ByVal ignoreException As Converter(Of Exception,Boolean) _
) As IEnumerable(Of KeyValuePair(Of Long,Stream))
C#
public IEnumerable<KeyValuePair<long,Stream>> ForeachBlock(
   bool allocatedOnly,
   bool verifyReads,
   Converter<Exception,bool> ignoreException
)

Parameters

allocatedOnly
Allows enumeration of all stream, or of just the externally allocated streams
verifyReads
Determines if the checksum should be verified while reading the block bytes
ignoreException
A method that returns true to ignore the exception and continue processing

Return Value

Enumeration of the identity and data stream of each block in the file

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
Dictionary<long, byte[]> data = new Dictionary<long, byte[]>();
using (TempFile file = new TempFile())
using (FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault))
{
    //Create:
    for (int i = 0; i < 256; i++)
        data.Add(ff.Create(), null);
    //Enumerate:
    int count = 0;
    foreach (KeyValuePair<long, Stream> fragment in ff.ForeachBlock(true, true, null))
        count++;
    Assert.AreEqual(256, count);
    ff.Clear();
    //Empty?
    foreach (KeyValuePair<long, Stream> fragment in ff.ForeachBlock(true, true, null))
        Assert.Fail();
}
VB.NET Copy Code
Dim data As New Dictionary(Of Long, Byte())()
Using file As New TempFile()
    Using ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512, 100, 2, FragmentedFile.OptionsDefault)
        'Create:
        Dim i As Integer = 0
        While i < 256
            data.Add(ff.Create(), Nothing)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        'Enumerate:
        Dim count As Integer = 0
        For Each fragment As KeyValuePair(Of Long, Stream) In ff.ForeachBlock(True, True, Nothing)
            System.Math.Max(System.Threading.Interlocked.Increment(count),count - 1)
        Next
        Assert.AreEqual(256, count)
        ff.Clear()
        'Empty?
        For Each fragment As KeyValuePair(Of Long, Stream) In ff.ForeachBlock(True, True, Nothing)
            Assert.Fail()
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Open Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : Open Method

identity
access

Glossary Item Box

Opens the file with the identity previously obtained by Create() using the access provided; however, Read+Write is not supported, use either Read or Write but not both.

Syntax

Visual Basic (Declaration)
Public Function Open( _
   ByVal identity As Long, _
   ByVal access As FileAccess _
) As Stream
C#
public Stream Open(
   long identity,
   FileAccess access
)

Parameters

identity
access

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
using (FragmentedFile ff = FragmentedFile.CreateNew(shared, 512, 100, 2))
{
    long id = ff.Create();
    using (Stream write = ff.Open(id, FileAccess.Write))
    {
        Assert.IsFalse(write.CanRead);
        Assert.IsTrue(write.CanWrite);
        Assert.IsFalse(write.CanSeek);
        PrimitiveSerializer.Int64.WriteTo(id, write);
        write.Flush();//no-op

        AssertThrows<NotSupportedException>(delegate() { write.Position = 0; });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Position); });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Length); });
        AssertThrows<NotSupportedException>(delegate() { write.SetLength(1); });
        AssertThrows<NotSupportedException>(delegate() { write.Seek(1, SeekOrigin.Begin); });
        AssertThrows<NotSupportedException>(delegate() { write.ReadByte(); });
    }
}
VB.NET Copy Code
Using [shared] As New SharedMemoryStream()
    Using ff As FragmentedFile = FragmentedFile.CreateNew([shared], 512, 100, 2)
        Dim id As Long = ff.Create()
        Using write As Stream = ff.Open(id, FileAccess.Write)
            Assert.IsFalse(write.CanRead)
            Assert.IsTrue(write.CanWrite)
            Assert.IsFalse(write.CanSeek)
            PrimitiveSerializer.Int64.WriteTo(id, write)
            write.Flush()
            'no-op
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Position = 0
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Position)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Length)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.SetLength(1)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Seek(1, SeekOrigin.Begin)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.ReadByte()
            End Function)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
FragmentedFile Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FragmentedFile Class

Glossary Item Box

For a list of all members of this type, see FragmentedFile members.

Public Properties

 | Name | Description
Public Property | FirstIdentity | Returns the 'first' block identity that can be allocated
Top

See Also

Reference

FragmentedFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FirstIdentity Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : FirstIdentity Property

Glossary Item Box

Returns the 'first' block identity that can be allocated

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FirstIdentity As Long
C#
public long FirstIdentity {get;}

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (TempFile file = new TempFile())
{
    Guid guid = Guid.NewGuid();
    long id;

    using (FragmentedFile ff = FragmentedFile.CreateNew(file.TempPath, 512))
    {
        using (Stream io = ff.Create(out id))
            PrimitiveSerializer.Guid.WriteTo(guid, io);
        Assert.AreEqual(id, ff.FirstIdentity);
    }
    using (FragmentedFile ff = new FragmentedFile(file.TempPath, 512))
    {
        Assert.AreEqual(id, ff.FirstIdentity);
        using (Stream io = ff.Open(id, FileAccess.Read))
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io));
    }
    using (FragmentedFile ff = new FragmentedFile(file.TempPath, 512, 10, 10, FileAccess.Read, FileShare.None, FileOptions.None))
    {
        Assert.AreEqual(id, ff.FirstIdentity);
        using (Stream io = ff.Open(id, FileAccess.Read))
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io));

        AssertThrows<InvalidOperationException>(delegate() { ff.Open(id, FileAccess.Write).Dispose(); });
    }
}
VB.NET Copy Code
Using file As New TempFile()
    Dim guid As Guid = Guid.NewGuid()
    Dim id As Long

    Using ff As FragmentedFile = FragmentedFile.CreateNew(file.TempPath, 512)
        Using io As Stream = ff.Create(id)
            PrimitiveSerializer.Guid.WriteTo(guid, io)
        End Using
        Assert.AreEqual(id, ff.FirstIdentity)
    End Using
    Using ff As New FragmentedFile(file.TempPath, 512)
        Assert.AreEqual(id, ff.FirstIdentity)
        Using io As Stream = ff.Open(id, FileAccess.Read)
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io))
        End Using
    End Using
    Using ff As New FragmentedFile(file.TempPath, 512, 10, 10, FileAccess.Read, FileShare.None, _
        FileOptions.None)
        Assert.AreEqual(id, ff.FirstIdentity)
        Using io As Stream = ff.Open(id, FileAccess.Read)
            Assert.AreEqual(guid, PrimitiveSerializer.Guid.ReadFrom(io))
        End Using

        AssertThrows(Of InvalidOperationException)(Function() Do
            ff.Open(id, FileAccess.Write).Dispose()
        End Function)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Used By

Stream FragmentedFile.Open(Int64,FileAccess)
FragmentedFile.Delete(Int64)

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
FragmentedFile Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FragmentedFile Class

Glossary Item Box

For a list of all members of this type, see FragmentedFile members.

Public Fields

 | Name | Description
Public Field | OptionsDefault | Common operational values for 'normal' files
Public Field | OptionsNoBuffering | Uses FILE_FLAG_NO_BUFFERING see http://msdn.microsoft.com/en-us/library/cc644950(v=vs.85).aspx (SLOWEST)
Public Field | OptionsWriteThrough | Common operational values for using OS cache write-through (SLOW)
Top

See Also

Reference

FragmentedFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OptionsDefault Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : OptionsDefault Field

Glossary Item Box

Common operational values for 'normal' files

Syntax

Visual Basic (Declaration)
Public Const OptionsDefault As FileOptions
C#
public const FileOptions OptionsDefault

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OptionsNoBuffering Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : OptionsNoBuffering Field

Glossary Item Box

Uses FILE_FLAG_NO_BUFFERING see http://msdn.microsoft.com/en-us/library/cc644950(v=vs.85).aspx (SLOWEST)

Syntax

Visual Basic (Declaration)
Public Const OptionsNoBuffering As FileOptions
C#
public const FileOptions OptionsNoBuffering

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OptionsWriteThrough Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FragmentedFile Class : OptionsWriteThrough Field

Glossary Item Box

Common operational values for using OS cache write-through (SLOW)

Syntax

Visual Basic (Declaration)
Public Const OptionsWriteThrough As FileOptions
C#
public const FileOptions OptionsWriteThrough

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FragmentedFile Class
FragmentedFile Members

Source Code

Library/IO/FragmentedFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IOStream Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : IOStream Class

Glossary Item Box

A collection of Stream helpers

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class IOStream
C#
public static class IOStream

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.IOStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IOStream Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : IOStream Class

Glossary Item Box

The following tables list the members exposed by IOStream.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Compress | Overloaded. Compress the existing file using an in-place replace.
static (Shared in Visual Basic) | CopyStream | Overloaded. Copy the entire input stream to the provided output stream, input stream will be disposed
static (Shared in Visual Basic) | Decompress | Overloaded. Decompress the existing file using an in-place replace.
static (Shared in Visual Basic) | Read | Overloaded. Reads a the number of bytes specified or throws IOException
static (Shared in Visual Basic) | ReadAllBytes | Reads all of the bytes from the input stream, input stream will be disposed
static (Shared in Visual Basic) | ReadAllText | Reads all of the bytes from the input stream, input stream will be disposed
static (Shared in Visual Basic) | ReadChunk | Overloaded. Attempts to read the number of bytes specified and returns the actual count
Top

See Also

Reference

IOStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IOStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : IOStream Class

Glossary Item Box

For a list of all members of this type, see IOStream members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Compress | Overloaded. Compress the existing file using an in-place replace.
static (Shared in Visual Basic) | CopyStream | Overloaded. Copy the entire input stream to the provided output stream, input stream will be disposed
static (Shared in Visual Basic) | Decompress | Overloaded. Decompress the existing file using an in-place replace.
static (Shared in Visual Basic) | Read | Overloaded. Reads a the number of bytes specified or throws IOException
static (Shared in Visual Basic) | ReadAllBytes | Reads all of the bytes from the input stream, input stream will be disposed
static (Shared in Visual Basic) | ReadAllText | Reads all of the bytes from the input stream, input stream will be disposed
static (Shared in Visual Basic) | ReadChunk | Overloaded. Attempts to read the number of bytes specified and returns the actual count
Top

See Also

Reference

IOStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Compress Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class : Compress Method

Glossary Item Box

Compress the existing file using an in-place replace.

Overload List

Overload | Description
Compress(String) | Compress the existing file using an in-place replace.
Compress(String,String) | Compress the existing file to the specified target.
Compress(Stream,Stream) | Compress the contents of the source stream into the target stream.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Compress(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Compress Method : Compress(String) Method

filename

Glossary Item Box

Compress the existing file using an in-place replace.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Compress( _
   ByVal filename As String _
)
C#
public static void Compress(
   string filename
)

Parameters

filename

Example

Library/Library.Test/TestIOStreamUtils.cs

C# Copy Code
byte[] testData = new byte[ushort.MaxValue];
new Random().NextBytes(testData);
Array.Clear(testData, 0, testData.Length / 2);
Hash compressedHash;
Hash hash = Hash.SHA512(testData);

using (TempFile f = new TempFile())
{
    f.WriteAllBytes(testData);
    Assert.AreEqual((long)testData.Length, f.Length);

    IOStream.Compress(f.TempPath);
    Assert.IsTrue(f.Length < testData.Length);
    compressedHash = Hash.SHA512(f.Read());
    Assert.IsFalse(compressedHash == hash);

    IOStream.Decompress(f.TempPath);
    Assert.AreEqual((long)testData.Length, f.Length);
    Assert.IsTrue(hash == Hash.SHA512(f.Read()));
}

MemoryStream ms = new MemoryStream(testData), gz = new MemoryStream();
IOStream.Compress(ms, gz);

Assert.IsTrue(compressedHash == Hash.SHA512(gz.ToArray()));
ms = new MemoryStream();
gz.Position = 0;
IOStream.Decompress(gz, ms);

Assert.IsTrue(hash == Hash.SHA512(ms.ToArray()));
VB.NET Copy Code
Dim testData As Byte() = New Byte(UShort.MaxValue) {}
New Random().NextBytes(testData)
Array.Clear(testData, 0, testData.Length / 2)
Dim compressedHash As Hash
Dim hash As Hash = Hash.SHA512(testData)

Using f As New TempFile()
    f.WriteAllBytes(testData)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)

    IOStream.Compress(f.TempPath)
    Assert.IsTrue(f.Length < testData.Length)
    compressedHash = Hash.SHA512(f.Read())
    Assert.IsFalse(compressedHash = hash)

    IOStream.Decompress(f.TempPath)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)
    Assert.IsTrue(hash = Hash.SHA512(f.Read()))
End Using

Dim ms As New MemoryStream(testData), gz As New MemoryStream()
IOStream.Compress(ms, gz)

Assert.IsTrue(compressedHash = Hash.SHA512(gz.ToArray()))
ms = New MemoryStream()
gz.Position = 0
IOStream.Decompress(gz, ms)

Assert.IsTrue(hash = Hash.SHA512(ms.ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Compress(String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Compress Method : Compress(String,String) Method

source
target

Glossary Item Box

Compress the existing file to the specified target.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Compress( _
   ByVal source As String, _
   ByVal target As String _
)
C#
public static void Compress(
   string source,
   string target
)

Parameters

source
target

Exceptions

Exception | Description
System.IO.IOException | The exception that is thrown when an I/O error occurs.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

IOStream.Compress(String)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Compress(Stream,Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Compress Method : Compress(Stream,Stream) Method

source
target

Glossary Item Box

Compress the contents of the source stream into the target stream.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Compress( _
   ByVal source As Stream, _
   ByVal target As Stream _
) As Long
C#
public static long Compress(
   Stream source,
   Stream target
)

Parameters

source
target

Example

Library/Library.Test/TestIOStreamUtils.cs

C# Copy Code
byte[] testData = new byte[ushort.MaxValue];
new Random().NextBytes(testData);
Array.Clear(testData, 0, testData.Length / 2);
Hash compressedHash;
Hash hash = Hash.SHA512(testData);

using (TempFile f = new TempFile())
{
    f.WriteAllBytes(testData);
    Assert.AreEqual((long)testData.Length, f.Length);

    IOStream.Compress(f.TempPath);
    Assert.IsTrue(f.Length < testData.Length);
    compressedHash = Hash.SHA512(f.Read());
    Assert.IsFalse(compressedHash == hash);

    IOStream.Decompress(f.TempPath);
    Assert.AreEqual((long)testData.Length, f.Length);
    Assert.IsTrue(hash == Hash.SHA512(f.Read()));
}

MemoryStream ms = new MemoryStream(testData), gz = new MemoryStream();
IOStream.Compress(ms, gz);

Assert.IsTrue(compressedHash == Hash.SHA512(gz.ToArray()));
ms = new MemoryStream();
gz.Position = 0;
IOStream.Decompress(gz, ms);

Assert.IsTrue(hash == Hash.SHA512(ms.ToArray()));
VB.NET Copy Code
Dim testData As Byte() = New Byte(UShort.MaxValue) {}
New Random().NextBytes(testData)
Array.Clear(testData, 0, testData.Length / 2)
Dim compressedHash As Hash
Dim hash As Hash = Hash.SHA512(testData)

Using f As New TempFile()
    f.WriteAllBytes(testData)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)

    IOStream.Compress(f.TempPath)
    Assert.IsTrue(f.Length < testData.Length)
    compressedHash = Hash.SHA512(f.Read())
    Assert.IsFalse(compressedHash = hash)

    IOStream.Decompress(f.TempPath)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)
    Assert.IsTrue(hash = Hash.SHA512(f.Read()))
End Using

Dim ms As New MemoryStream(testData), gz As New MemoryStream()
IOStream.Compress(ms, gz)

Assert.IsTrue(compressedHash = Hash.SHA512(gz.ToArray()))
ms = New MemoryStream()
gz.Position = 0
IOStream.Decompress(gz, ms)

Assert.IsTrue(hash = Hash.SHA512(ms.ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

IOStream.Compress(String,String)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyStream Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class : CopyStream Method

Glossary Item Box

Copy the entire input stream to the provided output stream, input stream will be disposed

Overload List

Overload | Description
CopyStream(Stream,Stream) | Copy the entire input stream to the provided output stream, input stream will be disposed
CopyStream(Stream,Stream,Int64) | Copy the specified number of bytes from the input stream to the provided output stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyStream(Stream,Stream) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > CopyStream Method : CopyStream(Stream,Stream) Method

input
output

Glossary Item Box

Copy the entire input stream to the provided output stream, input stream will be disposed

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function CopyStream( _
   ByVal input As Stream, _
   ByVal output As Stream _
) As Long
C#
public static long CopyStream(
   Stream input,
   Stream output
)

Parameters

input
output

Return Value

The number of bytes copied

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

Byte[] AsymmetricKey.Decrypt(Byte[])
Byte[] AESCryptoKey.Decrypt(Byte[])
Byte[] IOStream.ReadAllBytes(Stream)
Int64 IOStream.Compress(Stream,Stream)
Int64 IOStream.Decompress(Stream,Stream)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyStream(Stream,Stream,Int64) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > CopyStream Method : CopyStream(Stream,Stream,Int64) Method

input
output
stopAfter

Glossary Item Box

Copy the specified number of bytes from the input stream to the provided output stream

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function CopyStream( _
   ByVal input As Stream, _
   ByVal output As Stream, _
   ByVal stopAfter As Long _
) As Long
C#
public static long CopyStream(
   Stream input,
   Stream output,
   long stopAfter
)

Parameters

input
output
stopAfter

Return Value

The number of bytes copied

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

Int64 IOStream.CopyStream(Stream,Stream)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decompress Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class : Decompress Method

Glossary Item Box

Decompress the existing file using an in-place replace.

Overload List

Overload | Description
Decompress(String) | Decompress the existing file using an in-place replace.
Decompress(String,String) | Decompress the existing file to the specified target.
Decompress(Stream,Stream) | Decompress the source stream to the specified target stream.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Decompress(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Decompress Method : Decompress(String) Method

filename

Glossary Item Box

Decompress the existing file using an in-place replace.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Decompress( _
   ByVal filename As String _
)
C#
public static void Decompress(
   string filename
)

Parameters

filename

Example

Library/Library.Test/TestIOStreamUtils.cs

C# Copy Code
byte[] testData = new byte[ushort.MaxValue];
new Random().NextBytes(testData);
Array.Clear(testData, 0, testData.Length / 2);
Hash compressedHash;
Hash hash = Hash.SHA512(testData);

using (TempFile f = new TempFile())
{
    f.WriteAllBytes(testData);
    Assert.AreEqual((long)testData.Length, f.Length);

    IOStream.Compress(f.TempPath);
    Assert.IsTrue(f.Length < testData.Length);
    compressedHash = Hash.SHA512(f.Read());
    Assert.IsFalse(compressedHash == hash);

    IOStream.Decompress(f.TempPath);
    Assert.AreEqual((long)testData.Length, f.Length);
    Assert.IsTrue(hash == Hash.SHA512(f.Read()));
}

MemoryStream ms = new MemoryStream(testData), gz = new MemoryStream();
IOStream.Compress(ms, gz);

Assert.IsTrue(compressedHash == Hash.SHA512(gz.ToArray()));
ms = new MemoryStream();
gz.Position = 0;
IOStream.Decompress(gz, ms);

Assert.IsTrue(hash == Hash.SHA512(ms.ToArray()));
VB.NET Copy Code
Dim testData As Byte() = New Byte(UShort.MaxValue) {}
New Random().NextBytes(testData)
Array.Clear(testData, 0, testData.Length / 2)
Dim compressedHash As Hash
Dim hash As Hash = Hash.SHA512(testData)

Using f As New TempFile()
    f.WriteAllBytes(testData)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)

    IOStream.Compress(f.TempPath)
    Assert.IsTrue(f.Length < testData.Length)
    compressedHash = Hash.SHA512(f.Read())
    Assert.IsFalse(compressedHash = hash)

    IOStream.Decompress(f.TempPath)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)
    Assert.IsTrue(hash = Hash.SHA512(f.Read()))
End Using

Dim ms As New MemoryStream(testData), gz As New MemoryStream()
IOStream.Compress(ms, gz)

Assert.IsTrue(compressedHash = Hash.SHA512(gz.ToArray()))
ms = New MemoryStream()
gz.Position = 0
IOStream.Decompress(gz, ms)

Assert.IsTrue(hash = Hash.SHA512(ms.ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decompress(String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Decompress Method : Decompress(String,String) Method

source
target

Glossary Item Box

Decompress the existing file to the specified target.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Decompress( _
   ByVal source As String, _
   ByVal target As String _
)
C#
public static void Decompress(
   string source,
   string target
)

Parameters

source
target

Exceptions

Exception | Description
System.IO.IOException | The exception that is thrown when an I/O error occurs.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

IOStream.Decompress(String)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decompress(Stream,Stream) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Decompress Method : Decompress(Stream,Stream) Method

source
target

Glossary Item Box

Decompress the source stream to the specified target stream.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Decompress( _
   ByVal source As Stream, _
   ByVal target As Stream _
) As Long
C#
public static long Decompress(
   Stream source,
   Stream target
)

Parameters

source
target

Example

Library/Library.Test/TestIOStreamUtils.cs

C# Copy Code
byte[] testData = new byte[ushort.MaxValue];
new Random().NextBytes(testData);
Array.Clear(testData, 0, testData.Length / 2);
Hash compressedHash;
Hash hash = Hash.SHA512(testData);

using (TempFile f = new TempFile())
{
    f.WriteAllBytes(testData);
    Assert.AreEqual((long)testData.Length, f.Length);

    IOStream.Compress(f.TempPath);
    Assert.IsTrue(f.Length < testData.Length);
    compressedHash = Hash.SHA512(f.Read());
    Assert.IsFalse(compressedHash == hash);

    IOStream.Decompress(f.TempPath);
    Assert.AreEqual((long)testData.Length, f.Length);
    Assert.IsTrue(hash == Hash.SHA512(f.Read()));
}

MemoryStream ms = new MemoryStream(testData), gz = new MemoryStream();
IOStream.Compress(ms, gz);

Assert.IsTrue(compressedHash == Hash.SHA512(gz.ToArray()));
ms = new MemoryStream();
gz.Position = 0;
IOStream.Decompress(gz, ms);

Assert.IsTrue(hash == Hash.SHA512(ms.ToArray()));
VB.NET Copy Code
Dim testData As Byte() = New Byte(UShort.MaxValue) {}
New Random().NextBytes(testData)
Array.Clear(testData, 0, testData.Length / 2)
Dim compressedHash As Hash
Dim hash As Hash = Hash.SHA512(testData)

Using f As New TempFile()
    f.WriteAllBytes(testData)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)

    IOStream.Compress(f.TempPath)
    Assert.IsTrue(f.Length < testData.Length)
    compressedHash = Hash.SHA512(f.Read())
    Assert.IsFalse(compressedHash = hash)

    IOStream.Decompress(f.TempPath)
    Assert.AreEqual(DirectCast(testData.Length, Long), f.Length)
    Assert.IsTrue(hash = Hash.SHA512(f.Read()))
End Using

Dim ms As New MemoryStream(testData), gz As New MemoryStream()
IOStream.Compress(ms, gz)

Assert.IsTrue(compressedHash = Hash.SHA512(gz.ToArray()))
ms = New MemoryStream()
gz.Position = 0
IOStream.Decompress(gz, ms)

Assert.IsTrue(hash = Hash.SHA512(ms.ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

IOStream.Decompress(String,String)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class : Read Method

Glossary Item Box

Reads a the number of bytes specified or throws IOException

Overload List

Overload | Description
Read(Stream,Byte[]) | Reads a the number of bytes specified or throws IOException
Read(Stream,Int32) | Reads a the number of bytes specified or throws IOException
Read(Stream,Byte[],Int32) | Reads a the number of bytes specified or throws IOException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Stream,Byte[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Read Method : Read(Stream,Byte[]) Method

io
bytes

Glossary Item Box

Reads a the number of bytes specified or throws IOException

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Read( _
   ByVal io As Stream, _
   ByVal bytes() As Byte _
)
C#
public static void Read(
   Stream io,
   byte[] bytes
)

Parameters

io
bytes

Example

Library/Library.Test/TestIOStreamUtils.cs

C# Copy Code
byte[] testdata = new byte[2048];
new Random().NextBytes(testdata);

byte[] copy = new byte[testdata.Length];
IOStream.Read(FragmentStream(testdata, 16), copy);
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy));

byte[] copyb = new byte[testdata.Length / 2];
using (Stream s = FragmentStream(testdata, 16))
{
    IOStream.Read(s, copy, copy.Length - copyb.Length);
    IOStream.Read(s, copyb);
}
Array.Copy(copyb, 0, copy, copy.Length - copyb.Length, copyb.Length);
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy));

copy = IOStream.Read(FragmentStream(testdata, 16), testdata.Length);
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy));
VB.NET Copy Code
Dim testdata As Byte() = New Byte(2048) {}
New Random().NextBytes(testdata)

Dim copy As Byte() = New Byte(testdata.Length) {}
IOStream.Read(FragmentStream(testdata, 16), copy)
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy))

Dim copyb As Byte() = New Byte(testdata.Length / 2) {}
Using s As Stream = FragmentStream(testdata, 16)
    IOStream.Read(s, copy, copy.Length - copyb.Length)
    IOStream.Read(s, copyb)
End Using
Array.Copy(copyb, 0, copy, copy.Length - copyb.Length, copyb.Length)
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy))

copy = IOStream.Read(FragmentStream(testdata, 16), testdata.Length)
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Stream,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Read Method : Read(Stream,Int32) Method

io
nBytes

Glossary Item Box

Reads a the number of bytes specified or throws IOException

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Read( _
   ByVal io As Stream, _
   ByVal nBytes As Integer _
) As Byte()
C#
public static byte[] Read(
   Stream io,
   int nBytes
)

Parameters

io
nBytes

Example

Library/Library.Test/TestIOStreamUtils.cs

C# Copy Code
byte[] testdata = new byte[2048];
new Random().NextBytes(testdata);

byte[] copy = new byte[testdata.Length];
IOStream.Read(FragmentStream(testdata, 16), copy);
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy));

byte[] copyb = new byte[testdata.Length / 2];
using (Stream s = FragmentStream(testdata, 16))
{
    IOStream.Read(s, copy, copy.Length - copyb.Length);
    IOStream.Read(s, copyb);
}
Array.Copy(copyb, 0, copy, copy.Length - copyb.Length, copyb.Length);
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy));

copy = IOStream.Read(FragmentStream(testdata, 16), testdata.Length);
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy));
VB.NET Copy Code
Dim testdata As Byte() = New Byte(2048) {}
New Random().NextBytes(testdata)

Dim copy As Byte() = New Byte(testdata.Length) {}
IOStream.Read(FragmentStream(testdata, 16), copy)
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy))

Dim copyb As Byte() = New Byte(testdata.Length / 2) {}
Using s As Stream = FragmentStream(testdata, 16)
    IOStream.Read(s, copy, copy.Length - copyb.Length)
    IOStream.Read(s, copyb)
End Using
Array.Copy(copyb, 0, copy, copy.Length - copyb.Length, copyb.Length)
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy))

copy = IOStream.Read(FragmentStream(testdata, 16), testdata.Length)
Assert.AreEqual(Convert.ToBase64String(testdata), Convert.ToBase64String(copy))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

Stream PasswordKey.Decrypt(Stream,Salt.Size)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Stream,Byte[],Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > Read Method : Read(Stream,Byte[],Int32) Method

io
bytes
length

Glossary Item Box

Reads a the number of bytes specified or throws IOException

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Read( _
   ByVal io As Stream, _
   ByVal bytes() As Byte, _
   ByVal length As Integer _
)
C#
public static void Read(
   Stream io,
   byte[] bytes,
   int length
)

Parameters

io
bytes
length

Exceptions

Exception | Description
System.IO.IOException | The exception that is thrown when an I/O error occurs.

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
byte[] dataIn = new byte[1024];
byte[] copy;
new Random().NextBytes(dataIn);
GCHandle h = GCHandle.Alloc(dataIn, GCHandleType.Pinned);
try
{
    using (MarshallingStream stream = new MarshallingStream(h.AddrOfPinnedObject(), false, dataIn.Length))
    {
        Assert.IsTrue(stream.CanRead);
        Assert.IsTrue(stream.CanWrite);
        Assert.IsTrue(stream.CanSeek);

        copy = new byte[(int)stream.Length];
        IOStream.Read(stream, copy, (int)stream.Length);
        Assert.AreEqual(dataIn, copy);
        Assert.AreEqual(stream.Length, stream.Position);
        stream.Position = 0;
        Assert.AreEqual(0L, stream.Position);

        stream.Write(new byte[dataIn.Length], 0, dataIn.Length);
        Assert.AreEqual(new byte[dataIn.Length], dataIn);

        stream.Seek(0, SeekOrigin.Begin);
        Assert.AreEqual(0, stream.Position);
        stream.Write(copy, 0, dataIn.Length);
        Assert.AreEqual(dataIn, copy);

        stream.Seek(-10, SeekOrigin.Current);
        Assert.AreEqual(stream.Length - 10, stream.Position);

        stream.Seek(-stream.Length, SeekOrigin.End);
        Assert.AreEqual(0, stream.Position);

        stream.WriteByte(123);
        stream.Position = 0;
        Assert.AreEqual(123, stream.ReadByte());
    }

    using (MarshallingStream stream = new MarshallingStream(h.AddrOfPinnedObject(), true, dataIn.Length))
    {
        Assert.IsFalse(stream.CanWrite);

        copy = new byte[(int)stream.Length];
        IOStream.Read(stream, copy, (int)stream.Length);
        Assert.AreEqual(dataIn, copy);

        try
        {
            stream.Write(new byte[10], 0, 10);
            Assert.Fail();
        }
        catch (InvalidOperationException) { }

        stream.Dispose();
        try
        {
            stream.Read(new byte[10], 0, 10);
            Assert.Fail();
        }
        catch (ObjectDisposedException) { }
    }
}
finally { h.Free(); }
VB.NET Copy Code
Dim dataIn As Byte() = New Byte(1024) {}
Dim copy As Byte()
New Random().NextBytes(dataIn)
Dim h As GCHandle = GCHandle.Alloc(dataIn, GCHandleType.Pinned)
Try
    Using stream As New MarshallingStream(h.AddrOfPinnedObject(), False, dataIn.Length)
        Assert.IsTrue(stream.CanRead)
        Assert.IsTrue(stream.CanWrite)
        Assert.IsTrue(stream.CanSeek)

        copy = New Byte(DirectCast(stream.Length, Integer)) {}
        IOStream.Read(stream, copy, DirectCast(stream.Length, Integer))
        Assert.AreEqual(dataIn, copy)
        Assert.AreEqual(stream.Length, stream.Position)
        stream.Position = 0
        Assert.AreEqual(0L, stream.Position)

        stream.Write(New Byte(dataIn.Length) {}, 0, dataIn.Length)
        Assert.AreEqual(New Byte(dataIn.Length) {}, dataIn)

        stream.Seek(0, SeekOrigin.Begin)
        Assert.AreEqual(0, stream.Position)
        stream.Write(copy, 0, dataIn.Length)
        Assert.AreEqual(dataIn, copy)

        stream.Seek(-10, SeekOrigin.Current)
        Assert.AreEqual(stream.Length - 10, stream.Position)

        stream.Seek(-stream.Length, SeekOrigin.[End])
        Assert.AreEqual(0, stream.Position)

        stream.WriteByte(123)
        stream.Position = 0
        Assert.AreEqual(123, stream.ReadByte())
    End Using

    Using stream As New MarshallingStream(h.AddrOfPinnedObject(), True, dataIn.Length)
        Assert.IsFalse(stream.CanWrite)

        copy = New Byte(DirectCast(stream.Length, Integer)) {}
        IOStream.Read(stream, copy, DirectCast(stream.Length, Integer))
        Assert.AreEqual(dataIn, copy)

        Try
            stream.Write(New Byte(10) {}, 0, 10)
            Assert.Fail()
        Catch generatedExceptionName As InvalidOperationException
        End Try

        stream.Dispose()
        Try
            stream.Read(New Byte(10) {}, 0, 10)
            Assert.Fail()
        Catch generatedExceptionName As ObjectDisposedException
        End Try
    End Using
Finally
    h.Free()
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

Boolean SecureTransfer.Client.Upload(String,Int64,Stream)
IOStream.Read(Stream,Byte[])
Byte[] IOStream.Read(Stream,Int32)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadAllBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class : ReadAllBytes Method

io

Glossary Item Box

Reads all of the bytes from the input stream, input stream will be disposed

Syntax

Visual Basic (Declaration)
Public Shared Function ReadAllBytes( _
   ByVal io As Stream _
) As Byte()
C#
public static byte[] ReadAllBytes(
   Stream io
)

Parameters

io

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        stream.Write(new byte[100], 25, 55);
        stream.Close();
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.AreEqual(new byte[55], IOStream.ReadAllBytes(stream));
    }
}
VB.NET Copy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        stream.Write(New Byte(100) {}, 25, 55)
        stream.Close()
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.AreEqual(New Byte(55) {}, IOStream.ReadAllBytes(stream))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members

Source Code

Library/IO/IOStream.cs

Used By

String IOStream.ReadAllText(Stream,Encoding)


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadAllText Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class : ReadAllText Method

io
encoding

Glossary Item Box

Reads all of the bytes from the input stream, input stream will be disposed

Syntax

Visual Basic (Declaration)
Public Shared Function ReadAllText( _
   ByVal io As Stream, _
   ByVal encoding As Encoding _
) As String
C#
public static string ReadAllText(
   Stream io,
   Encoding encoding
)

Parameters

io
encoding

Example

Library/Library.Test/TestSecureString.cs

C# Copy Code
byte[] expect = Encoding.Unicode.GetBytes(TEST_PASSWORD);
foreach (SecureString ss in MakeStrings())
{
    Assert.AreEqual(expect, IOStream.ReadAllBytes(SecureStringUtils.ToStream(ss)));
    Assert.AreEqual(TEST_PASSWORD, IOStream.ReadAllText(SecureStringUtils.ToStream(ss), Encoding.Unicode));
}
VB.NET Copy Code
Dim expect As Byte() = Encoding.Unicode.GetBytes(TEST_PASSWORD)
For Each ss As SecureString In MakeStrings()
    Assert.AreEqual(expect, IOStream.ReadAllBytes(SecureStringUtils.ToStream(ss)))
    Assert.AreEqual(TEST_PASSWORD, IOStream.ReadAllText(SecureStringUtils.ToStream(ss), Encoding.Unicode))
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadChunk Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class : ReadChunk Method

Glossary Item Box

Attempts to read the number of bytes specified and returns the actual count

Overload List

Overload | Description
ReadChunk(Stream,Byte[],Int32) | Attempts to read the number of bytes specified and returns the actual count
ReadChunk(Stream,Byte[],Int32,Int32) | Attempts to read the number of bytes specified and returns the actual count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadChunk(Stream,Byte[],Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > ReadChunk Method : ReadChunk(Stream,Byte[],Int32) Method

io
bytes
length

Glossary Item Box

Attempts to read the number of bytes specified and returns the actual count

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function ReadChunk( _
   ByVal io As Stream, _
   ByVal bytes() As Byte, _
   ByVal length As Integer _
) As Integer
C#
public static int ReadChunk(
   Stream io,
   byte[] bytes,
   int length
)

Parameters

io
bytes
length

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

IOStream.Read(Stream,Byte[],Int32)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadChunk(Stream,Byte[],Int32,Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > IOStream Class > ReadChunk Method : ReadChunk(Stream,Byte[],Int32,Int32) Method

io
bytes
offset
length

Glossary Item Box

Attempts to read the number of bytes specified and returns the actual count

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function ReadChunk( _
   ByVal io As Stream, _
   ByVal bytes() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer _
) As Integer
C#
public static int ReadChunk(
   Stream io,
   byte[] bytes,
   int offset,
   int length
)

Parameters

io
bytes
offset
length

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IOStream Class
IOStream Members
Overload List

Used By

Int32 IOStream.ReadChunk(Stream,Byte[],Int32)

Source Code

Library/IO/IOStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MarshallingStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : MarshallingStream Class

Glossary Item Box

A stream that marshals bytes from unmanaged memory

Syntax

Visual Basic (Declaration)
Public Class MarshallingStream
   Inherits BaseStream
C#
public class MarshallingStream : BaseStream

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
byte[] dataIn = new byte[1024];
byte[] copy;
new Random().NextBytes(dataIn);
GCHandle h = GCHandle.Alloc(dataIn, GCHandleType.Pinned);
try
{
    using (MarshallingStream stream = new MarshallingStream(h.AddrOfPinnedObject(), false, dataIn.Length))
    {
        Assert.IsTrue(stream.CanRead);
        Assert.IsTrue(stream.CanWrite);
        Assert.IsTrue(stream.CanSeek);

        copy = new byte[(int)stream.Length];
        IOStream.Read(stream, copy, (int)stream.Length);
        Assert.AreEqual(dataIn, copy);
        Assert.AreEqual(stream.Length, stream.Position);
        stream.Position = 0;
        Assert.AreEqual(0L, stream.Position);

        stream.Write(new byte[dataIn.Length], 0, dataIn.Length);
        Assert.AreEqual(new byte[dataIn.Length], dataIn);

        stream.Seek(0, SeekOrigin.Begin);
        Assert.AreEqual(0, stream.Position);
        stream.Write(copy, 0, dataIn.Length);
        Assert.AreEqual(dataIn, copy);

        stream.Seek(-10, SeekOrigin.Current);
        Assert.AreEqual(stream.Length - 10, stream.Position);

        stream.Seek(-stream.Length, SeekOrigin.End);
        Assert.AreEqual(0, stream.Position);

        stream.WriteByte(123);
        stream.Position = 0;
        Assert.AreEqual(123, stream.ReadByte());
    }

    using (MarshallingStream stream = new MarshallingStream(h.AddrOfPinnedObject(), true, dataIn.Length))
    {
        Assert.IsFalse(stream.CanWrite);

        copy = new byte[(int)stream.Length];
        IOStream.Read(stream, copy, (int)stream.Length);
        Assert.AreEqual(dataIn, copy);

        try
        {
            stream.Write(new byte[10], 0, 10);
            Assert.Fail();
        }
        catch (InvalidOperationException) { }

        stream.Dispose();
        try
        {
            stream.Read(new byte[10], 0, 10);
            Assert.Fail();
        }
        catch (ObjectDisposedException) { }
    }
}
finally { h.Free(); }
VB.NET Copy Code
Dim dataIn As Byte() = New Byte(1024) {}
Dim copy As Byte()
New Random().NextBytes(dataIn)
Dim h As GCHandle = GCHandle.Alloc(dataIn, GCHandleType.Pinned)
Try
    Using stream As New MarshallingStream(h.AddrOfPinnedObject(), False, dataIn.Length)
        Assert.IsTrue(stream.CanRead)
        Assert.IsTrue(stream.CanWrite)
        Assert.IsTrue(stream.CanSeek)

        copy = New Byte(DirectCast(stream.Length, Integer)) {}
        IOStream.Read(stream, copy, DirectCast(stream.Length, Integer))
        Assert.AreEqual(dataIn, copy)
        Assert.AreEqual(stream.Length, stream.Position)
        stream.Position = 0
        Assert.AreEqual(0L, stream.Position)

        stream.Write(New Byte(dataIn.Length) {}, 0, dataIn.Length)
        Assert.AreEqual(New Byte(dataIn.Length) {}, dataIn)

        stream.Seek(0, SeekOrigin.Begin)
        Assert.AreEqual(0, stream.Position)
        stream.Write(copy, 0, dataIn.Length)
        Assert.AreEqual(dataIn, copy)

        stream.Seek(-10, SeekOrigin.Current)
        Assert.AreEqual(stream.Length - 10, stream.Position)

        stream.Seek(-stream.Length, SeekOrigin.[End])
        Assert.AreEqual(0, stream.Position)

        stream.WriteByte(123)
        stream.Position = 0
        Assert.AreEqual(123, stream.ReadByte())
    End Using

    Using stream As New MarshallingStream(h.AddrOfPinnedObject(), True, dataIn.Length)
        Assert.IsFalse(stream.CanWrite)

        copy = New Byte(DirectCast(stream.Length, Integer)) {}
        IOStream.Read(stream, copy, DirectCast(stream.Length, Integer))
        Assert.AreEqual(dataIn, copy)

        Try
            stream.Write(New Byte(10) {}, 0, 10)
            Assert.Fail()
        Catch generatedExceptionName As InvalidOperationException
        End Try

        stream.Dispose()
        Try
            stream.Read(New Byte(10) {}, 0, 10)
            Assert.Fail()
        Catch generatedExceptionName As ObjectDisposedException
        End Try
    End Using
Finally
    h.Free()
End Try

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.BaseStream
CSharpTest.Net.IO.MarshallingStream
CSharpTest.Net.Crypto.SecureStringStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
MarshallingStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : MarshallingStream Class

Glossary Item Box

The following tables list the members exposed by MarshallingStream.

Public Constructors

 | Name | Description
Public Constructor | MarshallingStream Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

MarshallingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MarshallingStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : MarshallingStream Constructor

Glossary Item Box

Overload List

Overload | Description
MarshallingStream Constructor(IntPtr,Boolean,Int32,Int32) | Constructs a stream that marshals bytes from unmanaged memory
MarshallingStream Constructor(IntPtr,Boolean,Int32) | Constructs a stream that marshals bytes from unmanaged memory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
MarshallingStream Constructor(IntPtr,Boolean,Int32,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class > MarshallingStream Constructor : MarshallingStream Constructor(IntPtr,Boolean,Int32,Int32)

ptrBytes
readOnly
start
length

Glossary Item Box

Constructs a stream that marshals bytes from unmanaged memory

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ptrBytes As IntPtr, _
   ByVal readOnly As Boolean, _
   ByVal start As Integer, _
   ByVal length As Integer _
)
C#
public MarshallingStream(
   IntPtr ptrBytes,
   bool readOnly,
   int start,
   int length
)

Parameters

ptrBytes
readOnly
start
length

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Overload List

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MarshallingStream Constructor(IntPtr,Boolean,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class > MarshallingStream Constructor : MarshallingStream Constructor(IntPtr,Boolean,Int32)

ptrBytes
readOnly
length

Glossary Item Box

Constructs a stream that marshals bytes from unmanaged memory

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ptrBytes As IntPtr, _
   ByVal readOnly As Boolean, _
   ByVal length As Integer _
)
C#
public MarshallingStream(
   IntPtr ptrBytes,
   bool readOnly,
   int length
)

Parameters

ptrBytes
readOnly
length

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
byte[] dataIn = new byte[1024];
byte[] copy;
new Random().NextBytes(dataIn);
GCHandle h = GCHandle.Alloc(dataIn, GCHandleType.Pinned);
try
{
    using (MarshallingStream stream = new MarshallingStream(h.AddrOfPinnedObject(), false, dataIn.Length))
    {
        Assert.IsTrue(stream.CanRead);
        Assert.IsTrue(stream.CanWrite);
        Assert.IsTrue(stream.CanSeek);

        copy = new byte[(int)stream.Length];
        IOStream.Read(stream, copy, (int)stream.Length);
        Assert.AreEqual(dataIn, copy);
        Assert.AreEqual(stream.Length, stream.Position);
        stream.Position = 0;
        Assert.AreEqual(0L, stream.Position);

        stream.Write(new byte[dataIn.Length], 0, dataIn.Length);
        Assert.AreEqual(new byte[dataIn.Length], dataIn);

        stream.Seek(0, SeekOrigin.Begin);
        Assert.AreEqual(0, stream.Position);
        stream.Write(copy, 0, dataIn.Length);
        Assert.AreEqual(dataIn, copy);

        stream.Seek(-10, SeekOrigin.Current);
        Assert.AreEqual(stream.Length - 10, stream.Position);

        stream.Seek(-stream.Length, SeekOrigin.End);
        Assert.AreEqual(0, stream.Position);

        stream.WriteByte(123);
        stream.Position = 0;
        Assert.AreEqual(123, stream.ReadByte());
    }

    using (MarshallingStream stream = new MarshallingStream(h.AddrOfPinnedObject(), true, dataIn.Length))
    {
        Assert.IsFalse(stream.CanWrite);

        copy = new byte[(int)stream.Length];
        IOStream.Read(stream, copy, (int)stream.Length);
        Assert.AreEqual(dataIn, copy);

        try
        {
            stream.Write(new byte[10], 0, 10);
            Assert.Fail();
        }
        catch (InvalidOperationException) { }

        stream.Dispose();
        try
        {
            stream.Read(new byte[10], 0, 10);
            Assert.Fail();
        }
        catch (ObjectDisposedException) { }
    }
}
finally { h.Free(); }
VB.NET Copy Code
Dim dataIn As Byte() = New Byte(1024) {}
Dim copy As Byte()
New Random().NextBytes(dataIn)
Dim h As GCHandle = GCHandle.Alloc(dataIn, GCHandleType.Pinned)
Try
    Using stream As New MarshallingStream(h.AddrOfPinnedObject(), False, dataIn.Length)
        Assert.IsTrue(stream.CanRead)
        Assert.IsTrue(stream.CanWrite)
        Assert.IsTrue(stream.CanSeek)

        copy = New Byte(DirectCast(stream.Length, Integer)) {}
        IOStream.Read(stream, copy, DirectCast(stream.Length, Integer))
        Assert.AreEqual(dataIn, copy)
        Assert.AreEqual(stream.Length, stream.Position)
        stream.Position = 0
        Assert.AreEqual(0L, stream.Position)

        stream.Write(New Byte(dataIn.Length) {}, 0, dataIn.Length)
        Assert.AreEqual(New Byte(dataIn.Length) {}, dataIn)

        stream.Seek(0, SeekOrigin.Begin)
        Assert.AreEqual(0, stream.Position)
        stream.Write(copy, 0, dataIn.Length)
        Assert.AreEqual(dataIn, copy)

        stream.Seek(-10, SeekOrigin.Current)
        Assert.AreEqual(stream.Length - 10, stream.Position)

        stream.Seek(-stream.Length, SeekOrigin.[End])
        Assert.AreEqual(0, stream.Position)

        stream.WriteByte(123)
        stream.Position = 0
        Assert.AreEqual(123, stream.ReadByte())
    End Using

    Using stream As New MarshallingStream(h.AddrOfPinnedObject(), True, dataIn.Length)
        Assert.IsFalse(stream.CanWrite)

        copy = New Byte(DirectCast(stream.Length, Integer)) {}
        IOStream.Read(stream, copy, DirectCast(stream.Length, Integer))
        Assert.AreEqual(dataIn, copy)

        Try
            stream.Write(New Byte(10) {}, 0, 10)
            Assert.Fail()
        Catch generatedExceptionName As InvalidOperationException
        End Try

        stream.Dispose()
        Try
            stream.Read(New Byte(10) {}, 0, 10)
            Assert.Fail()
        Catch generatedExceptionName As ObjectDisposedException
        End Try
    End Using
Finally
    h.Free()
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Overload List

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
MarshallingStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : MarshallingStream Class

Glossary Item Box

For a list of all members of this type, see MarshallingStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

MarshallingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : Dispose Method

Glossary Item Box

Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

Overload List

Overload | Description
Dispose(Boolean) | Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : Read Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Syntax

Visual Basic (Declaration)
Public Overrides Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int Read(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in Read

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : ReadByte Method

Glossary Item Box

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function ReadByte() As Integer
C#
public override int ReadByte()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in ReadByte

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Seek Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : Seek Method

offset
origin

Glossary Item Box

When overridden in a derived class, sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function Seek( _
   ByVal offset As Long, _
   ByVal origin As SeekOrigin _
) As Long
C#
public override long Seek(
   long offset,
   SeekOrigin origin
)

Parameters

offset
origin

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in Seek

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : Write Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
)
C#
public override void Write(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in Write

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : WriteByte Method

value

Glossary Item Box

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Syntax

Visual Basic (Declaration)
Public Overrides Sub WriteByte( _
   ByVal value As Byte _
)
C#
public override void WriteByte(
   byte value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in WriteByte

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
MarshallingStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : MarshallingStream Class

Glossary Item Box

For a list of all members of this type, see MarshallingStream members.

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

MarshallingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanRead Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : CanRead Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanRead As Boolean
C#
public override bool CanRead {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in CanRead

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanSeek Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : CanSeek Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanSeek As Boolean
C#
public override bool CanSeek {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in CanSeek

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanWrite Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : CanWrite Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanWrite As Boolean
C#
public override bool CanWrite {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in CanWrite

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : Length Property

Glossary Item Box

When overridden in a derived class, gets the length in bytes of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property Length As Long
C#
public override long Length {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in Length

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Position Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > MarshallingStream Class : Position Property

Glossary Item Box

When overridden in a derived class, gets or sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Property Position As Long
C#
public override long Position {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MarshallingStream Class
MarshallingStream Members
Base Implementation in Position

Source Code

Library/IO/MarshallingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NonClosingStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : NonClosingStream Class

Glossary Item Box

Provides a stream wrapper that will not close/dispose the underlying stream

Syntax

Visual Basic (Declaration)
Public Class NonClosingStream
   Inherits AggregateStream
C#
public class NonClosingStream : AggregateStream

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
MemoryStream ms = new MemoryStream(new byte[5]);
Assert.AreEqual(5, ms.Length);

using (Stream s = new NonClosingStream(ms))
    s.Close();

Assert.AreEqual(5, ms.Length);
Assert.AreEqual(0, ms.Position);
Assert.IsTrue(ms.CanRead);
Assert.AreEqual(5, ms.Read(new byte[10], 0, 10));
VB.NET Copy Code
Dim ms As New MemoryStream(New Byte(5) {})
Assert.AreEqual(5, ms.Length)

Using s As Stream = New NonClosingStream(ms)
    s.Close()
End Using

Assert.AreEqual(5, ms.Length)
Assert.AreEqual(0, ms.Position)
Assert.IsTrue(ms.CanRead)
Assert.AreEqual(5, ms.Read(New Byte(10) {}, 0, 10))

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.AggregateStream
CSharpTest.Net.IO.NonClosingStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

NonClosingStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/NonClosingStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
NonClosingStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : NonClosingStream Class

Glossary Item Box

The following tables list the members exposed by NonClosingStream.

Public Constructors

 | Name | Description
Public Constructor | NonClosingStream Constructor | Creates a wrapper around the provided stream
Top

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Protected Properties

 | Name | Description
Protected Property | Stream | Allows modifying the underlying stream (Inherited from CSharpTest.Net.IO.AggregateStream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Overridden. Disposes of this.Stream
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Prevents the disposal of the aggregated stream
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

NonClosingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/NonClosingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NonClosingStream Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > NonClosingStream Class : NonClosingStream Constructor

stream

Glossary Item Box

Creates a wrapper around the provided stream

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal stream As Stream _
)
C#
public NonClosingStream(
   Stream stream
)

Parameters

stream

Example

Library/Library.Test/TestStreams.cs

C# Copy Code
MemoryStream ms = new MemoryStream(new byte[5]);
Assert.AreEqual(5, ms.Length);

using (Stream s = new NonClosingStream(ms))
    s.Close();

Assert.AreEqual(5, ms.Length);
Assert.AreEqual(0, ms.Position);
Assert.IsTrue(ms.CanRead);
Assert.AreEqual(5, ms.Read(new byte[10], 0, 10));
VB.NET Copy Code
Dim ms As New MemoryStream(New Byte(5) {})
Assert.AreEqual(5, ms.Length)

Using s As Stream = New NonClosingStream(ms)
    s.Close()
End Using

Assert.AreEqual(5, ms.Length)
Assert.AreEqual(0, ms.Position)
Assert.IsTrue(ms.CanRead)
Assert.AreEqual(5, ms.Read(New Byte(10) {}, 0, 10))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

NonClosingStream Class
NonClosingStream Members

Used By

Byte[] AsymmetricKey.Encrypt(Byte[])
Byte[] AESCryptoKey.Encrypt(Byte[])

Source Code

Library/IO/NonClosingStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
NonClosingStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : NonClosingStream Class

Glossary Item Box

For a list of all members of this type, see NonClosingStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Overridden. Disposes of this.Stream
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Prevents the disposal of the aggregated stream
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

NonClosingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/NonClosingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > NonClosingStream Class : Close Method

Glossary Item Box

Disposes of this.Stream

Syntax

Visual Basic (Declaration)
Public Overrides Sub Close()
C#
public override void Close()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

NonClosingStream Class
NonClosingStream Members
Base Implementation in Close

Source Code

Library/IO/NonClosingStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > NonClosingStream Class : Dispose Method

Glossary Item Box

Prevents the disposal of the aggregated stream

Overload List

Overload | Description
Dispose(Boolean) | Prevents the disposal of the aggregated stream
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

NonClosingStream Class
NonClosingStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > NonClosingStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Prevents the disposal of the aggregated stream

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

NonClosingStream Class
NonClosingStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplaceFile Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : ReplaceFile Class

Glossary Item Box

Creates a temp file based on the given file being replaced and when a call to Commit() is made the target file is replaced with the current contents of the temporary file. Use the TransactFile if you MUST be certain to succeed then Commit(), otherwise this implementation provides a 'good-enough' transaction and is optimized for larger files.

Syntax

Visual Basic (Declaration)
Public Class ReplaceFile
   Inherits TempFile
   Implements CSharpTest.Net.Interfaces.ITransactable
C#
public class ReplaceFile : TempFile, CSharpTest.Net.Interfaces.ITransactable

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();

using (TempFile replace = new TempFile())
using (ReplaceFile temp = new ReplaceFile(replace.TempPath))
{
    temp.WriteAllText(testdata);
    Assert.IsTrue(temp.Exists);
    temp.Rollback();
    Assert.IsFalse(temp.Exists);
}
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()

Using replace As New TempFile()
    Using temp As New ReplaceFile(replace.TempPath)
        temp.WriteAllText(testdata)
        Assert.IsTrue(temp.Exists)
        temp.Rollback()
        Assert.IsFalse(temp.Exists)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.TempFile
CSharpTest.Net.IO.ReplaceFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ReplaceFile Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : ReplaceFile Class

Glossary Item Box

The following tables list the members exposed by ReplaceFile.

Public Constructors

 | Name | Description
Public Constructor | ReplaceFile Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Exists | Returns true if the current temp file exists. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | Info | Returns the FileInfo object for this temp file. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | Length | Gets or sets the current length of the temp file. If setting the length on a file that does not exist one will be created. If getting the length of a file that doesnt exist zero will be returned. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | TargetFile | Returns the originally provided filename that is being replaced
Public Property | TempPath | Returns the temporary file path being managed. (Inherited from CSharpTest.Net.IO.TempFile)
Top

Public Methods

 | Name | Description
Public Method | Commit | Commits the replace operation on the file
Public Method | CopyTo | Overloaded. Copies the file content to the specified target file name (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Create | Re-Creates and Opens the temporary file for writing, multiple calls will truncate existing data. (Inherited from CSharpTest.Net.IO.TempFile)
static (Shared in Visual Basic) | CreateDerivedFile | Derives a new filename that doesn't exist from the provided name, ie. file.txt becomes file.txt.~0001
Public Method | Delete | Deletes the current temp file immediatly if it exists. (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Detatch | Detatches this instance from the temporary file and returns the temp file's path (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Dispose | Overloaded. Overridden. Disposes of the open stream and the temporary file.
Public Method | Open | Open or Create the temporary file for reading and writing (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Read | Overloaded. Opens the temporary file for reading (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | ReadAllBytes | Reads all bytes from the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | ReadAllText | Reads all UTF8 text from the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Rollback | Aborts the operation and reverts pending changes
Public Method | WriteAllBytes | Writes all bytes to the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | WriteAllText | Writes all UTF8 text to the file (Inherited from CSharpTest.Net.IO.TempFile)
Top

See Also

Reference

ReplaceFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplaceFile Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class : ReplaceFile Constructor

Glossary Item Box

Overload List

Overload | Description
ReplaceFile Constructor(String) | Creates a temp file based on the given file being replaced and when a call to Commit() is made the target file is replaced with the current contents of the temporary file.
ReplaceFile Constructor(String,String) | Creates a backup of the target file when replacing using the extension provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplaceFile Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class > ReplaceFile Constructor : ReplaceFile Constructor(String)

targetName

Glossary Item Box

Creates a temp file based on the given file being replaced and when a call to Commit() is made the target file is replaced with the current contents of the temporary file.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal targetName As String _
)
C#
public ReplaceFile(
   string targetName
)

Parameters

targetName

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();

using (TempFile replace = new TempFile())
using (ReplaceFile temp = new ReplaceFile(replace.TempPath))
{
    temp.WriteAllText(testdata);
    Assert.IsTrue(temp.Exists);
    temp.Rollback();
    Assert.IsFalse(temp.Exists);
}
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()

Using replace As New TempFile()
    Using temp As New ReplaceFile(replace.TempPath)
        temp.WriteAllText(testdata)
        Assert.IsTrue(temp.Exists)
        temp.Rollback()
        Assert.IsFalse(temp.Exists)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members
Overload List

Used By

IOStream.Compress(String,String)
IOStream.Decompress(String,String)

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplaceFile Constructor(String,String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class > ReplaceFile Constructor : ReplaceFile Constructor(String,String)

targetName
The name of the file to replace
backupExtension
A valid file extension beginning with '.'

Glossary Item Box

Creates a backup of the target file when replacing using the extension provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal targetName As String, _
   ByVal backupExtension As String _
)
C#
public ReplaceFile(
   string targetName,
   string backupExtension
)

Parameters

targetName
The name of the file to replace
backupExtension
A valid file extension beginning with '.'

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();
string tmpPath;

TempFile replace = new TempFile();
using (ReplaceFile temp = new ReplaceFile(replace.TempPath))
{
    Assert.AreEqual(temp.TargetFile, replace.TempPath);
    tmpPath = temp.TempPath;
    Assert.IsTrue(temp.Exists);
    temp.WriteAllText(testdata);
    //missing commit:
    //temp.Commit();
}
Assert.AreEqual(0, replace.Length);
Assert.IsFalse(File.Exists(tmpPath));

string backupfile = Path.ChangeExtension(replace.TempPath, ".bak");
File.Delete(Path.ChangeExtension(replace.TempPath, ".bak"));
Assert.IsFalse(File.Exists(backupfile));
replace.WriteAllText("backup");

//now for real
using (ReplaceFile temp = new ReplaceFile(replace.TempPath, ".bak"))
{
    tmpPath = temp.TempPath;
    Assert.IsTrue(temp.Exists);
    temp.WriteAllText(testdata);
    temp.Commit();
}
Assert.IsFalse(File.Exists(tmpPath));
Assert.AreEqual(testdata, replace.ReadAllText());

Assert.IsTrue(File.Exists(backupfile));
using (TempFile fbackup = TempFile.Attach(backupfile))
    Assert.AreEqual("backup", fbackup.ReadAllText());
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()
Dim tmpPath As String

Dim replace As New TempFile()
Using temp As New ReplaceFile(replace.TempPath)
    Assert.AreEqual(temp.TargetFile, replace.TempPath)
    tmpPath = temp.TempPath
    Assert.IsTrue(temp.Exists)
        'missing commit:
        'temp.Commit();
    temp.WriteAllText(testdata)
End Using
Assert.AreEqual(0, replace.Length)
Assert.IsFalse(File.Exists(tmpPath))

Dim backupfile As String = Path.ChangeExtension(replace.TempPath, ".bak")
File.Delete(Path.ChangeExtension(replace.TempPath, ".bak"))
Assert.IsFalse(File.Exists(backupfile))
replace.WriteAllText("backup")

'now for real
Using temp As New ReplaceFile(replace.TempPath, ".bak")
    tmpPath = temp.TempPath
    Assert.IsTrue(temp.Exists)
    temp.WriteAllText(testdata)
    temp.Commit()
End Using
Assert.IsFalse(File.Exists(tmpPath))
Assert.AreEqual(testdata, replace.ReadAllText())

Assert.IsTrue(File.Exists(backupfile))
Using fbackup As TempFile = TempFile.Attach(backupfile)
    Assert.AreEqual("backup", fbackup.ReadAllText())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members
Overload List

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ReplaceFile Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : ReplaceFile Class

Glossary Item Box

For a list of all members of this type, see ReplaceFile members.

Public Methods

 | Name | Description
Public Method | Commit | Commits the replace operation on the file
Public Method | CopyTo | Overloaded. Copies the file content to the specified target file name (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Create | Re-Creates and Opens the temporary file for writing, multiple calls will truncate existing data. (Inherited from CSharpTest.Net.IO.TempFile)
static (Shared in Visual Basic) | CreateDerivedFile | Derives a new filename that doesn't exist from the provided name, ie. file.txt becomes file.txt.~0001
Public Method | Delete | Deletes the current temp file immediatly if it exists. (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Detatch | Detatches this instance from the temporary file and returns the temp file's path (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Dispose | Overloaded. Overridden. Disposes of the open stream and the temporary file.
Public Method | Open | Open or Create the temporary file for reading and writing (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Read | Overloaded. Opens the temporary file for reading (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | ReadAllBytes | Reads all bytes from the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | ReadAllText | Reads all UTF8 text from the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Rollback | Aborts the operation and reverts pending changes
Public Method | WriteAllBytes | Writes all bytes to the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | WriteAllText | Writes all UTF8 text to the file (Inherited from CSharpTest.Net.IO.TempFile)
Top

See Also

Reference

ReplaceFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Commit Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class : Commit Method

Glossary Item Box

Commits the replace operation on the file

Syntax

Visual Basic (Declaration)
Public Sub Commit()
C#
public void Commit()

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();
string tmpPath;

TempFile replace = new TempFile();
using (ReplaceFile temp = new ReplaceFile(replace.TempPath))
{
    Assert.AreEqual(temp.TargetFile, replace.TempPath);
    tmpPath = temp.TempPath;
    Assert.IsTrue(temp.Exists);
    temp.WriteAllText(testdata);
    //missing commit:
    //temp.Commit();
}
Assert.AreEqual(0, replace.Length);
Assert.IsFalse(File.Exists(tmpPath));

string backupfile = Path.ChangeExtension(replace.TempPath, ".bak");
File.Delete(Path.ChangeExtension(replace.TempPath, ".bak"));
Assert.IsFalse(File.Exists(backupfile));
replace.WriteAllText("backup");

//now for real
using (ReplaceFile temp = new ReplaceFile(replace.TempPath, ".bak"))
{
    tmpPath = temp.TempPath;
    Assert.IsTrue(temp.Exists);
    temp.WriteAllText(testdata);
    temp.Commit();
}
Assert.IsFalse(File.Exists(tmpPath));
Assert.AreEqual(testdata, replace.ReadAllText());

Assert.IsTrue(File.Exists(backupfile));
using (TempFile fbackup = TempFile.Attach(backupfile))
    Assert.AreEqual("backup", fbackup.ReadAllText());
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()
Dim tmpPath As String

Dim replace As New TempFile()
Using temp As New ReplaceFile(replace.TempPath)
    Assert.AreEqual(temp.TargetFile, replace.TempPath)
    tmpPath = temp.TempPath
    Assert.IsTrue(temp.Exists)
        'missing commit:
        'temp.Commit();
    temp.WriteAllText(testdata)
End Using
Assert.AreEqual(0, replace.Length)
Assert.IsFalse(File.Exists(tmpPath))

Dim backupfile As String = Path.ChangeExtension(replace.TempPath, ".bak")
File.Delete(Path.ChangeExtension(replace.TempPath, ".bak"))
Assert.IsFalse(File.Exists(backupfile))
replace.WriteAllText("backup")

'now for real
Using temp As New ReplaceFile(replace.TempPath, ".bak")
    tmpPath = temp.TempPath
    Assert.IsTrue(temp.Exists)
    temp.WriteAllText(testdata)
    temp.Commit()
End Using
Assert.IsFalse(File.Exists(tmpPath))
Assert.AreEqual(testdata, replace.ReadAllText())

Assert.IsTrue(File.Exists(backupfile))
Using fbackup As TempFile = TempFile.Attach(backupfile)
    Assert.AreEqual("backup", fbackup.ReadAllText())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members

Used By

IOStream.Compress(String,String)
IOStream.Decompress(String,String)

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateDerivedFile Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class : CreateDerivedFile Method

originalPath
the name of the file
tempfilePath
[out] the temp file name

Glossary Item Box

Derives a new filename that doesn't exist from the provided name, ie. file.txt becomes file.txt.~0001

Syntax

Visual Basic (Declaration)
Public Shared Function CreateDerivedFile( _
   ByVal originalPath As String, _
   ByRef tempfilePath As String _
) As Stream
C#
public static Stream CreateDerivedFile(
   string originalPath,
   out string tempfilePath
)

Parameters

originalPath
the name of the file
tempfilePath
[out] the temp file name

Return Value

A stream with exclusive write access to the file

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string path;
using(DisposingList l = new DisposingList())
{
    TempFile ftarget = new TempFile();
    ftarget.Delete();

    l.Add(ftarget);
    TempFile fbigone = TempFile.Attach(String.Format("{0}.~{1:x4}", ftarget.TempPath, 0x10008 - 25));
    fbigone.Create().Dispose();
    Assert.IsTrue(fbigone.Exists);
    l.Add(fbigone);
    path = ftarget.TempPath;

    string tmpName;
    Dictionary<string, object> names = new Dictionary<string,object>(StringComparer.OrdinalIgnoreCase);

    for( int i=0; i < 25; i++ )
    {
        Stream s = ReplaceFile.CreateDerivedFile(ftarget.TempPath, out tmpName);
        l.Add(TempFile.Attach(tmpName));
        l.Add(s);
        names.Add(tmpName, null);
    }

    fbigone.Delete();
    Assert.AreEqual(25, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length);
}
Assert.AreEqual(0, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length);
VB.NET Copy Code
Dim path As String
Using l As New DisposingList()
    Dim ftarget As New TempFile()
    ftarget.Delete()

    l.Add(ftarget)
    Dim fbigone As TempFile = TempFile.Attach([String].Format("{0}.~{1:x4}", ftarget.TempPath, &H10008 - 25))
    fbigone.Create().Dispose()
    Assert.IsTrue(fbigone.Exists)
    l.Add(fbigone)
    path = ftarget.TempPath

    Dim tmpName As String
    Dim names As New Dictionary(Of String, Object)(StringComparer.OrdinalIgnoreCase)

    Dim i As Integer = 0
    While i < 25
        Dim s As Stream = ReplaceFile.CreateDerivedFile(ftarget.TempPath, tmpName)
        l.Add(TempFile.Attach(tmpName))
        l.Add(s)
        names.Add(tmpName, Nothing)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    fbigone.Delete()
    Assert.AreEqual(25, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length)
End Using
Assert.AreEqual(0, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class : Dispose Method

Glossary Item Box

Disposes of the open stream and the temporary file.

Overload List

Overload | Description
Dispose(Boolean) | Disposes of the open stream and the temporary file.
Dispose() | Disposes of the temporary file (Inherited from CSharpTest.Net.IO.TempFile)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of the open stream and the temporary file.

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Rollback Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class : Rollback Method

Glossary Item Box

Aborts the operation and reverts pending changes

Syntax

Visual Basic (Declaration)
Public Sub Rollback()
C#
public void Rollback()

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();

using (TempFile replace = new TempFile())
using (ReplaceFile temp = new ReplaceFile(replace.TempPath))
{
    temp.WriteAllText(testdata);
    Assert.IsTrue(temp.Exists);
    temp.Rollback();
    Assert.IsFalse(temp.Exists);
}
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()

Using replace As New TempFile()
    Using temp As New ReplaceFile(replace.TempPath)
        temp.WriteAllText(testdata)
        Assert.IsTrue(temp.Exists)
        temp.Rollback()
        Assert.IsFalse(temp.Exists)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ReplaceFile Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : ReplaceFile Class

Glossary Item Box

For a list of all members of this type, see ReplaceFile members.

Public Properties

 | Name | Description
Public Property | Exists | Returns true if the current temp file exists. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | Info | Returns the FileInfo object for this temp file. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | Length | Gets or sets the current length of the temp file. If setting the length on a file that does not exist one will be created. If getting the length of a file that doesnt exist zero will be returned. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | TargetFile | Returns the originally provided filename that is being replaced
Public Property | TempPath | Returns the temporary file path being managed. (Inherited from CSharpTest.Net.IO.TempFile)
Top

See Also

Reference

ReplaceFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TargetFile Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > ReplaceFile Class : TargetFile Property

Glossary Item Box

Returns the originally provided filename that is being replaced

Syntax

Visual Basic (Declaration)
Public ReadOnly Property TargetFile As String
C#
public string TargetFile {get;}

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();
string tmpPath;

TempFile replace = new TempFile();
using (ReplaceFile temp = new ReplaceFile(replace.TempPath))
{
    Assert.AreEqual(temp.TargetFile, replace.TempPath);
    tmpPath = temp.TempPath;
    Assert.IsTrue(temp.Exists);
    temp.WriteAllText(testdata);
    //missing commit:
    //temp.Commit();
}
Assert.AreEqual(0, replace.Length);
Assert.IsFalse(File.Exists(tmpPath));

string backupfile = Path.ChangeExtension(replace.TempPath, ".bak");
File.Delete(Path.ChangeExtension(replace.TempPath, ".bak"));
Assert.IsFalse(File.Exists(backupfile));
replace.WriteAllText("backup");

//now for real
using (ReplaceFile temp = new ReplaceFile(replace.TempPath, ".bak"))
{
    tmpPath = temp.TempPath;
    Assert.IsTrue(temp.Exists);
    temp.WriteAllText(testdata);
    temp.Commit();
}
Assert.IsFalse(File.Exists(tmpPath));
Assert.AreEqual(testdata, replace.ReadAllText());

Assert.IsTrue(File.Exists(backupfile));
using (TempFile fbackup = TempFile.Attach(backupfile))
    Assert.AreEqual("backup", fbackup.ReadAllText());
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()
Dim tmpPath As String

Dim replace As New TempFile()
Using temp As New ReplaceFile(replace.TempPath)
    Assert.AreEqual(temp.TargetFile, replace.TempPath)
    tmpPath = temp.TempPath
    Assert.IsTrue(temp.Exists)
        'missing commit:
        'temp.Commit();
    temp.WriteAllText(testdata)
End Using
Assert.AreEqual(0, replace.Length)
Assert.IsFalse(File.Exists(tmpPath))

Dim backupfile As String = Path.ChangeExtension(replace.TempPath, ".bak")
File.Delete(Path.ChangeExtension(replace.TempPath, ".bak"))
Assert.IsFalse(File.Exists(backupfile))
replace.WriteAllText("backup")

'now for real
Using temp As New ReplaceFile(replace.TempPath, ".bak")
    tmpPath = temp.TempPath
    Assert.IsTrue(temp.Exists)
    temp.WriteAllText(testdata)
    temp.Commit()
End Using
Assert.IsFalse(File.Exists(tmpPath))
Assert.AreEqual(testdata, replace.ReadAllText())

Assert.IsTrue(File.Exists(backupfile))
Using fbackup As TempFile = TempFile.Attach(backupfile)
    Assert.AreEqual("backup", fbackup.ReadAllText())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReplaceFile Class
ReplaceFile Members

Source Code

Library/IO/ReplaceFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SegmentedMemoryStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SegmentedMemoryStream Class

Glossary Item Box

Creates a stream over an array of byte arrays in memory to reduce use of the LOH and array resizing operation.

Syntax

Visual Basic (Declaration)
Public Class SegmentedMemoryStream
   Inherits System.IO.Stream
C#
public class SegmentedMemoryStream : System.IO.Stream

Example

Library/Library.Test/TestSegmentedStream.cs

C# Copy Code
using (SegmentedMemoryStream ms = new SegmentedMemoryStream(5))
{
    Write(ms, "12345");
    Write(ms, "abcd");
    Write(ms, "ABCDEF");
    Write(ms, "12345");
    Write(ms, "");

    ms.Flush();
    Assert.AreEqual(20L, ms.Length);
    Assert.AreEqual(20L, ms.Position);

    ms.Position = 0;
    Assert.AreEqual("12345abcdABCDEF12345", Read(ms, (int)ms.Length));

    ms.Position = 5;
    Assert.AreEqual("a", Read(ms, 1));
    Assert.AreEqual("bcd", Read(ms, 3));
    Assert.AreEqual("ABCDEF", Read(ms, 6));
    Assert.AreEqual("12345", Read(ms, 5));
    Assert.AreEqual(0, ms.Read(new byte[10], 0, 10));
}
VB.NET Copy Code
Using ms As New SegmentedMemoryStream(5)
    Write(ms, "12345")
    Write(ms, "abcd")
    Write(ms, "ABCDEF")
    Write(ms, "12345")
    Write(ms, "")

    ms.Flush()
    Assert.AreEqual(20L, ms.Length)
    Assert.AreEqual(20L, ms.Position)

    ms.Position = 0
    Assert.AreEqual("12345abcdABCDEF12345", Read(ms, DirectCast(ms.Length, Integer)))

    ms.Position = 5
    Assert.AreEqual("a", Read(ms, 1))
    Assert.AreEqual("bcd", Read(ms, 3))
    Assert.AreEqual("ABCDEF", Read(ms, 6))
    Assert.AreEqual("12345", Read(ms, 5))
    Assert.AreEqual(0, ms.Read(New Byte(10) {}, 0, 10))
End Using

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.SegmentedMemoryStream
CSharpTest.Net.IO.SharedMemoryStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SegmentedMemoryStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SegmentedMemoryStream Class

Glossary Item Box

The following tables list the members exposed by SegmentedMemoryStream.

Public Constructors

 | Name | Description
Public Constructor | SegmentedMemoryStream Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | Overridden. When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | Overridden. When overridden in a derived class, sets the length of the current stream.
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

SegmentedMemoryStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SegmentedMemoryStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : SegmentedMemoryStream Constructor

Glossary Item Box

Overload List

Overload | Description
SegmentedMemoryStream Constructor() | Creates a memory stream that uses 32k segments for storage
SegmentedMemoryStream Constructor(Int32) | Create a memory stream that uses the specified size of segments
SegmentedMemoryStream Constructor(SegmentedMemoryStream) | Creates a 'clone' of the stream sharing the same contents

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SegmentedMemoryStream Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class > SegmentedMemoryStream Constructor : SegmentedMemoryStream Constructor()

Glossary Item Box

Creates a memory stream that uses 32k segments for storage

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public SegmentedMemoryStream()

Example

Library/Library.Test/TestSegmentedStream.cs

C# Copy Code
using (SegmentedMemoryStream ms = new SegmentedMemoryStream())
{
    Assert.AreEqual(0L, ms.Length);
    Assert.AreEqual(0L, ms.Position);
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin));
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current));
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.End));

    ms.Position = 42L;
    Assert.AreEqual(42L, ms.Length);
    Assert.AreEqual(42L, ms.Position);
    Assert.AreEqual(42L, ms.Seek(42, System.IO.SeekOrigin.Begin));
    Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.Current));
    Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.End));

    ms.Position = 0;
    Assert.AreEqual(0L, ms.Position);
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin));
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current));
    Assert.AreEqual(0L, ms.Seek(-42, System.IO.SeekOrigin.End));
}
VB.NET Copy Code
Using ms As New SegmentedMemoryStream()
    Assert.AreEqual(0L, ms.Length)
    Assert.AreEqual(0L, ms.Position)
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin))
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current))
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.[End]))

    ms.Position = 42L
    Assert.AreEqual(42L, ms.Length)
    Assert.AreEqual(42L, ms.Position)
    Assert.AreEqual(42L, ms.Seek(42, System.IO.SeekOrigin.Begin))
    Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.Current))
    Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.[End]))

    ms.Position = 0
    Assert.AreEqual(0L, ms.Position)
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin))
    Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current))
    Assert.AreEqual(0L, ms.Seek(-42, System.IO.SeekOrigin.[End]))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Overload List

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SegmentedMemoryStream Constructor(Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class > SegmentedMemoryStream Constructor : SegmentedMemoryStream Constructor(Int32)

segmentSize

Glossary Item Box

Create a memory stream that uses the specified size of segments

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal segmentSize As Integer _
)
C#
public SegmentedMemoryStream(
   int segmentSize
)

Parameters

segmentSize

Example

Library/Library.Test/TestSegmentedStream.cs

C# Copy Code
using (SegmentedMemoryStream ms = new SegmentedMemoryStream(5))
{
    Write(ms, "12345");
    Write(ms, "abcd");
    Write(ms, "ABCDEF");
    Write(ms, "12345");
    Write(ms, "");

    ms.Flush();
    Assert.AreEqual(20L, ms.Length);
    Assert.AreEqual(20L, ms.Position);

    ms.Position = 0;
    Assert.AreEqual("12345abcdABCDEF12345", Read(ms, (int)ms.Length));

    ms.Position = 5;
    Assert.AreEqual("a", Read(ms, 1));
    Assert.AreEqual("bcd", Read(ms, 3));
    Assert.AreEqual("ABCDEF", Read(ms, 6));
    Assert.AreEqual("12345", Read(ms, 5));
    Assert.AreEqual(0, ms.Read(new byte[10], 0, 10));
}
VB.NET Copy Code
Using ms As New SegmentedMemoryStream(5)
    Write(ms, "12345")
    Write(ms, "abcd")
    Write(ms, "ABCDEF")
    Write(ms, "12345")
    Write(ms, "")

    ms.Flush()
    Assert.AreEqual(20L, ms.Length)
    Assert.AreEqual(20L, ms.Position)

    ms.Position = 0
    Assert.AreEqual("12345abcdABCDEF12345", Read(ms, DirectCast(ms.Length, Integer)))

    ms.Position = 5
    Assert.AreEqual("a", Read(ms, 1))
    Assert.AreEqual("bcd", Read(ms, 3))
    Assert.AreEqual("ABCDEF", Read(ms, 6))
    Assert.AreEqual("12345", Read(ms, 5))
    Assert.AreEqual(0, ms.Read(New Byte(10) {}, 0, 10))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Overload List

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SegmentedMemoryStream Constructor(SegmentedMemoryStream)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class > SegmentedMemoryStream Constructor : SegmentedMemoryStream Constructor(SegmentedMemoryStream)

from

Glossary Item Box

Creates a 'clone' of the stream sharing the same contents

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal from As SegmentedMemoryStream _
)
C#
protected SegmentedMemoryStream(
   SegmentedMemoryStream from
)

Parameters

from

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Overload List


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SegmentedMemoryStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SegmentedMemoryStream Class

Glossary Item Box

For a list of all members of this type, see SegmentedMemoryStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Overridden. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | Overridden. When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | Overridden. When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Public Method | ReadByte | Overridden. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Public Method | Seek | Overridden. When overridden in a derived class, sets the position within the current stream.
Public Method | SetLength | Overridden. When overridden in a derived class, sets the length of the current stream.
Public Method | Write | Overridden. When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Public Method | WriteByte | Overridden. Writes a byte to the current position in the stream and advances the position within the stream by one byte.
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

SegmentedMemoryStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : Dispose Method

Glossary Item Box

Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

Overload List

Overload | Description
Dispose(Boolean) | Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.
Dispose() | Releases all resources used by the System.IO.Stream. (Inherited from System.IO.Stream)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Flush Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : Flush Method

Glossary Item Box

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Flush()
C#
public override void Flush()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in Flush

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : Read Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Syntax

Visual Basic (Declaration)
Public Overrides Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
C#
public override int Read(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in Read

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : ReadByte Method

Glossary Item Box

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function ReadByte() As Integer
C#
public override int ReadByte()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in ReadByte

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Seek Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : Seek Method

offset
origin

Glossary Item Box

When overridden in a derived class, sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Function Seek( _
   ByVal offset As Long, _
   ByVal origin As SeekOrigin _
) As Long
C#
public override long Seek(
   long offset,
   SeekOrigin origin
)

Parameters

offset
origin

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in Seek

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetLength Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : SetLength Method

value

Glossary Item Box

When overridden in a derived class, sets the length of the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Sub SetLength( _
   ByVal value As Long _
)
C#
public override void SetLength(
   long value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in SetLength

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : Write Method

buffer
offset
count

Glossary Item Box

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Syntax

Visual Basic (Declaration)
Public Overrides Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
)
C#
public override void Write(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in Write

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteByte Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : WriteByte Method

value

Glossary Item Box

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Syntax

Visual Basic (Declaration)
Public Overrides Sub WriteByte( _
   ByVal value As Byte _
)
C#
public override void WriteByte(
   byte value
)

Parameters

value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in WriteByte

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SegmentedMemoryStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SegmentedMemoryStream Class

Glossary Item Box

For a list of all members of this type, see SegmentedMemoryStream members.

Public Properties

 | Name | Description
Public Property | CanRead | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Public Property | CanSeek | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | Overridden. When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Public Property | Length | Overridden. When overridden in a derived class, gets the length in bytes of the stream.
Public Property | Position | Overridden. When overridden in a derived class, gets or sets the position within the current stream.
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

SegmentedMemoryStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanRead Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : CanRead Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanRead As Boolean
C#
public override bool CanRead {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in CanRead

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanSeek Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : CanSeek Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanSeek As Boolean
C#
public override bool CanSeek {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in CanSeek

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CanWrite Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : CanWrite Property

Glossary Item Box

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property CanWrite As Boolean
C#
public override bool CanWrite {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in CanWrite

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : Length Property

Glossary Item Box

When overridden in a derived class, gets the length in bytes of the stream.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property Length As Long
C#
public override long Length {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in Length

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Position Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SegmentedMemoryStream Class : Position Property

Glossary Item Box

When overridden in a derived class, gets or sets the position within the current stream.

Syntax

Visual Basic (Declaration)
Public Overrides Property Position As Long
C#
public override long Position {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SegmentedMemoryStream Class
SegmentedMemoryStream Members
Base Implementation in Position

Source Code

Library/IO/SegmentedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SharedMemoryStream Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SharedMemoryStream Class

Glossary Item Box

A memory stream that can be cloned to create an instance for another thread to access the same memory pool.

Syntax

Visual Basic (Declaration)
Public Class SharedMemoryStream
   Inherits SegmentedMemoryStream
   Implements CSharpTest.Net.Interfaces.IFactory(Of Stream)
C#
public class SharedMemoryStream : SegmentedMemoryStream, CSharpTest.Net.Interfaces.IFactory<Stream>

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        stream.Write(new byte[100], 25, 55);
        stream.Close();
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.AreEqual(new byte[55], IOStream.ReadAllBytes(stream));
    }
}
VB.NET Copy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        stream.Write(New Byte(100) {}, 25, 55)
        stream.Close()
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.AreEqual(New Byte(55) {}, IOStream.ReadAllBytes(stream))
    End Using
End Using

Inheritance Hierarchy

System.Object
System.MarshalByRefObject
System.IO.Stream
CSharpTest.Net.IO.SegmentedMemoryStream
CSharpTest.Net.IO.SharedMemoryStream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SharedMemoryStream Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/SharedMemoryStream.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SharedMemoryStream Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SharedMemoryStream Class

Glossary Item Box

The following tables list the members exposed by SharedMemoryStream.

Public Constructors

 | Name | Description
Public Constructor | SharedMemoryStream Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Clone | Returns a 'clone' of this stream so that the two instances act independantly upon a single set of data
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

SharedMemoryStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/SharedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SharedMemoryStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SharedMemoryStream Class : SharedMemoryStream Constructor

Glossary Item Box

Overload List

Overload | Description
SharedMemoryStream Constructor() | Creates a memory stream that uses 32k segments for storage
SharedMemoryStream Constructor(Int32) | Create a memory stream that uses the specified size of segments
SharedMemoryStream Constructor(SharedMemoryStream) | Creates a 'clone' of the stream sharing the same contents

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SharedMemoryStream Class
SharedMemoryStream Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SharedMemoryStream Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SharedMemoryStream Class > SharedMemoryStream Constructor : SharedMemoryStream Constructor()

Glossary Item Box

Creates a memory stream that uses 32k segments for storage

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public SharedMemoryStream()

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        stream.Write(new byte[100], 25, 55);
        stream.Close();
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.AreEqual(new byte[55], IOStream.ReadAllBytes(stream));
    }
}
VB.NET Copy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        stream.Write(New Byte(100) {}, 25, 55)
        stream.Close()
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.AreEqual(New Byte(55) {}, IOStream.ReadAllBytes(stream))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SharedMemoryStream Class
SharedMemoryStream Members
Overload List

Source Code

Library/IO/SharedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SharedMemoryStream Constructor(Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SharedMemoryStream Class > SharedMemoryStream Constructor : SharedMemoryStream Constructor(Int32)

segmentSize

Glossary Item Box

Create a memory stream that uses the specified size of segments

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal segmentSize As Integer _
)
C#
public SharedMemoryStream(
   int segmentSize
)

Parameters

segmentSize

Example

Library/Library.Test/TestSegmentedStream.cs

C# Copy Code
using (ManualResetEvent mreStart = new ManualResetEvent(false))
using (SharedMemoryStream shared = new SharedMemoryStream(5))
using (SharedMemoryStream copy = shared.Clone())
{
    Thread[] allwriters = new Thread[Math.Max(1, Environment.ProcessorCount - 1)];
    for (int tix = 0; tix < allwriters.Length; tix++)
    {
        allwriters[tix] = new Thread(
            delegate()
                {
                    using (SharedMemoryStream stream = shared.Clone())
                    {
                        Random r = new Random();
                        mreStart.WaitOne();
                        for (int i = 0; i < 1000; i++)
                        {
                            PrimitiveSerializer.Int32.WriteTo(i, stream);
                            Thread.SpinWait(r.Next(i));
                        }
                    }
                }
            );
        allwriters[tix].IsBackground = true;
        allwriters[tix].Start();
    }

    mreStart.Set();
    foreach(Thread t in allwriters)
        Assert.IsTrue(t.Join(100));

    for (int i = 0; i < 1000; i++)
    {
        int value = PrimitiveSerializer.Int32.ReadFrom(copy);
        Assert.AreEqual(i, value);
    }
}
VB.NET Copy Code
Using mreStart As New ManualResetEvent(False)
    Using [shared] As New SharedMemoryStream(5)
        Using copy As SharedMemoryStream = [shared].Clone()
            Dim allwriters As Thread() = New Thread(Math.Max(1, Environment.ProcessorCount - 1)) {}
            Dim tix As Integer = 0
            While tix < allwriters.Length
                allwriters(tix) = New Thread(Function() Do
                    Using stream As SharedMemoryStream = [shared].Clone()
                        Dim r As New Random()
                        mreStart.WaitOne()
                        Dim i As Integer = 0
                        While i < 1000
                            PrimitiveSerializer.Int32.WriteTo(i, stream)
                            Thread.SpinWait(r.[Next](i))
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                    End Using
                End Function)
                allwriters(tix).IsBackground = True
                allwriters(tix).Start()
                System.Math.Max(System.Threading.Interlocked.Increment(tix),tix - 1)
            End While

            mreStart.[Set]()
            For Each t As Thread In allwriters
                Assert.IsTrue(t.Join(100))
            Next

            Dim i As Integer = 0
            While i < 1000
                Dim value As Integer = PrimitiveSerializer.Int32.ReadFrom(copy)
                Assert.AreEqual(i, value)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SharedMemoryStream Class
SharedMemoryStream Members
Overload List

Source Code

Library/IO/SharedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SharedMemoryStream Constructor(SharedMemoryStream)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SharedMemoryStream Class > SharedMemoryStream Constructor : SharedMemoryStream Constructor(SharedMemoryStream)

from

Glossary Item Box

Creates a 'clone' of the stream sharing the same contents

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal from As SharedMemoryStream _
)
C#
public SharedMemoryStream(
   SharedMemoryStream from
)

Parameters

from

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SharedMemoryStream Class
SharedMemoryStream Members
Overload List

Used By

SharedMemoryStream SharedMemoryStream.Clone()

Source Code

Library/IO/SharedMemoryStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SharedMemoryStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SharedMemoryStream Class

Glossary Item Box

For a list of all members of this type, see SharedMemoryStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Clone | Returns a 'clone' of this stream so that the two instances act independantly upon a single set of data
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

SharedMemoryStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/SharedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > SharedMemoryStream Class : Clone Method

Glossary Item Box

Returns a 'clone' of this stream so that the two instances act independantly upon a single set of data

Syntax

Visual Basic (Declaration)
Public Function Clone() As SharedMemoryStream
C#
public SharedMemoryStream Clone()

Example

Library/Library.Test/TestSegmentedStream.cs

C# Copy Code
using (ManualResetEvent mreStart = new ManualResetEvent(false))
using (SharedMemoryStream shared = new SharedMemoryStream(5))
using (SharedMemoryStream copy = shared.Clone())
{
    Thread[] allwriters = new Thread[Math.Max(1, Environment.ProcessorCount - 1)];
    for (int tix = 0; tix < allwriters.Length; tix++)
    {
        allwriters[tix] = new Thread(
            delegate()
                {
                    using (SharedMemoryStream stream = shared.Clone())
                    {
                        Random r = new Random();
                        mreStart.WaitOne();
                        for (int i = 0; i < 1000; i++)
                        {
                            PrimitiveSerializer.Int32.WriteTo(i, stream);
                            Thread.SpinWait(r.Next(i));
                        }
                    }
                }
            );
        allwriters[tix].IsBackground = true;
        allwriters[tix].Start();
    }

    mreStart.Set();
    foreach(Thread t in allwriters)
        Assert.IsTrue(t.Join(100));

    for (int i = 0; i < 1000; i++)
    {
        int value = PrimitiveSerializer.Int32.ReadFrom(copy);
        Assert.AreEqual(i, value);
    }
}
VB.NET Copy Code
Using mreStart As New ManualResetEvent(False)
    Using [shared] As New SharedMemoryStream(5)
        Using copy As SharedMemoryStream = [shared].Clone()
            Dim allwriters As Thread() = New Thread(Math.Max(1, Environment.ProcessorCount - 1)) {}
            Dim tix As Integer = 0
            While tix < allwriters.Length
                allwriters(tix) = New Thread(Function() Do
                    Using stream As SharedMemoryStream = [shared].Clone()
                        Dim r As New Random()
                        mreStart.WaitOne()
                        Dim i As Integer = 0
                        While i < 1000
                            PrimitiveSerializer.Int32.WriteTo(i, stream)
                            Thread.SpinWait(r.[Next](i))
                            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                        End While
                    End Using
                End Function)
                allwriters(tix).IsBackground = True
                allwriters(tix).Start()
                System.Math.Max(System.Threading.Interlocked.Increment(tix),tix - 1)
            End While

            mreStart.[Set]()
            For Each t As Thread In allwriters
                Assert.IsTrue(t.Join(100))
            Next

            Dim i As Integer = 0
            While i < 1000
                Dim value As Integer = PrimitiveSerializer.Int32.ReadFrom(copy)
                Assert.AreEqual(i, value)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SharedMemoryStream Class
SharedMemoryStream Members

Source Code

Library/IO/SharedMemoryStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamCache Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : StreamCache Class

Glossary Item Box

Provides a simple means of caching several streams on a single file and for a thread to quickly exclusive access to one of those streams. This class provides the base implementation used by FileStreamCache and FragmentedFile.

Syntax

Visual Basic (Declaration)
Public Class StreamCache
   Inherits CSharpTest.Net.Bases.Disposable
   Implements CSharpTest.Net.Interfaces.IFactory(Of Stream)
C#
public class StreamCache : CSharpTest.Net.Bases.Disposable, CSharpTest.Net.Interfaces.IFactory<Stream>

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        stream.Write(new byte[100], 25, 55);
        stream.Close();
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.AreEqual(new byte[55], IOStream.ReadAllBytes(stream));
    }
}
VB.NET Copy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        stream.Write(New Byte(100) {}, 25, 55)
        stream.Close()
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.AreEqual(New Byte(55) {}, IOStream.ReadAllBytes(stream))
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Disposable
CSharpTest.Net.IO.StreamCache

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/StreamCache.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
StreamCache Class Members
See Also Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : StreamCache Class

Glossary Item Box

The following tables list the members exposed by StreamCache.

Public Constructors

 | Name | Description
Public Constructor | StreamCache Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Overloaded. Overridden. disposes of the object if it has not already been disposed
Public Method | Open | Overloaded. Waits for a stream to become available and returns a wrapper on that stream. Just dispose like any other stream to return the resource to the stream pool.
Top

Protected Methods

 | Name | Description
Protected Method | Assert | Raises the ObjectDisposedException if this object has already been disposed (Inherited from CSharpTest.Net.Bases.Disposable)
Top

Public Events

 | Name | Description
Public Event | Disposed | Raised when the object is disposed (Inherited from CSharpTest.Net.Bases.Disposable)
Top

See Also

Reference

StreamCache Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/StreamCache.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamCache Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class : StreamCache Constructor

Glossary Item Box

Overload List

Overload | Description
StreamCache Constructor(IFactory<Stream>) | Constructs the stream cache allowing one stream per thread
StreamCache Constructor(IFactory<Stream>,Int32) | Constructs the stream cache with the maximum allowed stream items

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Class
StreamCache Members


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamCache Constructor(IFactory<Stream>)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class > StreamCache Constructor : StreamCache Constructor(IFactory<Stream>)

streamFactory

Glossary Item Box

Constructs the stream cache allowing one stream per thread

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal streamFactory As IFactory(Of Stream) _
)
C#
public StreamCache(
   IFactory<Stream> streamFactory
)

Parameters

streamFactory

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (TempFile tempFile = new TempFile())
{
    using (StreamCache cache = new StreamCache(new FileStreamFactory(tempFile.TempPath, FileMode.Open)))
    {
        using (stream = cache.Open())
        {
            stream.SetLength(100);
            stream.WriteByte(1);
        }
    }

    Assert.AreEqual(100, tempFile.Length);
    using (stream = tempFile.Open())
        Assert.AreEqual(1, stream.ReadByte());
}
VB.NET Copy Code
Dim stream As Stream
Using tempFile As New TempFile()
    Using cache As New StreamCache(New FileStreamFactory(tempFile.TempPath, FileMode.Open))
        Using stream = cache.Open()
            stream.SetLength(100)
            stream.WriteByte(1)
        End Using
    End Using

    Assert.AreEqual(100, tempFile.Length)
    Using stream = tempFile.Open()
        Assert.AreEqual(1, stream.ReadByte())
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Class
StreamCache Members
Overload List

Source Code

Library/IO/StreamCache.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamCache Constructor(IFactory<Stream>,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class > StreamCache Constructor : StreamCache Constructor(IFactory<Stream>,Int32)

streamFactory
maxItem

Glossary Item Box

Constructs the stream cache with the maximum allowed stream items

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal streamFactory As IFactory(Of Stream), _
   ByVal maxItem As Integer _
)
C#
public StreamCache(
   IFactory<Stream> streamFactory,
   int maxItem
)

Parameters

streamFactory
maxItem

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        stream.Write(new byte[100], 25, 55);
        stream.Close();
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.AreEqual(new byte[55], IOStream.ReadAllBytes(stream));
    }
}
VB.NET Copy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        stream.Write(New Byte(100) {}, 25, 55)
        stream.Close()
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.AreEqual(New Byte(55) {}, IOStream.ReadAllBytes(stream))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Class
StreamCache Members
Overload List

Used By

Boolean SecureTransfer.Client.Download(String,Stream)
Boolean SecureTransfer.Client.Download(String,String)

Source Code

Library/IO/StreamCache.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
StreamCache Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : StreamCache Class

Glossary Item Box

For a list of all members of this type, see StreamCache members.

Public Methods

 | Name | Description
Public Method | Dispose | Overloaded. Overridden. disposes of the object if it has not already been disposed
Public Method | Open | Overloaded. Waits for a stream to become available and returns a wrapper on that stream. Just dispose like any other stream to return the resource to the stream pool.
Top

Protected Methods

 | Name | Description
Protected Method | Assert | Raises the ObjectDisposedException if this object has already been disposed (Inherited from CSharpTest.Net.Bases.Disposable)
Top

See Also

Reference

StreamCache Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/StreamCache.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class : Dispose Method

Glossary Item Box

disposes of the object if it has not already been disposed

Overload List

Overload | Description
Dispose(Boolean) |
Dispose() | disposes of the object if it has not already been disposed (Inherited from CSharpTest.Net.Bases.Disposable)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Class
StreamCache Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Class
StreamCache Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Open Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class : Open Method

Glossary Item Box

Waits for a stream to become available and returns a wrapper on that stream. Just dispose like any other stream to return the resource to the stream pool.

Overload List

Overload | Description
Open() | Waits for a stream to become available and returns a wrapper on that stream. Just dispose like any other stream to return the resource to the stream pool.
Open(FileAccess) | Waits for a stream to become available and returns a wrapper on that stream. Just dispose like any other stream to return the resource to the stream pool.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Class
StreamCache Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Open() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class > Open Method : Open() Method

Glossary Item Box

Waits for a stream to become available and returns a wrapper on that stream. Just dispose like any other stream to return the resource to the stream pool.

Syntax

Visual Basic (Declaration)
Public Overloads Function Open() As Stream
C#
public Stream Open()

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        stream.Write(new byte[100], 25, 55);
        stream.Close();
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.AreEqual(new byte[55], IOStream.ReadAllBytes(stream));
    }
}
VB.NET Copy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        stream.Write(New Byte(100) {}, 25, 55)
        stream.Close()
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.AreEqual(New Byte(55) {}, IOStream.ReadAllBytes(stream))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Class
StreamCache Members
Overload List

Source Code

Library/IO/StreamCache.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Open(FileAccess) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > StreamCache Class > Open Method : Open(FileAccess) Method

access

Glossary Item Box

Waits for a stream to become available and returns a wrapper on that stream. Just dispose like any other stream to return the resource to the stream pool.

Syntax

Visual Basic (Declaration)
Public Overloads Function Open( _
   ByVal access As FileAccess _
) As Stream
C#
public Stream Open(
   FileAccess access
)

Parameters

access

Example

Library/Library.Test/TestStreamCache.cs

C# Copy Code
Stream stream;
using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1))
{
    using (stream = cache.Open())
    {
        stream.Write(new byte[100], 25, 55);
        stream.Close();
    }
    using (stream = cache.Open(FileAccess.Read))
    {
        Assert.AreEqual(new byte[55], IOStream.ReadAllBytes(stream));
    }
}
VB.NET Copy Code
Dim stream As Stream
Using cache As New StreamCache(New SharedMemoryStream(), 1)
    Using stream = cache.Open()
        stream.Write(New Byte(100) {}, 25, 55)
        stream.Close()
    End Using
    Using stream = cache.Open(FileAccess.Read)
        Assert.AreEqual(New Byte(55) {}, IOStream.ReadAllBytes(stream))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamCache Class
StreamCache Members
Overload List

Used By

FragmentedFile.Dispose()
FragmentedFile.Clear()
Stream StreamCache.Open()

Source Code

Library/IO/StreamCache.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpClientEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpClientEventArgs Class

Glossary Item Box

Provides a buffered state of the client connection

Syntax

Visual Basic (Declaration)
Public MustInherit Class TcpClientEventArgs
   Inherits System.EventArgs
C#
public abstract class TcpClientEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.IO.TcpClientEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Members
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TcpClientEventArgs Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpClientEventArgs Class

Glossary Item Box

The following tables list the members exposed by TcpClientEventArgs.

Protected Constructors

 | Name | Description
Protected Constructor | TcpClientEventArgs Constructor | ctor for TcpClientEventArgs
Top

Public Fields

 | Name | Description
Public Field | Client | Returns the TcpClient for this connection, should not be used directly.
Public Field | Host | Returns the TcpServer
Top

Public Properties

 | Name | Description
Public Property | BytesAvailable | Returns the number of bytes currently available.
Public Property | BytesDesired | Sets or Gets the number of bytes required to fulfill the request. The event will not be notified again until the required bytes have been read from the socket.
Public Property | UserData | Sets or Gets custom user information associated with this connection.
Top

Public Methods

 | Name | Description
Public Method | Close | Closes the connection.
Public Method | ConsumeBytes | Consumes (removes from buffer) the number of bytes specified
Public Method | GetBuffer | Returns the buffer being used for reading (not a copy, be careful)
Public Method | Read | Reads (and consumes) the number of bytes specified
Public Method | Write | Writes a response to the client
Top

See Also

Reference

TcpClientEventArgs Class
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpClientEventArgs Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : TcpClientEventArgs Constructor

host
client

Glossary Item Box

ctor for TcpClientEventArgs

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal host As TcpServer, _
   ByVal client As TcpClient _
)
C#
protected TcpClientEventArgs(
   TcpServer host,
   TcpClient client
)

Parameters

host
client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TcpClientEventArgs Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpClientEventArgs Class

Glossary Item Box

For a list of all members of this type, see TcpClientEventArgs members.

Public Methods

 | Name | Description
Public Method | Close | Closes the connection.
Public Method | ConsumeBytes | Consumes (removes from buffer) the number of bytes specified
Public Method | GetBuffer | Returns the buffer being used for reading (not a copy, be careful)
Public Method | Read | Reads (and consumes) the number of bytes specified
Public Method | Write | Writes a response to the client
Top

See Also

Reference

TcpClientEventArgs Class
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : Close Method

Glossary Item Box

Closes the connection.

Syntax

Visual Basic (Declaration)
Public MustOverride Sub Close()
C#
public abstract void Close()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ConsumeBytes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : ConsumeBytes Method

count

Glossary Item Box

Consumes (removes from buffer) the number of bytes specified

Syntax

Visual Basic (Declaration)
Public Sub ConsumeBytes( _
   ByVal count As Integer _
)
C#
public void ConsumeBytes(
   int count
)

Parameters

count

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members

Used By

Int32 TcpClientEventArgs.Read(Byte[],Int32,Int32)

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetBuffer Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : GetBuffer Method

Glossary Item Box

Returns the buffer being used for reading (not a copy, be careful)

Syntax

Visual Basic (Declaration)
Public MustOverride Function GetBuffer() As Byte()
C#
public abstract byte[] GetBuffer()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members

Used By

Int32 TcpClientEventArgs.Read(Byte[],Int32,Int32)
TcpClientEventArgs.ConsumeBytes(Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : Read Method

buffer
offset
count

Glossary Item Box

Reads (and consumes) the number of bytes specified

Syntax

Visual Basic (Declaration)
Public Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
C#
public int Read(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : Write Method

buffer
offset
count

Glossary Item Box

Writes a response to the client

Syntax

Visual Basic (Declaration)
Public MustOverride Sub Write( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
)
C#
public abstract void Write(
   byte[] buffer,
   int offset,
   int count
)

Parameters

buffer
offset
count

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TcpClientEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpClientEventArgs Class

Glossary Item Box

For a list of all members of this type, see TcpClientEventArgs members.

Public Properties

 | Name | Description
Public Property | BytesAvailable | Returns the number of bytes currently available.
Public Property | BytesDesired | Sets or Gets the number of bytes required to fulfill the request. The event will not be notified again until the required bytes have been read from the socket.
Public Property | UserData | Sets or Gets custom user information associated with this connection.
Top

See Also

Reference

TcpClientEventArgs Class
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
BytesAvailable Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : BytesAvailable Property

Glossary Item Box

Returns the number of bytes currently available.

Syntax

Visual Basic (Declaration)
Public MustOverride ReadOnly Property BytesAvailable As Integer
C#
public abstract int BytesAvailable {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members

Used By

Int32 TcpClientEventArgs.Read(Byte[],Int32,Int32)
TcpClientEventArgs.ConsumeBytes(Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
BytesDesired Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : BytesDesired Property

Glossary Item Box

Sets or Gets the number of bytes required to fulfill the request. The event will not be notified again until the required bytes have been read from the socket.

Syntax

Visual Basic (Declaration)
Public Property BytesDesired As Integer
C#
public int BytesDesired {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members


%%PageItemTitle%%

[image]
CSharpTest.Net
UserData Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : UserData Property

Glossary Item Box

Sets or Gets custom user information associated with this connection.

Syntax

Visual Basic (Declaration)
Public Property UserData As Object
C#
public object UserData {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TcpClientEventArgs Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpClientEventArgs Class

Glossary Item Box

For a list of all members of this type, see TcpClientEventArgs members.

Public Fields

 | Name | Description
Public Field | Client | Returns the TcpClient for this connection, should not be used directly.
Public Field | Host | Returns the TcpServer
Top

See Also

Reference

TcpClientEventArgs Class
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Client Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : Client Field

Glossary Item Box

Returns the TcpClient for this connection, should not be used directly.

Syntax

Visual Basic (Declaration)
Public ReadOnly Client As TcpClient
C#
public readonly TcpClient Client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members

Used By

TcpServer.Stop()


%%PageItemTitle%%

[image]
CSharpTest.Net
Host Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpClientEventArgs Class : Host Field

Glossary Item Box

Returns the TcpServer

Syntax

Visual Basic (Declaration)
Public ReadOnly Host As TcpServer
C#
public readonly TcpServer Host

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClientEventArgs Class
TcpClientEventArgs Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpServer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpServer Class

Glossary Item Box

Hosts an TcpListener on a dedicated set of worker threads, providing a clean shutdown on dispose.

Syntax

Visual Basic (Declaration)
Public Class TcpServer
C#
public class TcpServer

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.TcpServer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Members
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TcpServer Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpServer Class

Glossary Item Box

The following tables list the members exposed by TcpServer.

Public Constructors

 | Name | Description
Public Constructor | TcpServer Constructor | Constructs the TcpServer with a fixed thread-pool size.
Top

Public Properties

 | Name | Description
Public Property | ShutdownEvent | Exposes a WaitHandle that can be used to signal other threads that the server is shutting down.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Start |
Public Method | Stop | Stops the server and all worker threads.
Top

Public Events

 | Name | Description
Public Event | OnClientClosed | Performs the processing of the request on one of the worker threads
Public Event | OnClientConnect | Performs the processing of the request on one of the worker threads
Public Event | OnDataRecieved | Performs the processing of the request on one of the worker threads
Public Event | OnError | Raised when an unhandled exception occurs.
Top

See Also

Reference

TcpServer Class
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpServer Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : TcpServer Constructor

maxThreads

Glossary Item Box

Constructs the TcpServer with a fixed thread-pool size.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal maxThreads As Integer _
)
C#
public TcpServer(
   int maxThreads
)

Parameters

maxThreads

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TcpServer Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpServer Class

Glossary Item Box

For a list of all members of this type, see TcpServer members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Start |
Public Method | Stop | Stops the server and all worker threads.
Top

See Also

Reference

TcpServer Class
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : Start Method

address
port

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Sub Start( _
   ByVal address As IPAddress, _
   ByVal port As Integer _
)
C#
public void Start(
   IPAddress address,
   int port
)

Parameters

address
port

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Stop Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : Stop Method

Glossary Item Box

Stops the server and all worker threads.

Syntax

Visual Basic (Declaration)
Public Sub Stop()
C#
public void Stop()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Used By

TcpServer.Dispose()

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TcpServer Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpServer Class

Glossary Item Box

For a list of all members of this type, see TcpServer members.

Public Properties

 | Name | Description
Public Property | ShutdownEvent | Exposes a WaitHandle that can be used to signal other threads that the server is shutting down.
Top

See Also

Reference

TcpServer Class
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ShutdownEvent Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : ShutdownEvent Property

Glossary Item Box

Exposes a WaitHandle that can be used to signal other threads that the server is shutting down.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ShutdownEvent As WaitHandle
C#
public WaitHandle ShutdownEvent {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
TcpServer Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TcpServer Class

Glossary Item Box

For a list of all members of this type, see TcpServer members.

Public Events

 | Name | Description
Public Event | OnClientClosed | Performs the processing of the request on one of the worker threads
Public Event | OnClientConnect | Performs the processing of the request on one of the worker threads
Public Event | OnDataRecieved | Performs the processing of the request on one of the worker threads
Public Event | OnError | Raised when an unhandled exception occurs.
Top

See Also

Reference

TcpServer Class
CSharpTest.Net.IO Namespace

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnClientClosed Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : OnClientClosed Event

Glossary Item Box

Performs the processing of the request on one of the worker threads

Syntax

Visual Basic (Declaration)
Public Event OnClientClosed As EventHandler(Of TcpClientEventArgs)
C#
public event EventHandler<TcpClientEventArgs> OnClientClosed

Event Data

The event handler receives an argument of type TcpClientEventArgs containing data related to this event. The following TcpClientEventArgs properties provide information specific to this event.

Property | Description
BytesAvailable | Returns the number of bytes currently available.
BytesDesired | Sets or Gets the number of bytes required to fulfill the request. The event will not be notified again until the required bytes have been read from the socket.
UserData | Sets or Gets custom user information associated with this connection.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnClientConnect Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : OnClientConnect Event

Glossary Item Box

Performs the processing of the request on one of the worker threads

Syntax

Visual Basic (Declaration)
Public Event OnClientConnect As EventHandler(Of TcpClientEventArgs)
C#
public event EventHandler<TcpClientEventArgs> OnClientConnect

Event Data

The event handler receives an argument of type TcpClientEventArgs containing data related to this event. The following TcpClientEventArgs properties provide information specific to this event.

Property | Description
BytesAvailable | Returns the number of bytes currently available.
BytesDesired | Sets or Gets the number of bytes required to fulfill the request. The event will not be notified again until the required bytes have been read from the socket.
UserData | Sets or Gets custom user information associated with this connection.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnDataRecieved Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : OnDataRecieved Event

Glossary Item Box

Performs the processing of the request on one of the worker threads

Syntax

Visual Basic (Declaration)
Public Event OnDataRecieved As EventHandler(Of TcpClientEventArgs)
C#
public event EventHandler<TcpClientEventArgs> OnDataRecieved

Event Data

The event handler receives an argument of type TcpClientEventArgs containing data related to this event. The following TcpClientEventArgs properties provide information specific to this event.

Property | Description
BytesAvailable | Returns the number of bytes currently available.
BytesDesired | Sets or Gets the number of bytes required to fulfill the request. The event will not be notified again until the required bytes have been read from the socket.
UserData | Sets or Gets custom user information associated with this connection.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnError Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TcpServer Class : OnError Event

Glossary Item Box

Raised when an unhandled exception occurs.

Syntax

Visual Basic (Declaration)
Public Event OnError As EventHandler(Of ErrorEventArgs)
C#
public event EventHandler<ErrorEventArgs> OnError

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TempDirectory Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TempDirectory Class

Glossary Item Box

Provides a class for managing a temporary directory and making reasonable a attempt to remove it upon disposal.

Syntax

Visual Basic (Declaration)
Public Class TempDirectory
C#
public class TempDirectory

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempDirectory a = new TempDirectory())
using(TempDirectory b = new TempDirectory())
{
    File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a");
    Directory.CreateDirectory(Path.Combine(a.TempPath, "child"));
    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b");

    a.CopyTo(b.TempPath);
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")));
    Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")));
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, @"child\b.txt")));
    Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));

    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b-new");
    a.CopyTo(b.TempPath, true);
    //has changed
    Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));
}
VB.NET Copy Code
Using a As New TempDirectory()
    Using b As New TempDirectory()
        File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a")
        Directory.CreateDirectory(Path.Combine(a.TempPath, "child"))
        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b")

        a.CopyTo(b.TempPath)
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")))
        Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")))
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "child\b.txt")))
        Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))

        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b-new")
        a.CopyTo(b.TempPath, True)
        'has changed
        Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.TempDirectory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TempDirectory Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TempDirectory Class

Glossary Item Box

The following tables list the members exposed by TempDirectory.

Public Constructors

 | Name | Description
Public Constructor | TempDirectory Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Exists | Returns true if the current temp directory exists.
Public Property | Info | Returns the FileInfo object for this temp directory.
Public Property | TempPath | Returns the temporary directory path being managed.
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Attach | Attaches a new instances of a TempFile to the provided directory path
Public Method | CopyTo | Overloaded. Copies the file content to the specified target file name
static (Shared in Visual Basic) | DeepCopy | Creates a deep-copy of the directory contents
static (Shared in Visual Basic) | Delete | Overloaded. Safely delete the provided directory name
Public Method | Detatch | Detatches this instance from the temporary directory and returns the temp directory's path
Public Method | Dispose | Overloaded. Disposes of the temporary directory
Top

Protected Methods

 | Name | Description
Protected Method | Finalize | Removes the directory if Dispose() is not called
Top

See Also

Reference

TempDirectory Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TempDirectory Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : TempDirectory Constructor

Glossary Item Box

Overload List

Overload | Description
TempDirectory Constructor() | Constructs a new temp directory with a newly created directory.
TempDirectory Constructor(String) | Manage the provided directory path

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TempDirectory Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class > TempDirectory Constructor : TempDirectory Constructor()

Glossary Item Box

Constructs a new temp directory with a newly created directory.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public TempDirectory()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempDirectory a = new TempDirectory())
using(TempDirectory b = new TempDirectory())
{
    File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a");
    Directory.CreateDirectory(Path.Combine(a.TempPath, "child"));
    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b");

    a.CopyTo(b.TempPath);
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")));
    Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")));
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, @"child\b.txt")));
    Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));

    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b-new");
    a.CopyTo(b.TempPath, true);
    //has changed
    Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));
}
VB.NET Copy Code
Using a As New TempDirectory()
    Using b As New TempDirectory()
        File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a")
        Directory.CreateDirectory(Path.Combine(a.TempPath, "child"))
        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b")

        a.CopyTo(b.TempPath)
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")))
        Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")))
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "child\b.txt")))
        Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))

        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b-new")
        a.CopyTo(b.TempPath, True)
        'has changed
        Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Overload List

Used By

TestResXtoMc.TestBuildMcFromResX()
TestResXtoMcByProject.TestGenerateWin32Resource()
TestResXtoMcByProject.TestProjectResXVersionByAssembly()
TestResXtoMcByProject.TestCreateMessageAssembly()
TestResXtoMcByProject.TestProjectResXWithBadAssemblyInfo()

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TempDirectory Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class > TempDirectory Constructor : TempDirectory Constructor(String)

directory

Glossary Item Box

Manage the provided directory path

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal directory As String _
)
C#
public TempDirectory(
   string directory
)

Parameters

directory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Overload List

Used By

TempDirectory TempDirectory.Attach(String)
TempDirectory.Delete(String)

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TempDirectory Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TempDirectory Class

Glossary Item Box

For a list of all members of this type, see TempDirectory members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Attach | Attaches a new instances of a TempFile to the provided directory path
Public Method | CopyTo | Overloaded. Copies the file content to the specified target file name
static (Shared in Visual Basic) | DeepCopy | Creates a deep-copy of the directory contents
static (Shared in Visual Basic) | Delete | Overloaded. Safely delete the provided directory name
Public Method | Detatch | Detatches this instance from the temporary directory and returns the temp directory's path
Public Method | Dispose | Overloaded. Disposes of the temporary directory
Top

Protected Methods

 | Name | Description
Protected Method | Finalize | Removes the directory if Dispose() is not called
Top

See Also

Reference

TempDirectory Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Attach Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : Attach Method

existingPath

Glossary Item Box

Attaches a new instances of a TempFile to the provided directory path

Syntax

Visual Basic (Declaration)
Public Shared Function Attach( _
   ByVal existingPath As String _
) As TempDirectory
C#
public static TempDirectory Attach(
   string existingPath
)

Parameters

existingPath

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string path;
using (TempDirectory d = new TempDirectory())
{
    Assert.IsTrue(Directory.Exists(d.TempPath));
    path = d.Detatch();
}
Assert.IsTrue(Directory.Exists(path));
using (TempDirectory d = TempDirectory.Attach(path))
{
    Assert.IsTrue(Directory.Exists(path));
}
Assert.IsFalse(Directory.Exists(path));
VB.NET Copy Code
Dim path As String
Using d As New TempDirectory()
    Assert.IsTrue(Directory.Exists(d.TempPath))
    path = d.Detatch()
End Using
Assert.IsTrue(Directory.Exists(path))
Using d As TempDirectory = TempDirectory.Attach(path)
    Assert.IsTrue(Directory.Exists(path))
End Using
Assert.IsFalse(Directory.Exists(path))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : CopyTo Method

Glossary Item Box

Copies the file content to the specified target file name

Overload List

Overload | Description
CopyTo(String) | Copies the file content to the specified target file name
CopyTo(String,Boolean) | Copies the directory content to the specified target directory name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class > CopyTo Method : CopyTo(String) Method

target

Glossary Item Box

Copies the file content to the specified target file name

Syntax

Visual Basic (Declaration)
Public Overloads Sub CopyTo( _
   ByVal target As String _
)
C#
public void CopyTo(
   string target
)

Parameters

target

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempDirectory a = new TempDirectory())
using(TempDirectory b = new TempDirectory())
{
    File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a");
    Directory.CreateDirectory(Path.Combine(a.TempPath, "child"));
    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b");

    a.CopyTo(b.TempPath);
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")));
    Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")));
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, @"child\b.txt")));
    Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));

    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b-new");
    a.CopyTo(b.TempPath, true);
    //has changed
    Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));
}
VB.NET Copy Code
Using a As New TempDirectory()
    Using b As New TempDirectory()
        File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a")
        Directory.CreateDirectory(Path.Combine(a.TempPath, "child"))
        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b")

        a.CopyTo(b.TempPath)
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")))
        Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")))
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "child\b.txt")))
        Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))

        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b-new")
        a.CopyTo(b.TempPath, True)
        'has changed
        Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Overload List

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo(String,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class > CopyTo Method : CopyTo(String,Boolean) Method

target
replace

Glossary Item Box

Copies the directory content to the specified target directory name

Syntax

Visual Basic (Declaration)
Public Overloads Sub CopyTo( _
   ByVal target As String, _
   ByVal replace As Boolean _
)
C#
public void CopyTo(
   string target,
   bool replace
)

Parameters

target
replace

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempDirectory a = new TempDirectory())
using(TempDirectory b = new TempDirectory())
{
    File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a");
    Directory.CreateDirectory(Path.Combine(a.TempPath, "child"));
    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b");

    a.CopyTo(b.TempPath);
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")));
    Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")));
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, @"child\b.txt")));
    Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));

    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b-new");
    a.CopyTo(b.TempPath, true);
    //has changed
    Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));
}
VB.NET Copy Code
Using a As New TempDirectory()
    Using b As New TempDirectory()
        File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a")
        Directory.CreateDirectory(Path.Combine(a.TempPath, "child"))
        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b")

        a.CopyTo(b.TempPath)
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")))
        Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")))
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "child\b.txt")))
        Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))

        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b-new")
        a.CopyTo(b.TempPath, True)
        'has changed
        Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Overload List

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DeepCopy Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : DeepCopy Method

srcDirectory
targetDirectory
replace

Glossary Item Box

Creates a deep-copy of the directory contents

Syntax

Visual Basic (Declaration)
Public Shared Sub DeepCopy( _
   ByVal srcDirectory As String, _
   ByVal targetDirectory As String, _
   ByVal replace As Boolean _
)
C#
public static void DeepCopy(
   string srcDirectory,
   string targetDirectory,
   bool replace
)

Parameters

srcDirectory
targetDirectory
replace

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members

Used By

TempDirectory.CopyTo(String)
TempDirectory.CopyTo(String,Boolean)
TempDirectory.DeepCopy(String,String,Boolean)

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : Delete Method

Glossary Item Box

Safely delete the provided directory name

Overload List

Overload | Description
Delete(String) | Safely delete the provided directory name
Delete() | Deletes the current temp directory immediatly if it exists.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class > Delete Method : Delete(String) Method

path

Glossary Item Box

Safely delete the provided directory name

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Delete( _
   ByVal path As String _
)
C#
public static void Delete(
   string path
)

Parameters

path

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string path = new TempDirectory().Detatch();
using (Stream io = File.Create(Path.Combine(path, "temp")))
    TempDirectory.Delete(path);

Assert.IsTrue(Directory.Exists(path));

GC.Collect(0, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();

Assert.IsFalse(Directory.Exists(path));
VB.NET Copy Code
Dim path As String = New TempDirectory().Detatch()
Using io As Stream = File.Create(Path.Combine(path, "temp"))
    TempDirectory.Delete(path)
End Using

Assert.IsTrue(Directory.Exists(path))

GC.Collect(0, GCCollectionMode.Forced)
GC.WaitForPendingFinalizers()

Assert.IsFalse(Directory.Exists(path))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Overload List

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class > Delete Method : Delete() Method

Glossary Item Box

Deletes the current temp directory immediatly if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Delete()
C#
public void Delete()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempDirectory dir;
using(dir = new TempDirectory())
{
    Assert.IsTrue(dir.Exists);
    dir.Delete();
    Assert.IsFalse(dir.Exists);
}
VB.NET Copy Code
Dim dir As TempDirectory
Using dir = New TempDirectory()
    Assert.IsTrue(dir.Exists)
    dir.Delete()
    Assert.IsFalse(dir.Exists)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Overload List

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Detatch Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : Detatch Method

Glossary Item Box

Detatches this instance from the temporary directory and returns the temp directory's path

Syntax

Visual Basic (Declaration)
Public Function Detatch() As String
C#
public string Detatch()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string path = new TempDirectory().Detatch();
using (Stream io = File.Create(Path.Combine(path, "temp")))
    TempDirectory.Delete(path);

Assert.IsTrue(Directory.Exists(path));

GC.Collect(0, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();

Assert.IsFalse(Directory.Exists(path));
VB.NET Copy Code
Dim path As String = New TempDirectory().Detatch()
Using io As Stream = File.Create(Path.Combine(path, "temp"))
    TempDirectory.Delete(path)
End Using

Assert.IsTrue(Directory.Exists(path))

GC.Collect(0, GCCollectionMode.Forced)
GC.WaitForPendingFinalizers()

Assert.IsFalse(Directory.Exists(path))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : Dispose Method

Glossary Item Box

Disposes of the temporary directory

Overload List

Overload | Description
Dispose() | Disposes of the temporary directory
Dispose(Boolean) | Disposes of the temporary directory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class > Dispose Method : Dispose() Method

Glossary Item Box

Disposes of the temporary directory

Syntax

Visual Basic (Declaration)
Public Overloads Sub Dispose()
C#
public void Dispose()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempDirectory dir = new TempDirectory();
Assert.IsTrue(dir.Exists);
dir.Dispose();
Assert.IsFalse(dir.Exists);
VB.NET Copy Code
Dim dir As New TempDirectory()
Assert.IsTrue(dir.Exists)
dir.Dispose()
Assert.IsFalse(dir.Exists)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Overload List

Used By

TempDirectory.Delete(String)

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of the temporary directory

Syntax

Visual Basic (Declaration)
Protected Overloads Overridable Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected virtual void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Overload List

Used By

TempDirectory.Dispose()


%%PageItemTitle%%

[image]
CSharpTest.Net
Finalize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : Finalize Method

Glossary Item Box

Removes the directory if Dispose() is not called

Syntax

Visual Basic (Declaration)
Protected Overrides Sub Finalize()
C#
protected override void Finalize()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members
Base Implementation in Finalize


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TempDirectory Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TempDirectory Class

Glossary Item Box

For a list of all members of this type, see TempDirectory members.

Public Properties

 | Name | Description
Public Property | Exists | Returns true if the current temp directory exists.
Public Property | Info | Returns the FileInfo object for this temp directory.
Public Property | TempPath | Returns the temporary directory path being managed.
Top

See Also

Reference

TempDirectory Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Exists Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : Exists Property

Glossary Item Box

Returns true if the current temp directory exists.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Exists As Boolean
C#
public bool Exists {get;}

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempDirectory dir;
using(dir = new TempDirectory())
{
    Assert.IsTrue(dir.Exists);
    dir.Delete();
    Assert.IsFalse(dir.Exists);
}
VB.NET Copy Code
Dim dir As TempDirectory
Using dir = New TempDirectory()
    Assert.IsTrue(dir.Exists)
    dir.Delete()
    Assert.IsFalse(dir.Exists)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members

Used By

TempDirectory.Delete()

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Info Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : Info Property

Glossary Item Box

Returns the FileInfo object for this temp directory.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Info As DirectoryInfo
C#
public DirectoryInfo Info {get;}

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempDirectory dir = new TempDirectory())
    Assert.AreEqual(dir.TempPath, dir.Info.FullName);
VB.NET Copy Code
Using dir As New TempDirectory()
    Assert.AreEqual(dir.TempPath, dir.Info.FullName)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TempPath Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : TempPath Property

Glossary Item Box

Returns the temporary directory path being managed.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property TempPath As String
C#
public string TempPath {get;}

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempDirectory a = new TempDirectory())
using(TempDirectory b = new TempDirectory())
{
    File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a");
    Directory.CreateDirectory(Path.Combine(a.TempPath, "child"));
    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b");

    a.CopyTo(b.TempPath);
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")));
    Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")));
    Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, @"child\b.txt")));
    Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));

    File.WriteAllText(Path.Combine(a.TempPath, @"child\b.txt"), "text-b-new");
    a.CopyTo(b.TempPath, true);
    //has changed
    Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, @"child\b.txt")));
}
VB.NET Copy Code
Using a As New TempDirectory()
    Using b As New TempDirectory()
        File.WriteAllText(Path.Combine(a.TempPath, "a.txt"), "text-a")
        Directory.CreateDirectory(Path.Combine(a.TempPath, "child"))
        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b")

        a.CopyTo(b.TempPath)
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "a.txt")))
        Assert.AreEqual("text-a", File.ReadAllText(Path.Combine(b.TempPath, "a.txt")))
        Assert.IsTrue(File.Exists(Path.Combine(b.TempPath, "child\b.txt")))
        Assert.AreEqual("text-b", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))

        File.WriteAllText(Path.Combine(a.TempPath, "child\b.txt"), "text-b-new")
        a.CopyTo(b.TempPath, True)
        'has changed
        Assert.AreEqual("text-b-new", File.ReadAllText(Path.Combine(b.TempPath, "child\b.txt")))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempDirectory Class
TempDirectory Members

Used By

TestResXtoMc.TestBuildMcFromResX()
TestResXtoMcByProject.TestGenerateWin32Resource()
TestResXtoMcByProject.TestProjectResXVersionByAssembly()
TestResXtoMcByProject.TestCreateMessageAssembly()
TestResXtoMcByProject.TestProjectResXWithBadAssemblyInfo()
TempDirectory.Delete()
TempDirectory.CopyTo(String)
TempDirectory.CopyTo(String,Boolean)

Source Code

Library/IO/TempDirectory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TempFile Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TempFile Class

Glossary Item Box

Provides a class for managing a temporary file and making reasonable a attempt to remove it upon disposal.

Syntax

Visual Basic (Declaration)
Public Class TempFile
C#
public class TempFile

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html>
    <head><title>required</title></head>
    <body><iframe></iframe></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10);

using (TempFile temp = new TempFile())
{
    temp.WriteAllText(doc);
    v.Validate(@"C:\transitional.xhtml", new StreamReader(temp.Read()));
}
VB.NET Copy Code
Dim doc As String = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" & vbCr & vbLf & "            <html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body><iframe></iframe></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10)

Using temp As New TempFile()
    temp.WriteAllText(doc)
    v.Validate("C:\transitional.xhtml", New StreamReader(temp.Read()))
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.TempFile
CSharpTest.Net.IO.ReplaceFile
CSharpTest.Net.IO.TransactFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Members
CSharpTest.Net.IO Namespace
TempFile ScriptEngine.Compile(String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TempFile Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TempFile Class

Glossary Item Box

The following tables list the members exposed by TempFile.

Public Constructors

 | Name | Description
Public Constructor | TempFile Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Exists | Returns true if the current temp file exists.
Public Property | Info | Returns the FileInfo object for this temp file.
Public Property | Length | Gets or sets the current length of the temp file. If setting the length on a file that does not exist one will be created. If getting the length of a file that doesnt exist zero will be returned.
Public Property | TempPath | Returns the temporary file path being managed.
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Attach | Attaches a new instances of a TempFile to the provided file path
Public Method | CopyTo | Overloaded. Copies the file content to the specified target file name
Public Method | Create | Re-Creates and Opens the temporary file for writing, multiple calls will truncate existing data.
static (Shared in Visual Basic) | CreateTempPath | Creates a temp file having the provided extension
static (Shared in Visual Basic) | Delete | Overloaded. Safely delete the provided file name
Public Method | Detatch | Detatches this instance from the temporary file and returns the temp file's path
Public Method | Dispose | Overloaded. Disposes of the temporary file
static (Shared in Visual Basic) | FromCopy | Creates a temp file having a copy of the specified file
static (Shared in Visual Basic) | FromExtension | Creates a temp file having the provided extension
Public Method | Open | Open or Create the temporary file for reading and writing
Public Method | Read | Overloaded. Opens the temporary file for reading
Public Method | ReadAllBytes | Reads all bytes from the file
Public Method | ReadAllText | Reads all UTF8 text from the file
Public Method | WriteAllBytes | Writes all bytes to the file
Public Method | WriteAllText | Writes all UTF8 text to the file
Top

Protected Methods

 | Name | Description
Protected Method | Finalize | Removes the file if Dispose() is not called
Top

See Also

Reference

TempFile Class
CSharpTest.Net.IO Namespace
TempFile ScriptEngine.Compile(String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TempFile Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : TempFile Constructor

Glossary Item Box

Overload List

Overload | Description
TempFile Constructor() | Constructs a new temp file with a newly created/empty file.
TempFile Constructor(String) | Manage the provided file path

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TempFile Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > TempFile Constructor : TempFile Constructor()

Glossary Item Box

Constructs a new temp file with a newly created/empty file.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public TempFile()

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html>
    <head><title>required</title></head>
    <body><iframe></iframe></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10);

using (TempFile temp = new TempFile())
{
    temp.WriteAllText(doc);
    v.Validate(@"C:\transitional.xhtml", new StreamReader(temp.Read()));
}
VB.NET Copy Code
Dim doc As String = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" & vbCr & vbLf & "            <html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body><iframe></iframe></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10)

Using temp As New TempFile()
    temp.WriteAllText(doc)
    v.Validate("C:\transitional.xhtml", New StreamReader(temp.Read()))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Used By

BasicTests.TestBulkInsert()
SampleCustomTypeTest.Setup()
TestBackupAndRecovery.TestRecoveryOnNewWithAsyncLog()
TestBackupAndRecovery.TestRestoreLargeLog()
TestBackupAndRecovery.TestRecoveryOnExistingWithAsyncLog()
TestBackupAndRecovery.TestRecoveryOnNew()
TestBackupAndRecovery.TestRecoveryOnExisting()
TestBackupAndRecovery.TestRecoveryOnNewLargeOrder()
TestBackupAndRecovery.TestRecoveryOnExistingLargeOrder()
TestBPlusTreeOptions.TestReadOnly()
BasicFileTests.Setup()
BPlusTree TestFileSerialized.BTreeFactory.Create()
BPlusTree DictionaryTestsVersion2.BTreeFactory.Create()
TestBulkInsert.TestMergeSequenceInFile()
TestBulkInsert.TestMergeRandomInFile()
TestMultiInstance.TestReadOnlyCopy()
TestMultiInstance.TestSyncFromLogging()
TestTransactionLog.TestTransactionLogOptions()
TestTransactionLog.TestAddOperation()
TestTransactionLog.TestUpdateOperation()
TestTransactionLog.TestRemoveOperation()
TestTransactionLog.TestMultipleWriteAndReplay()
TestTransactionLog.TestMultipleTransAndReplay()
TestTransactionLog.TestLargeWriteAndReplay()
TestTransactionLog.TestProgressiveReplay()
TestTransactionLog.TestSingleRollbackAndReplay()
TestTransactionLog.TestPositionAndReplay()
TestTransactionLog.TestCommitEmptyAndReplay()
TestTransactionLog.TestReplayEmpty()
TestTransactionLog.TestTruncateLog()
TestTransactionLog.TestLogWithJunkAppended()
TestTransactionLog.TestLogCorruption()
ThreadedBTreeTest.Setup()
ThreadedBTreeTest.TestAbortWritersAndRecover()
ThreadedMassInsertTest.TestConcurrency()
XhtmlValidation.Validate(TextReader)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TempFile Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > TempFile Constructor : TempFile Constructor(String)

filename

Glossary Item Box

Manage the provided file path

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String _
)
C#
public TempFile(
   string filename
)

Parameters

filename

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string path = Path.GetTempFileName();
Assert.IsTrue(File.Exists(path));
File.WriteAllText(path, "Test");

TempFile filea = TempFile.Attach(path);
Assert.AreEqual(path, filea.TempPath);
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath));

filea.Dispose();
Assert.IsFalse(File.Exists(path));

using (TempFile filec = new TempFile(path))
    Assert.IsFalse(File.Exists(path));
VB.NET Copy Code
Dim path As String = Path.GetTempFileName()
Assert.IsTrue(File.Exists(path))
File.WriteAllText(path, "Test")

Dim filea As TempFile = TempFile.Attach(path)
Assert.AreEqual(path, filea.TempPath)
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath))

filea.Dispose()
Assert.IsFalse(File.Exists(path))

Using filec As New TempFile(path)
    Assert.IsFalse(File.Exists(path))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Used By

TempFile TempFile.Attach(String)
TempFile TempFile.FromExtension(String)
TempFile.Delete(String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TempFile Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TempFile Class

Glossary Item Box

For a list of all members of this type, see TempFile members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Attach | Attaches a new instances of a TempFile to the provided file path
Public Method | CopyTo | Overloaded. Copies the file content to the specified target file name
Public Method | Create | Re-Creates and Opens the temporary file for writing, multiple calls will truncate existing data.
static (Shared in Visual Basic) | CreateTempPath | Creates a temp file having the provided extension
static (Shared in Visual Basic) | Delete | Overloaded. Safely delete the provided file name
Public Method | Detatch | Detatches this instance from the temporary file and returns the temp file's path
Public Method | Dispose | Overloaded. Disposes of the temporary file
static (Shared in Visual Basic) | FromCopy | Creates a temp file having a copy of the specified file
static (Shared in Visual Basic) | FromExtension | Creates a temp file having the provided extension
Public Method | Open | Open or Create the temporary file for reading and writing
Public Method | Read | Overloaded. Opens the temporary file for reading
Public Method | ReadAllBytes | Reads all bytes from the file
Public Method | ReadAllText | Reads all UTF8 text from the file
Public Method | WriteAllBytes | Writes all bytes to the file
Public Method | WriteAllText | Writes all UTF8 text to the file
Top

Protected Methods

 | Name | Description
Protected Method | Finalize | Removes the file if Dispose() is not called
Top

See Also

Reference

TempFile Class
CSharpTest.Net.IO Namespace
TempFile ScriptEngine.Compile(String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Attach Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Attach Method

existingPath

Glossary Item Box

Attaches a new instances of a TempFile to the provided file path

Syntax

Visual Basic (Declaration)
Public Shared Function Attach( _
   ByVal existingPath As String _
) As TempFile
C#
public static TempFile Attach(
   string existingPath
)

Parameters

existingPath

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string path = Path.GetTempFileName();
Assert.IsTrue(File.Exists(path));
File.WriteAllText(path, "Test");

TempFile filea = TempFile.Attach(path);
Assert.AreEqual(path, filea.TempPath);
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath));

filea.Dispose();
Assert.IsFalse(File.Exists(path));

using (TempFile filec = new TempFile(path))
    Assert.IsFalse(File.Exists(path));
VB.NET Copy Code
Dim path As String = Path.GetTempFileName()
Assert.IsTrue(File.Exists(path))
File.WriteAllText(path, "Test")

Dim filea As TempFile = TempFile.Attach(path)
Assert.AreEqual(path, filea.TempPath)
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath))

filea.Dispose()
Assert.IsFalse(File.Exists(path))

Using filec As New TempFile(path)
    Assert.IsFalse(File.Exists(path))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TestTransactionLog.TestBenchmarkWriteSpeed()
ThreadedBTreeTest.TestAbortWritersAndRecover()
TestResXtoMcByProject.TestGenerateWin32Resource()
TestResXtoMcByProject.TestProjectResXVersionByAssembly()
TestResXtoMcByProject.TestCreateMessageAssembly()
TestResXtoMcByProject.TestProjectResXWithBadAssemblyInfo()
Boolean SecureTransfer.Client.Download(String,String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : CopyTo Method

Glossary Item Box

Copies the file content to the specified target file name

Overload List

Overload | Description
CopyTo(String) | Copies the file content to the specified target file name
CopyTo(String,Boolean) | Copies the file content to the specified target file name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > CopyTo Method : CopyTo(String) Method

target

Glossary Item Box

Copies the file content to the specified target file name

Syntax

Visual Basic (Declaration)
Public Overloads Sub CopyTo( _
   ByVal target As String _
)
C#
public void CopyTo(
   string target
)

Parameters

target

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile filea = new TempFile();

File.WriteAllText(filea.TempPath, "Test");
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath));

TempFile fileb = new TempFile();
Assert.AreNotEqual(filea.TempPath, fileb.TempPath);

filea.CopyTo(fileb.TempPath, true);
Assert.AreEqual("Test", File.ReadAllText(fileb.TempPath));

File.Delete(filea.TempPath);
Assert.IsFalse(File.Exists(filea.TempPath));

fileb.CopyTo(filea.TempPath);
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath));

filea.Dispose();
fileb.Dispose();
VB.NET Copy Code
Dim filea As New TempFile()

File.WriteAllText(filea.TempPath, "Test")
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath))

Dim fileb As New TempFile()
Assert.AreNotEqual(filea.TempPath, fileb.TempPath)

filea.CopyTo(fileb.TempPath, True)
Assert.AreEqual("Test", File.ReadAllText(fileb.TempPath))

File.Delete(filea.TempPath)
Assert.IsFalse(File.Exists(filea.TempPath))

fileb.CopyTo(filea.TempPath)
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath))

filea.Dispose()
fileb.Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyTo(String,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > CopyTo Method : CopyTo(String,Boolean) Method

target
replace

Glossary Item Box

Copies the file content to the specified target file name

Syntax

Visual Basic (Declaration)
Public Overloads Sub CopyTo( _
   ByVal target As String, _
   ByVal replace As Boolean _
)
C#
public void CopyTo(
   string target,
   bool replace
)

Parameters

target
replace

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile filea = new TempFile();

File.WriteAllText(filea.TempPath, "Test");
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath));

TempFile fileb = new TempFile();
Assert.AreNotEqual(filea.TempPath, fileb.TempPath);

filea.CopyTo(fileb.TempPath, true);
Assert.AreEqual("Test", File.ReadAllText(fileb.TempPath));

File.Delete(filea.TempPath);
Assert.IsFalse(File.Exists(filea.TempPath));

fileb.CopyTo(filea.TempPath);
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath));

filea.Dispose();
fileb.Dispose();
VB.NET Copy Code
Dim filea As New TempFile()

File.WriteAllText(filea.TempPath, "Test")
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath))

Dim fileb As New TempFile()
Assert.AreNotEqual(filea.TempPath, fileb.TempPath)

filea.CopyTo(fileb.TempPath, True)
Assert.AreEqual("Test", File.ReadAllText(fileb.TempPath))

File.Delete(filea.TempPath)
Assert.IsFalse(File.Exists(filea.TempPath))

fileb.CopyTo(filea.TempPath)
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath))

filea.Dispose()
fileb.Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Used By

TempFile.CopyTo(String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Create Method

Glossary Item Box

Re-Creates and Opens the temporary file for writing, multiple calls will truncate existing data.

Syntax

Visual Basic (Declaration)
Public Function Create() As Stream
C#
public Stream Create()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile file = new TempFile();

Stream c = file.Create();
Assert.IsTrue(c.CanWrite);
Assert.IsFalse(c.CanRead);

Stream r = file.Read();
Assert.IsFalse(r.CanWrite);
Assert.IsTrue(r.CanRead);

c.Dispose();
r.Dispose();
file.Dispose();
VB.NET Copy Code
Dim file As New TempFile()

Dim c As Stream = file.Create()
Assert.IsTrue(c.CanWrite)
Assert.IsFalse(c.CanRead)

Dim r As Stream = file.Read()
Assert.IsFalse(r.CanWrite)
Assert.IsTrue(r.CanRead)

c.Dispose()
r.Dispose()
file.Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Source Code

Library/IO/TempFile.cs

Used By

IOStream.Compress(String,String)
IOStream.Decompress(String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateTempPath Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : CreateTempPath Method

extensionWithDot

Glossary Item Box

Creates a temp file having the provided extension

Syntax

Visual Basic (Declaration)
Public Shared Function CreateTempPath( _
   ByVal extensionWithDot As String _
) As String
C#
public static string CreateTempPath(
   string extensionWithDot
)

Parameters

extensionWithDot

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TempFile TempFile.FromExtension(String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Delete Method

Glossary Item Box

Safely delete the provided file name

Overload List

Overload | Description
Delete(String) | Safely delete the provided file name
Delete() | Deletes the current temp file immediatly if it exists.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > Delete Method : Delete(String) Method

path

Glossary Item Box

Safely delete the provided file name

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Delete( _
   ByVal path As String _
)
C#
public static void Delete(
   string path
)

Parameters

path

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile file = new TempFile();

Assert.IsTrue(File.Exists(file.TempPath));
TempFile.Delete(file.TempPath);

Assert.IsFalse(File.Exists(file.TempPath));
file.Dispose();

//ignres bad paths:
TempFile.Delete("@~+_(!&($_~!(&*+_~&^%^|||&&&\\\\ THIS IS AN INVALID FILE NAME.*");
VB.NET Copy Code
Dim file As New TempFile()

Assert.IsTrue(File.Exists(file.TempPath))
TempFile.Delete(file.TempPath)

Assert.IsFalse(File.Exists(file.TempPath))
file.Dispose()

'ignres bad paths:
TempFile.Delete("@~+_(!&($_~!(&*+_~&^%^|||&&&\\ THIS IS AN INVALID FILE NAME.*")

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > Delete Method : Delete() Method

Glossary Item Box

Deletes the current temp file immediatly if it exists.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Delete()
C#
public void Delete()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string test = "Hello World!\u1255";
TempFile file = new TempFile();
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test));

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes());
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllBytes(Encoding.UTF8.GetBytes(test));
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllText(test);
Assert.AreEqual(test, file.ReadAllText());
VB.NET Copy Code
Dim test As String = "Hello World!ቕ"
Dim file As New TempFile()
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test))

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes())
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllBytes(Encoding.UTF8.GetBytes(test))
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllText(test)
Assert.AreEqual(test, file.ReadAllText())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Used By

BasicFileTests.TestDeleteUnderlyingFile()
BasicFileTests.TestDeleteAfterGarbageCollection()
TestBulkInsert.TestMergeSequenceInFile()
TestBulkInsert.TestMergeRandomInFile()
TestTransactionLog.TestTransactionLogOptions()
ThreadedBTreeTest.TestAbortWritersAndRecover()

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Detatch Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Detatch Method

Glossary Item Box

Detatches this instance from the temporary file and returns the temp file's path

Syntax

Visual Basic (Declaration)
Public Function Detatch() As String
C#
public string Detatch()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile filea = new TempFile();
string path = filea.TempPath;
Assert.IsTrue(File.Exists(path));

Assert.AreEqual(path, filea.Detatch());
Assert.IsTrue(File.Exists(path));
filea.Dispose();
Assert.IsTrue(File.Exists(path));

File.Delete(path);
VB.NET Copy Code
Dim filea As New TempFile()
Dim path As String = filea.TempPath
Assert.IsTrue(File.Exists(path))

Assert.AreEqual(path, filea.Detatch())
Assert.IsTrue(File.Exists(path))
filea.Dispose()
Assert.IsTrue(File.Exists(path))

File.Delete(path)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

Boolean SecureTransfer.Client.Download(String,String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Dispose Method

Glossary Item Box

Disposes of the temporary file

Overload List

Overload | Description
Dispose() | Disposes of the temporary file
Dispose(Boolean) | Disposes of the temporary file

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > Dispose Method : Dispose() Method

Glossary Item Box

Disposes of the temporary file

Syntax

Visual Basic (Declaration)
Public Overloads Sub Dispose()
C#
public void Dispose()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile f = new TempFile();
f.Length = 5;
Assert.AreEqual(f.Length, f.Info.Length);
f.Dispose();

Assert.AreEqual(0, f.Length);
VB.NET Copy Code
Dim f As New TempFile()
f.Length = 5
Assert.AreEqual(f.Length, f.Info.Length)
f.Dispose()

Assert.AreEqual(0, f.Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Used By

BasicTests.TestBulkInsert()
SampleCustomTypeTest.Teardown()
BasicFileTests.TearDown()
BPlusTree DictionaryTestsVersion2.BTreeFactory.Create()
ThreadedBTreeTest.Teardown()
TempFile TempFile.FromCopy(String)
TempFile.Delete(String)
ScriptRunner.Dispose()

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of the temporary file

Syntax

Visual Basic (Declaration)
Protected Overloads Overridable Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected virtual void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Used By

TempFile.Dispose()
TransactFile.Commit()
TransactFile.Rollback()
ReplaceFile.Commit()
ReplaceFile.Rollback()


%%PageItemTitle%%

[image]
CSharpTest.Net
Finalize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Finalize Method

Glossary Item Box

Removes the file if Dispose() is not called

Syntax

Visual Basic (Declaration)
Protected Overrides Sub Finalize()
C#
protected override void Finalize()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Base Implementation in Finalize


%%PageItemTitle%%

[image]
CSharpTest.Net
FromCopy Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : FromCopy Method

srcFileName

Glossary Item Box

Creates a temp file having a copy of the specified file

Syntax

Visual Basic (Declaration)
Public Shared Function FromCopy( _
   ByVal srcFileName As String _
) As TempFile
C#
public static TempFile FromCopy(
   string srcFileName
)

Parameters

srcFileName

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempFile a = TempFile.FromExtension(".test"))
{
    a.WriteAllText("a");
    Assert.AreEqual("a", a.ReadAllText());
    Assert.AreEqual(".test", Path.GetExtension(a.TempPath));

    using (TempFile b = TempFile.FromCopy(a.TempPath))
    {
        Assert.AreEqual("a", b.ReadAllText());
        Assert.AreEqual(".test", Path.GetExtension(b.TempPath));
    }
}
VB.NET Copy Code
Using a As TempFile = TempFile.FromExtension(".test")
    a.WriteAllText("a")
    Assert.AreEqual("a", a.ReadAllText())
    Assert.AreEqual(".test", Path.GetExtension(a.TempPath))

    Using b As TempFile = TempFile.FromCopy(a.TempPath)
        Assert.AreEqual("a", b.ReadAllText())
        Assert.AreEqual(".test", Path.GetExtension(b.TempPath))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromExtension Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : FromExtension Method

extensionWithDot

Glossary Item Box

Creates a temp file having the provided extension

Syntax

Visual Basic (Declaration)
Public Shared Function FromExtension( _
   ByVal extensionWithDot As String _
) As TempFile
C#
public static TempFile FromExtension(
   string extensionWithDot
)

Parameters

extensionWithDot

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempFile a = TempFile.FromExtension(".test"))
{
    a.WriteAllText("a");
    Assert.AreEqual("a", a.ReadAllText());
    Assert.AreEqual(".test", Path.GetExtension(a.TempPath));

    using (TempFile b = TempFile.FromCopy(a.TempPath))
    {
        Assert.AreEqual("a", b.ReadAllText());
        Assert.AreEqual(".test", Path.GetExtension(b.TempPath));
    }
}
VB.NET Copy Code
Using a As TempFile = TempFile.FromExtension(".test")
    a.WriteAllText("a")
    Assert.AreEqual("a", a.ReadAllText())
    Assert.AreEqual(".test", Path.GetExtension(a.TempPath))

    Using b As TempFile = TempFile.FromCopy(a.TempPath)
        Assert.AreEqual("a", b.ReadAllText())
        Assert.AreEqual(".test", Path.GetExtension(b.TempPath))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TestResXtoMc.TestEmptyResXToMc()
TestResXtoMc.TestSimpleStringResXToMc()
TestResXtoMc.TestResXToMcWithCategoryFacilityAndSource()
TestResXtoMc.TestFormatResXToMc()
TestResXtoMc.TestFormatWithSuffixResXToMc()
TestResXtoMc.TestBuildMcFromResX()
TestResXtoMc.TestDuplicateHResult()
TestResXtoMc.TestDuplicateNameInFiles()
TestResXtoMc.TestDuplicateCategorySameIdAndName()
TestResXtoMc.TestDuplicateCategorySameIdDifferentName()
TempFile TempFile.FromCopy(String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Open Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Open Method

Glossary Item Box

Open or Create the temporary file for reading and writing

Syntax

Visual Basic (Declaration)
Public Function Open() As Stream
C#
public Stream Open()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile file = new TempFile();

Stream r = file.Read();
Assert.IsFalse(r.CanWrite);
Assert.IsTrue(r.CanRead);

Stream o = file.Open();
Assert.IsTrue(o.CanWrite);
Assert.IsTrue(o.CanRead);

o.Dispose();
r.Dispose();
file.Dispose();
VB.NET Copy Code
Dim file As New TempFile()

Dim r As Stream = file.Read()
Assert.IsFalse(r.CanWrite)
Assert.IsTrue(r.CanRead)

Dim o As Stream = file.Open()
Assert.IsTrue(o.CanWrite)
Assert.IsTrue(o.CanRead)

o.Dispose()
r.Dispose()
file.Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

BasicFileTests.TestRecoverCorruptedFile()
TestResXtoMcByProject.TestGenerateWin32Resource()
TestResXtoMcByProject.TestProjectResXVersionByAssembly()
TestResXtoMcByProject.TestProjectResXWithBadAssemblyInfo()

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Read Method

Glossary Item Box

Opens the temporary file for reading

Overload List

Overload | Description
Read() | Opens the temporary file for reading
Read(FileShare) | Opens the temporary file for reading

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > Read Method : Read() Method

Glossary Item Box

Opens the temporary file for reading

Syntax

Visual Basic (Declaration)
Public Overloads Function Read() As Stream
C#
public Stream Read()

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html>
    <head><title>required</title></head>
    <body><iframe></iframe></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10);

using (TempFile temp = new TempFile())
{
    temp.WriteAllText(doc);
    v.Validate(@"C:\transitional.xhtml", new StreamReader(temp.Read()));
}
VB.NET Copy Code
Dim doc As String = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" & vbCr & vbLf & "            <html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body><iframe></iframe></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10)

Using temp As New TempFile()
    temp.WriteAllText(doc)
    v.Validate("C:\transitional.xhtml", New StreamReader(temp.Read()))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(FileShare) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > Read Method : Read(FileShare) Method

shared

Glossary Item Box

Opens the temporary file for reading

Syntax

Visual Basic (Declaration)
Public Overloads Function Read( _
   ByVal shared As FileShare _
) As Stream
C#
public Stream Read(
   FileShare shared
)

Parameters

shared

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members
Overload List

Used By

Stream TempFile.Read()

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadAllBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : ReadAllBytes Method

Glossary Item Box

Reads all bytes from the file

Syntax

Visual Basic (Declaration)
Public Function ReadAllBytes() As Byte()
C#
public byte[] ReadAllBytes()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string test = "Hello World!\u1255";
TempFile file = new TempFile();
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test));

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes());
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllBytes(Encoding.UTF8.GetBytes(test));
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllText(test);
Assert.AreEqual(test, file.ReadAllText());
VB.NET Copy Code
Dim test As String = "Hello World!ቕ"
Dim file As New TempFile()
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test))

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes())
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllBytes(Encoding.UTF8.GetBytes(test))
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllText(test)
Assert.AreEqual(test, file.ReadAllText())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TestTransactionLog.TestLogCorruption()

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadAllText Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : ReadAllText Method

Glossary Item Box

Reads all UTF8 text from the file

Syntax

Visual Basic (Declaration)
Public Function ReadAllText() As String
C#
public string ReadAllText()

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
using(TempFile a = TempFile.FromExtension(".test"))
{
    a.WriteAllText("a");
    Assert.AreEqual("a", a.ReadAllText());
    Assert.AreEqual(".test", Path.GetExtension(a.TempPath));

    using (TempFile b = TempFile.FromCopy(a.TempPath))
    {
        Assert.AreEqual("a", b.ReadAllText());
        Assert.AreEqual(".test", Path.GetExtension(b.TempPath));
    }
}
VB.NET Copy Code
Using a As TempFile = TempFile.FromExtension(".test")
    a.WriteAllText("a")
    Assert.AreEqual("a", a.ReadAllText())
    Assert.AreEqual(".test", Path.GetExtension(a.TempPath))

    Using b As TempFile = TempFile.FromCopy(a.TempPath)
        Assert.AreEqual("a", b.ReadAllText())
        Assert.AreEqual(".test", Path.GetExtension(b.TempPath))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TestResXtoMc.TestEmptyResXToMc()
TestResXtoMc.TestSimpleStringResXToMc()
TestResXtoMc.TestResXToMcWithCategoryFacilityAndSource()
TestResXtoMc.TestFormatResXToMc()
TestResXtoMc.TestFormatWithSuffixResXToMc()
Int32 ScriptRunner.Run(TextReader,String[])
ScriptRunner.Start(String[])

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteAllBytes Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : WriteAllBytes Method

data

Glossary Item Box

Writes all bytes to the file

Syntax

Visual Basic (Declaration)
Public Sub WriteAllBytes( _
   ByVal data() As Byte _
)
C#
public void WriteAllBytes(
   byte[] data
)

Parameters

data

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string test = "Hello World!\u1255";
TempFile file = new TempFile();
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test));

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes());
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllBytes(Encoding.UTF8.GetBytes(test));
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllText(test);
Assert.AreEqual(test, file.ReadAllText());
VB.NET Copy Code
Dim test As String = "Hello World!ቕ"
Dim file As New TempFile()
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test))

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes())
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllBytes(Encoding.UTF8.GetBytes(test))
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllText(test)
Assert.AreEqual(test, file.ReadAllText())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TestTransactionLog.TestLogCorruption()

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteAllText Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : WriteAllText Method

content

Glossary Item Box

Writes all UTF8 text to the file

Syntax

Visual Basic (Declaration)
Public Sub WriteAllText( _
   ByVal content As String _
)
C#
public void WriteAllText(
   string content
)

Parameters

content

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">
<html>
    <head><title>required</title></head>
    <body><iframe></iframe></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10);

using (TempFile temp = new TempFile())
{
    temp.WriteAllText(doc);
    v.Validate(@"C:\transitional.xhtml", new StreamReader(temp.Read()));
}
VB.NET Copy Code
Dim doc As String = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" & vbCr & vbLf & "            <html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body><iframe></iframe></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.XhtmlTransitional_10)

Using temp As New TempFile()
    temp.WriteAllText(doc)
    v.Validate("C:\transitional.xhtml", New StreamReader(temp.Read()))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TestResXtoMcByProject.TestGenerateWin32Resource()
TestResXtoMcByProject.TestProjectResXVersionByAssembly()
TestResXtoMcByProject.TestCreateMessageAssembly()
TestResXtoMcByProject.TestProjectResXWithBadAssemblyInfo()
XhtmlValidation.Validate(TextReader)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TempFile Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TempFile Class

Glossary Item Box

For a list of all members of this type, see TempFile members.

Public Properties

 | Name | Description
Public Property | Exists | Returns true if the current temp file exists.
Public Property | Info | Returns the FileInfo object for this temp file.
Public Property | Length | Gets or sets the current length of the temp file. If setting the length on a file that does not exist one will be created. If getting the length of a file that doesnt exist zero will be returned.
Public Property | TempPath | Returns the temporary file path being managed.
Top

See Also

Reference

TempFile Class
CSharpTest.Net.IO Namespace
TempFile ScriptEngine.Compile(String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Exists Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Exists Property

Glossary Item Box

Returns true if the current temp file exists.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Exists As Boolean
C#
public bool Exists {get;}

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
string test = "Hello World!\u1255";
TempFile file = new TempFile();
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test));

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes());
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllBytes(Encoding.UTF8.GetBytes(test));
Assert.AreEqual(test, file.ReadAllText());

file.Delete();
Assert.IsFalse(File.Exists(file.TempPath));
Assert.IsFalse(file.Exists);
file.WriteAllText(test);
Assert.AreEqual(test, file.ReadAllText());
VB.NET Copy Code
Dim test As String = "Hello World!ቕ"
Dim file As New TempFile()
File.WriteAllBytes(file.TempPath, Encoding.UTF8.GetBytes(test))

Assert.AreEqual(Encoding.UTF8.GetBytes(test), file.ReadAllBytes())
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllBytes(Encoding.UTF8.GetBytes(test))
Assert.AreEqual(test, file.ReadAllText())

file.Delete()
Assert.IsFalse(File.Exists(file.TempPath))
Assert.IsFalse(file.Exists)
file.WriteAllText(test)
Assert.AreEqual(test, file.ReadAllText())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TestResXtoMcByProject.TestCreateMessageAssembly()
TempFile.Delete()

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Info Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Info Property

Glossary Item Box

Returns the FileInfo object for this temp file.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Info As FileInfo
C#
public FileInfo Info {get;}

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile f = new TempFile();
f.Length = 5;
Assert.AreEqual(f.Length, f.Info.Length);
f.Dispose();

Assert.AreEqual(0, f.Length);
VB.NET Copy Code
Dim f As New TempFile()
f.Length = 5
Assert.AreEqual(f.Length, f.Info.Length)
f.Dispose()

Assert.AreEqual(0, f.Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : Length Property

Glossary Item Box

Gets or sets the current length of the temp file. If setting the length on a file that does not exist one will be created. If getting the length of a file that doesnt exist zero will be returned.

Syntax

Visual Basic (Declaration)
Public Property Length As Long
C#
public long Length {get; set;}

Example

Library/Library.Test/TestTempFiles.cs

C# Copy Code
TempFile f = new TempFile();
f.Length = 5;
Assert.AreEqual(f.Length, f.Info.Length);
f.Dispose();

Assert.AreEqual(0, f.Length);
VB.NET Copy Code
Dim f As New TempFile()
f.Length = 5
Assert.AreEqual(f.Length, f.Info.Length)
f.Dispose()

Assert.AreEqual(0, f.Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

TestTransactionLog.TestBenchmarkWriteSpeed()
Boolean SecureTransfer.Client.Download(String,String)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TempPath Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class : TempPath Property

Glossary Item Box

Returns the temporary file path being managed.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property TempPath As String
C#
public string TempPath {get;}

Example

Library/Library.Test/TestXhtmlValid.cs

C# Copy Code
string doc = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">
<html>
    <head><title>required</title></head>
    <body></body>
</html>
";

XhtmlValidation v = new XhtmlValidation(XhtmlDTDSpecification.XhtmlStrict_10);

using (TempFile temp = new TempFile())
{
    temp.WriteAllText(doc);
    v.Validate(temp.TempPath);
}
VB.NET Copy Code
Dim doc As String = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">" & vbCr & vbLf & "            <html>" & vbCr & vbLf & "                <head><title>required</title></head>" & vbCr & vbLf & "                <body></body>" & vbCr & vbLf & "            </html>" & vbCr & vbLf & "            "

Dim v As New XhtmlValidation(XhtmlDTDSpecification.XhtmlStrict_10)

Using temp As New TempFile()
    temp.WriteAllText(doc)
    v.Validate(temp.TempPath)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TempFile Class
TempFile Members

Used By

SampleCustomTypeTest.TestCommonConfiguration()
TestBackupAndRecovery.TestRestoreLargeLog()
TestBPlusTreeOptions.TestReadOnly()
BPlusTree TestFileSerialized.BTreeFactory.Create()
BPlusTree DictionaryTestsVersion2.BTreeFactory.Create()
TestBulkInsert.TestMergeRandomInFile()
TestMultiInstance.TestReadOnlyCopy()
TestMultiInstance.TestSyncFromLogging()
TestTransactionLog.TestTransactionLogOptions()
TestTransactionLog.TestBenchmarkWriteSpeed()
TestTransactionLog.TestLogWithJunkAppended()
TestTransactionLog.TestLogCorruption()
ThreadedBTreeTest.TestAbortWritersAndRecover()
ThreadedBTreeTest.TestErrorsOnInsertAndDelete()
ThreadedBTreeTest.TestConcurrentCreateReadUpdateDelete8000()
ThreadedMassInsertTest.TestConcurrency()
TestResXtoMc.TestEmptyResXToMc()
TestResXtoMc.TestSimpleStringResXToMc()
TestResXtoMc.TestResXToMcWithCategoryFacilityAndSource()
TestResXtoMc.TestFormatResXToMc()
TestResXtoMc.TestFormatWithSuffixResXToMc()
TestResXtoMc.TestBuildMcFromResX()
TestResXtoMc.TestDuplicateHResult()
TestResXtoMc.TestDuplicateNameInFiles()
TestResXtoMc.TestDuplicateCategorySameIdAndName()
TestResXtoMc.TestDuplicateCategorySameIdDifferentName()
TestResXtoMcByProject.TestGenerateWin32Resource()
TestResXtoMcByProject.TestProjectResXVersionByAssembly()
TestResXtoMcByProject.TestCreateMessageAssembly()
TestResXtoMcByProject.TestProjectResXWithBadAssemblyInfo()
XhtmlValidation.Validate(TextReader)
TempFile TempFile.FromCopy(String)
Byte[] TempFile.ReadAllBytes()
TempFile.WriteAllBytes(Byte[])
String TempFile.ReadAllText()
TempFile.WriteAllText(String)
TempFile.Delete()
Stream TempFile.Create()
Stream TempFile.Open()
Stream TempFile.Read(FileShare)
TempFile.CopyTo(String,Boolean)

Source Code

Library/IO/TempFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactedCompoundFile Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile Class

Glossary Item Box

Similar behavior to the FragmentedFile; however, a much improved implementation. Allows for file-level commit/rollback or write-by-write commits to disk. By default provides data-protection against process-crashes but not OS crashes. Use FileOptions.WriteThrough to protect against OS crashes and power outtages.

Syntax

Visual Basic (Declaration)
Public Class TransactedCompoundFile
   Implements CSharpTest.Net.Interfaces.ITransactable
C#
public class TransactedCompoundFile : CSharpTest.Net.Interfaces.ITransactable

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.TransactedCompoundFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TransactedCompoundFile Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile Class

Glossary Item Box

The following tables list the members exposed by TransactedCompoundFile.

Public Constructors

 | Name | Description
Public Constructor | TransactedCompoundFile Constructor | Overloaded.
Top

Public Properties

 | Name | Description
static (Shared in Visual Basic) | FirstIdentity | Returns the first block that *would* be allocated by a call to Create() on an empty file.
Top

Public Methods

 | Name | Description
Public Method | Clear | Immediatly truncates the file to zero-length and re-initializes an empty file
Public Method | Commit | Overloaded. For file-level transactions, performs a two-stage commit of all changed handles.
Public Method | Create | Allocates a handle for data, you MUST call Write to commit the handle, otherwise the handle may be reallocated after closing and re-opening this file. If you do not intend to commit the handle by writing to it, you should still call Delete() so that it may be reused.
Public Method | Delete | Deletes the handle and frees the associated block space for reuse.
Public Method | Dispose | Closes all streams and clears all in-memory data.
Public Method | Read | Reads all bytes from the from the handle specified
Public Method | Rollback | For file-level transactions, Reloads the file from it's original (or last committed) state.
Public Method | Write | Writes the bytes provided to the handle that was previously obtained by a call to Create(). The length must not be more than ((16*BlockSize)-32) bytes in length. The exact header size (32 bytes) may change without notice in a future release.
Top

See Also

Reference

TransactedCompoundFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactedCompoundFile Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : TransactedCompoundFile Constructor

Glossary Item Box

Overload List

Overload | Description
TransactedCompoundFile Constructor(String) | Creates or opens a TransactedCompoundFile using the filename specified.
TransactedCompoundFile Constructor(Options) | Creates or opens a TransactedCompoundFile using the filename specified.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactedCompoundFile Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class > TransactedCompoundFile Constructor : TransactedCompoundFile Constructor(String)

filename

Glossary Item Box

Creates or opens a TransactedCompoundFile using the filename specified.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filename As String _
)
C#
public TransactedCompoundFile(
   string filename
)

Parameters

filename

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
using (TempFile temp2 = new TempFile())
{
    byte[] sample = new byte[1024];
    new Random().NextBytes(sample);
    List<uint> handles = new List<uint>();
    using (TransactedCompoundFile file = new TransactedCompoundFile(
            new TransactedCompoundFile.Options(temp.TempPath) { FileOptions = FileOptions.WriteThrough }
        ))
    {
        for (int i = 0; i < 1000; i++)
        {
            var hid = file.Create();
            handles.Add(hid);
            file.Write(hid, sample, i, sample.Length - i);
        }
        file.Commit();
        File.Copy(temp.TempPath, temp2.TempPath, true);
    }
    using (TransactedCompoundFile file = new TransactedCompoundFile(temp2.TempPath))
    {
        for (int i = 0; i < 1000; i++)
        {
            CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(handles[i])));
        }
    }
}
VB.NET Copy Code
Using temp As New TempFile()
    Using temp2 As New TempFile()
        Dim sample As Byte() = New Byte(1024) {}
        New Random().NextBytes(sample)
        Dim [handles] As New List(Of UInteger)()
        Using file As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
            Key .FileOptions = FileOptions.WriteThrough _
        })
            Dim i As Integer = 0
            While i < 1000
                Dim hid As var = file.Create()
                [handles].Add(hid)
                file.Write(hid, sample, i, sample.Length - i)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
            file.Commit()
            File.Copy(temp.TempPath, temp2.TempPath, True)
        End Using
        Using file As New TransactedCompoundFile(temp2.TempPath)
            Dim i As Integer = 0
            While i < 1000
                CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read([handles](i))))
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members
Overload List

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactedCompoundFile Constructor(Options)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class > TransactedCompoundFile Constructor : TransactedCompoundFile Constructor(Options)

options

Glossary Item Box

Creates or opens a TransactedCompoundFile using the filename specified.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal options As TransactedCompoundFile.Options _
)
C#
public TransactedCompoundFile(
   TransactedCompoundFile.Options options
)

Parameters

options

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members
Overload List

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TransactedCompoundFile Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile Class

Glossary Item Box

For a list of all members of this type, see TransactedCompoundFile members.

Public Methods

 | Name | Description
Public Method | Clear | Immediatly truncates the file to zero-length and re-initializes an empty file
Public Method | Commit | Overloaded. For file-level transactions, performs a two-stage commit of all changed handles.
Public Method | Create | Allocates a handle for data, you MUST call Write to commit the handle, otherwise the handle may be reallocated after closing and re-opening this file. If you do not intend to commit the handle by writing to it, you should still call Delete() so that it may be reused.
Public Method | Delete | Deletes the handle and frees the associated block space for reuse.
Public Method | Dispose | Closes all streams and clears all in-memory data.
Public Method | Read | Reads all bytes from the from the handle specified
Public Method | Rollback | For file-level transactions, Reloads the file from it's original (or last committed) state.
Public Method | Write | Writes the bytes provided to the handle that was previously obtained by a call to Create(). The length must not be more than ((16*BlockSize)-32) bytes in length. The exact header size (32 bytes) may change without notice in a future release.
Top

See Also

Reference

TransactedCompoundFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : Clear Method

Glossary Item Box

Immediatly truncates the file to zero-length and re-initializes an empty file

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    byte[] sample = new byte[1024];
    new Random().NextBytes(sample);
    List<uint> handles = new List<uint>();
    using (TransactedCompoundFile file = new TransactedCompoundFile(temp.TempPath))
    {
        for (int i = 0; i < 100; i++)
        {
            var hid = file.Create();
            handles.Add(hid);
            file.Write(hid, sample, i, sample.Length - i);
            CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(hid)));
            file.Commit();
        }
        file.Clear();
        for (int i = 0; i < 100; i++)
        {
            try
            {
                IOStream.ReadAllBytes(file.Read(handles[i]));
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException) { }
        }
    }
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim sample As Byte() = New Byte(1024) {}
    New Random().NextBytes(sample)
    Dim [handles] As New List(Of UInteger)()
    Using file As New TransactedCompoundFile(temp.TempPath)
        Dim i As Integer = 0
        While i < 100
            Dim hid As var = file.Create()
            [handles].Add(hid)
            file.Write(hid, sample, i, sample.Length - i)
            CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(hid)))
            file.Commit()
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        file.Clear()
        Dim i As Integer = 0
        While i < 100
            Try
                IOStream.ReadAllBytes(file.Read([handles](i)))
                Assert.Fail()
            Catch generatedExceptionName As ArgumentOutOfRangeException
            End Try
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Commit Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : Commit Method

Glossary Item Box

For file-level transactions, performs a two-stage commit of all changed handles.

Overload List

Overload | Description
Commit() | For file-level transactions, performs a two-stage commit of all changed handles.
Commit<T>(Action<T>,T) | For file-level transactions, performs a two-stage commit of all changed handles. After the first stage has completed, the stageCommit() delegate is invoked.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Commit() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class > Commit Method : Commit() Method

Glossary Item Box

For file-level transactions, performs a two-stage commit of all changed handles.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Commit()
C#
public void Commit()

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
uint handle;
byte[] bytes = RandomBytes(2140);
using (TempFile temp = new TempFile())
{
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize=512, CreateNew = true }))
    {
        Assert.AreEqual(TransactedCompoundFile.FirstIdentity, test.Create());
        test.Write(TransactedCompoundFile.FirstIdentity, Encoding.UTF8.GetBytes("Roger was here."), 0, 15);
        Assert.AreEqual("Roger was here.", Encoding.UTF8.GetString(IOStream.ReadAllBytes(test.Read(TransactedCompoundFile.FirstIdentity))));

        for (int i = 0; i < 10; i++)
        {
            var id = test.Create();
            test.Write(id, bytes, i, 300);
            if (i % 2 == 0)
                test.Delete(id);
        }

        handle = test.Create();
        test.Write(handle, bytes, 1000, bytes.Length - 1000);
        CompareBytes(bytes, 1000, bytes.Length - 1000, IOStream.ReadAllBytes(test.Read(handle)));

        test.Write(handle, bytes, 0, bytes.Length);
        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(handle)));

        test.Commit();
    }
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize=512, CreateNew = false }))
    {
        Assert.AreEqual("Roger was here.", Encoding.UTF8.GetString(IOStream.ReadAllBytes(test.Read(TransactedCompoundFile.FirstIdentity))));
        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(handle)));
    }
}
VB.NET Copy Code
Dim handle As UInteger
Dim bytes As Byte() = RandomBytes(2140)
Using temp As New TempFile()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Assert.AreEqual(TransactedCompoundFile.FirstIdentity, test.Create())
        test.Write(TransactedCompoundFile.FirstIdentity, Encoding.UTF8.GetBytes("Roger was here."), 0, 15)
        Assert.AreEqual("Roger was here.", Encoding.UTF8.GetString(IOStream.ReadAllBytes(test.Read(TransactedCompoundFile.FirstIdentity))))

        Dim i As Integer = 0
        While i < 10
            Dim id As var = test.Create()
            test.Write(id, bytes, i, 300)
            If i Mod 2 = 0 Then
                test.Delete(id)
            End If
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        handle = test.Create()
        test.Write(handle, bytes, 1000, bytes.Length - 1000)
        CompareBytes(bytes, 1000, bytes.Length - 1000, IOStream.ReadAllBytes(test.Read(handle)))

        test.Write(handle, bytes, 0, bytes.Length)
        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(handle)))

        test.Commit()
    End Using
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = False _
    })
        Assert.AreEqual("Roger was here.", Encoding.UTF8.GetString(IOStream.ReadAllBytes(test.Read(TransactedCompoundFile.FirstIdentity))))
        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(handle)))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members
Overload List

Used By

TransactedCompoundFile.Dispose()

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Commit<T>(Action<T>,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class > Commit Method : Commit<T>(Action<T>,T) Method

stageCommit
value

Glossary Item Box

For file-level transactions, performs a two-stage commit of all changed handles. After the first stage has completed, the stageCommit() delegate is invoked.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Commit(Of T)( _
   ByVal stageCommit As Action(Of T), _
   ByVal value As T _
)
C#
public void Commit<T>(
   Action<T> stageCommit,
   T value
)

Parameters

stageCommit
value

Type Parameters

T

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members
Overload List

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : Create Method

Glossary Item Box

Allocates a handle for data, you MUST call Write to commit the handle, otherwise the handle may be reallocated after closing and re-opening this file. If you do not intend to commit the handle by writing to it, you should still call Delete() so that it may be reused.

Syntax

Visual Basic (Declaration)
Public Function Create() As UInteger
C#
public uint Create()

Exceptions

Exception | Description
System.IO.InvalidDataException |

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : Delete Method

handle

Glossary Item Box

Deletes the handle and frees the associated block space for reuse.

Syntax

Visual Basic (Declaration)
Public Sub Delete( _
   ByVal handle As UInteger _
)
C#
public void Delete(
   uint handle
)

Parameters

handle

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : Dispose Method

Glossary Item Box

Closes all streams and clears all in-memory data.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    var options = new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512 };

    const int count = 4;
    byte[] sample = new byte[options.MaxWriteSize / 3];
    new Random().NextBytes(sample);

    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            Assert.AreEqual(h, file.Create());
        for (uint h = 1u; h < count; h++)
            file.Write(h, sample, 0, sample.Length);
        file.Commit();
    }

    //Corrupts the primary of the first block, and secondary of the last block:
    using (Stream f = temp.Open())
    {
        f.Write(sample, 0, 100);
        f.Seek(-100, SeekOrigin.End);
        f.Write(sample, 0, 100);
    }
    try
    {
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary;
        new TransactedCompoundFile(options).Dispose();
        Assert.Fail("Should not load");
    }
    catch (InvalidDataException)
    {
    }
    try
    {
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary;
        new TransactedCompoundFile(options).Dispose();
        Assert.Fail("Should not load");
    }
    catch (InvalidDataException)
    {
    }

    options.LoadingRule = TransactedCompoundFile.LoadingRule.Default;
    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            CompareBytes(sample, 0, sample.Length, IOStream.ReadAllBytes(file.Read(h)));
        //Commit fixes corruption
        file.Commit();
    }

    options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary;
    new TransactedCompoundFile(options).Dispose();
    options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary;
    new TransactedCompoundFile(options).Dispose();
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim options As var = New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512 _
    }

    Const  count As Integer = 4
    Dim sample As Byte() = New Byte(options.MaxWriteSize / 3) {}
    New Random().NextBytes(sample)

    Using file As New TransactedCompoundFile(options)
        Dim h As UInteger = 1UI
        While h < count
            Assert.AreEqual(h, file.Create())
            System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
        End While
        Dim h As UInteger = 1UI
        While h < count
            file.Write(h, sample, 0, sample.Length)
            System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
        End While
        file.Commit()
    End Using

    'Corrupts the primary of the first block, and secondary of the last block:
    Using f As Stream = temp.Open()
        f.Write(sample, 0, 100)
        f.Seek(-100, SeekOrigin.[End])
        f.Write(sample, 0, 100)
    End Using
    Try
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary
        New TransactedCompoundFile(options).Dispose()
        Assert.Fail("Should not load")
    Catch generatedExceptionName As InvalidDataException
    End Try
    Try
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary
        New TransactedCompoundFile(options).Dispose()
        Assert.Fail("Should not load")
    Catch generatedExceptionName As InvalidDataException
    End Try

    options.LoadingRule = TransactedCompoundFile.LoadingRule.[Default]
    Using file As New TransactedCompoundFile(options)
        Dim h As UInteger = 1UI
        While h < count
            CompareBytes(sample, 0, sample.Length, IOStream.ReadAllBytes(file.Read(h)))
            System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
        End While
        'Commit fixes corruption
        file.Commit()
    End Using

    options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary
    New TransactedCompoundFile(options).Dispose()
    options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary
    New TransactedCompoundFile(options).Dispose()
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : Read Method

handle

Glossary Item Box

Reads all bytes from the from the handle specified

Syntax

Visual Basic (Declaration)
Public Function Read( _
   ByVal handle As UInteger _
) As Stream
C#
public Stream Read(
   uint handle
)

Parameters

handle

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.
System.IO.InvalidDataException |

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Rollback Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : Rollback Method

Glossary Item Box

For file-level transactions, Reloads the file from it's original (or last committed) state.

Syntax

Visual Basic (Declaration)
Public Sub Rollback()
C#
public void Rollback()

Exceptions

Exception | Description
System.InvalidOperationException | When CommitOnWrite is true, there is no going back.
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    byte[] sample = new byte[1024];
    new Random().NextBytes(sample);
    List<uint> handles = new List<uint>();
    using (TransactedCompoundFile file = new TransactedCompoundFile(temp.TempPath))
    {
        for (int i = 0; i < 1000; i++)
        {
            var hid = file.Create();
            handles.Add(hid);
            file.Write(hid, sample, i, sample.Length - i);
            CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(hid)));
        }
        file.Commit();
    }
    using (TransactedCompoundFile file = new TransactedCompoundFile(temp.TempPath))
    {
        byte[] dummy = new byte[1024];
        for (int i = 0; i < 1000; i++)
        {
            file.Write(handles[i], dummy, 0, dummy.Length);
            file.Delete(handles[i]);
        }
        file.Rollback();
        for (int i = 0; i < 1000; i++)
        {
            CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(handles[i])));
        }
    }
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim sample As Byte() = New Byte(1024) {}
    New Random().NextBytes(sample)
    Dim [handles] As New List(Of UInteger)()
    Using file As New TransactedCompoundFile(temp.TempPath)
        Dim i As Integer = 0
        While i < 1000
            Dim hid As var = file.Create()
            [handles].Add(hid)
            file.Write(hid, sample, i, sample.Length - i)
            CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(hid)))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        file.Commit()
    End Using
    Using file As New TransactedCompoundFile(temp.TempPath)
        Dim dummy As Byte() = New Byte(1024) {}
        Dim i As Integer = 0
        While i < 1000
            file.Write([handles](i), dummy, 0, dummy.Length)
            file.Delete([handles](i))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
        file.Rollback()
        Dim i As Integer = 0
        While i < 1000
            CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read([handles](i))))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : Write Method

handle
bytes
offset
length

Glossary Item Box

Writes the bytes provided to the handle that was previously obtained by a call to Create(). The length must not be more than ((16*BlockSize)-32) bytes in length. The exact header size (32 bytes) may change without notice in a future release.

Syntax

Visual Basic (Declaration)
Public Sub Write( _
   ByVal handle As UInteger, _
   ByVal bytes() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer _
)
C#
public void Write(
   uint handle,
   byte[] bytes,
   int offset,
   int length
)

Parameters

handle
bytes
offset
length

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TransactedCompoundFile Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile Class

Glossary Item Box

For a list of all members of this type, see TransactedCompoundFile members.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | FirstIdentity | Returns the first block that *would* be allocated by a call to Create() on an empty file.
Top

See Also

Reference

TransactedCompoundFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FirstIdentity Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile Class : FirstIdentity Property

Glossary Item Box

Returns the first block that *would* be allocated by a call to Create() on an empty file.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property FirstIdentity As UInteger
C#
public static uint FirstIdentity {get;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
uint handle;
byte[] bytes = RandomBytes(2140);
using (TempFile temp = new TempFile())
{
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize=512, CreateNew = true }))
    {
        Assert.AreEqual(TransactedCompoundFile.FirstIdentity, test.Create());
        test.Write(TransactedCompoundFile.FirstIdentity, Encoding.UTF8.GetBytes("Roger was here."), 0, 15);
        Assert.AreEqual("Roger was here.", Encoding.UTF8.GetString(IOStream.ReadAllBytes(test.Read(TransactedCompoundFile.FirstIdentity))));

        for (int i = 0; i < 10; i++)
        {
            var id = test.Create();
            test.Write(id, bytes, i, 300);
            if (i % 2 == 0)
                test.Delete(id);
        }

        handle = test.Create();
        test.Write(handle, bytes, 1000, bytes.Length - 1000);
        CompareBytes(bytes, 1000, bytes.Length - 1000, IOStream.ReadAllBytes(test.Read(handle)));

        test.Write(handle, bytes, 0, bytes.Length);
        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(handle)));

        test.Commit();
    }
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize=512, CreateNew = false }))
    {
        Assert.AreEqual("Roger was here.", Encoding.UTF8.GetString(IOStream.ReadAllBytes(test.Read(TransactedCompoundFile.FirstIdentity))));
        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(handle)));
    }
}
VB.NET Copy Code
Dim handle As UInteger
Dim bytes As Byte() = RandomBytes(2140)
Using temp As New TempFile()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Assert.AreEqual(TransactedCompoundFile.FirstIdentity, test.Create())
        test.Write(TransactedCompoundFile.FirstIdentity, Encoding.UTF8.GetBytes("Roger was here."), 0, 15)
        Assert.AreEqual("Roger was here.", Encoding.UTF8.GetString(IOStream.ReadAllBytes(test.Read(TransactedCompoundFile.FirstIdentity))))

        Dim i As Integer = 0
        While i < 10
            Dim id As var = test.Create()
            test.Write(id, bytes, i, 300)
            If i Mod 2 = 0 Then
                test.Delete(id)
            End If
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        handle = test.Create()
        test.Write(handle, bytes, 1000, bytes.Length - 1000)
        CompareBytes(bytes, 1000, bytes.Length - 1000, IOStream.ReadAllBytes(test.Read(handle)))

        test.Write(handle, bytes, 0, bytes.Length)
        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(handle)))

        test.Commit()
    End Using
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = False _
    })
        Assert.AreEqual("Roger was here.", Encoding.UTF8.GetString(IOStream.ReadAllBytes(test.Read(TransactedCompoundFile.FirstIdentity))))
        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(handle)))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile Class
TransactedCompoundFile Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactedCompoundFile.Options Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile.Options Class

Glossary Item Box

Advanced Options used to construct a TransactedCompoundFile

Syntax

Visual Basic (Declaration)
Public Class TransactedCompoundFile.Options
C#
public class TransactedCompoundFile.Options

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.TransactedCompoundFile.Options

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactedCompoundFile.cs

Used By

TransactedCompoundFile.Options TransactedCompoundFile.Options.Clone()


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TransactedCompoundFile.Options Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile.Options Class

Glossary Item Box

The following tables list the members exposed by TransactedCompoundFile.Options.

Public Constructors

 | Name | Description
Public Constructor | TransactedCompoundFile.Options Constructor | Constructs an Options instance
Top

Public Properties

 | Name | Description
Public Property | BlockSize | Defines the block-size used for storing data. Data storred in a given handle must be less than ((16*BlockSize)-8)
Public Property | CommitOnDispose | Automatically Commit the storage file when it's disposed.
Public Property | CommitOnWrite | When true every write will rewrite the modified handle(s) back to disk, otherwise the handle state is kept in memory until a call to commit has been made.
Public Property | CreateNew | True to create a new file, false to use the existing file. If this value is false and the file does not exist an exception will be raised.
Public Property | FileOptions | The FileOptions used for writing to the file
Public Property | FilePath | Retrieves the file name that was provided to the constructor
Public Property | LoadingRule | See comments on the LoadingRule enumerated type and Commit(Action,T)
Public Property | MaxWriteSize | Returns the maximum number of bytes that can be written to a single handle base on the current BlockSize setting.
Public Property | ReadOnly | Gets or sets a flag that controls if the file is opened in read-only mode. For ReadOnly files, another writer may exist; however, changes to the file will not be reflected until reload.
Top

Public Methods

 | Name | Description
Public Method | Clone | Returns a copy of the options currently specified.
Top

See Also

Reference

TransactedCompoundFile.Options Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactedCompoundFile.cs

Used By

TransactedCompoundFile.Options TransactedCompoundFile.Options.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactedCompoundFile.Options Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : TransactedCompoundFile.Options Constructor

filePath
The file name to use

Glossary Item Box

Constructs an Options instance

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal filePath As String _
)
C#
public TransactedCompoundFile.Options(
   string filePath
)

Parameters

filePath
The file name to use

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TransactedCompoundFile.Options Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile.Options Class

Glossary Item Box

For a list of all members of this type, see TransactedCompoundFile.Options members.

Public Methods

 | Name | Description
Public Method | Clone | Returns a copy of the options currently specified.
Top

See Also

Reference

TransactedCompoundFile.Options Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactedCompoundFile.cs

Used By

TransactedCompoundFile.Options TransactedCompoundFile.Options.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : Clone Method

Glossary Item Box

Returns a copy of the options currently specified.

Syntax

Visual Basic (Declaration)
Public Function Clone() As TransactedCompoundFile.Options
C#
public TransactedCompoundFile.Options Clone()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TransactedCompoundFile.Options Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile.Options Class

Glossary Item Box

For a list of all members of this type, see TransactedCompoundFile.Options members.

Public Properties

 | Name | Description
Public Property | BlockSize | Defines the block-size used for storing data. Data storred in a given handle must be less than ((16*BlockSize)-8)
Public Property | CommitOnDispose | Automatically Commit the storage file when it's disposed.
Public Property | CommitOnWrite | When true every write will rewrite the modified handle(s) back to disk, otherwise the handle state is kept in memory until a call to commit has been made.
Public Property | CreateNew | True to create a new file, false to use the existing file. If this value is false and the file does not exist an exception will be raised.
Public Property | FileOptions | The FileOptions used for writing to the file
Public Property | FilePath | Retrieves the file name that was provided to the constructor
Public Property | LoadingRule | See comments on the LoadingRule enumerated type and Commit(Action,T)
Public Property | MaxWriteSize | Returns the maximum number of bytes that can be written to a single handle base on the current BlockSize setting.
Public Property | ReadOnly | Gets or sets a flag that controls if the file is opened in read-only mode. For ReadOnly files, another writer may exist; however, changes to the file will not be reflected until reload.
Top

See Also

Reference

TransactedCompoundFile.Options Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactedCompoundFile.cs

Used By

TransactedCompoundFile.Options TransactedCompoundFile.Options.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
BlockSize Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : BlockSize Property

Glossary Item Box

Defines the block-size used for storing data. Data storred in a given handle must be less than ((16*BlockSize)-8)

Syntax

Visual Basic (Declaration)
Public Property BlockSize As Integer
C#
public int BlockSize {get; set;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommitOnDispose Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : CommitOnDispose Property

Glossary Item Box

Automatically Commit the storage file when it's disposed.

Syntax

Visual Basic (Declaration)
Public Property CommitOnDispose As Boolean
C#
public bool CommitOnDispose {get; set;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp1 = new TempFile())
using (TempFile temp2 = new TempFile())
{
    var options = new TransactedCompoundFile.Options(temp1.TempPath) { BlockSize = 512 };

    const int count = 4;
    byte[] sample1 = new byte[options.MaxWriteSize / 3];
    byte[] sample2 = (byte[])sample1.Clone();
    new Random().NextBytes(sample1);
    new Random().NextBytes(sample2);

    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            Assert.AreEqual(h, file.Create());
        for (uint h = 1u; h < count; h++)
            file.Write(h, sample1, 0, sample1.Length);
        file.Commit();//persist.
        for (uint h = 1u; h < count; h++)
            file.Write(h, sample2, 0, sample2.Length);

        file.Commit(x => temp1.CopyTo(temp2.TempPath, true), 0);
    }

    options = new TransactedCompoundFile.Options(temp2.TempPath) { BlockSize = 512, CommitOnDispose = false };

    //Verify primary has sample2 data
    options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary;
    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            CompareBytes(sample2, 0, sample2.Length, IOStream.ReadAllBytes(file.Read(h)));
    }
    //Verify secondary has sample1 data
    options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary;
    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            CompareBytes(sample1, 0, sample1.Length, IOStream.ReadAllBytes(file.Read(h)));
    }
}
VB.NET Copy Code
Using temp1 As New TempFile()
    Using temp2 As New TempFile()
        Dim options As var = New TransactedCompoundFile.Options(temp1.TempPath) With { _
            Key .BlockSize = 512 _
        }

        Const  count As Integer = 4
        Dim sample1 As Byte() = New Byte(options.MaxWriteSize / 3) {}
        Dim sample2 As Byte() = DirectCast(sample1.Clone(), Byte())
        New Random().NextBytes(sample1)
        New Random().NextBytes(sample2)

        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                Assert.AreEqual(h, file.Create())
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
            Dim h As UInteger = 1UI
            While h < count
                file.Write(h, sample1, 0, sample1.Length)
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
            file.Commit()
            'persist.
            Dim h As UInteger = 1UI
            While h < count
                file.Write(h, sample2, 0, sample2.Length)
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While

            file.Commit(Function(x) temp1.CopyTo(temp2.TempPath, True), 0)
        End Using

        options = New TransactedCompoundFile.Options(temp2.TempPath) With { _
            Key .BlockSize = 512, _
            Key .CommitOnDispose = False _
        }

        'Verify primary has sample2 data
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary
        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                CompareBytes(sample2, 0, sample2.Length, IOStream.ReadAllBytes(file.Read(h)))
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
        End Using
        'Verify secondary has sample1 data
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary
        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                CompareBytes(sample1, 0, sample1.Length, IOStream.ReadAllBytes(file.Read(h)))
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Used By

TransactedCompoundFile.Dispose()

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CommitOnWrite Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : CommitOnWrite Property

Glossary Item Box

When true every write will rewrite the modified handle(s) back to disk, otherwise the handle state is kept in memory until a call to commit has been made.

Syntax

Visual Basic (Declaration)
Public Property CommitOnWrite As Boolean
C#
public bool CommitOnWrite {get; set;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    TestWriteWithOptions(
        new TransactedCompoundFile.Options(temp.TempPath)
        {
            BlockSize = 512,
            CommitOnWrite = false,
            CommitOnDispose = false
        }
        );
}
VB.NET Copy Code
Using temp As New TempFile()
    TestWriteWithOptions(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CommitOnWrite = False, _
        Key .CommitOnDispose = False _
    })
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Used By

TransactedCompoundFile.Commit(Action,T)
TransactedCompoundFile.Rollback()

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreateNew Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : CreateNew Property

Glossary Item Box

True to create a new file, false to use the existing file. If this value is false and the file does not exist an exception will be raised.

Syntax

Visual Basic (Declaration)
Public Property CreateNew As Boolean
C#
public bool CreateNew {get; set;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NET Copy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileOptions Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : FileOptions Property

Glossary Item Box

The FileOptions used for writing to the file

Syntax

Visual Basic (Declaration)
Public Property FileOptions As FileOptions
C#
public FileOptions FileOptions {get; set;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
using (TempFile temp2 = new TempFile())
{
    byte[] sample = new byte[1024];
    new Random().NextBytes(sample);
    List<uint> handles = new List<uint>();
    using (TransactedCompoundFile file = new TransactedCompoundFile(
            new TransactedCompoundFile.Options(temp.TempPath) { FileOptions = FileOptions.WriteThrough }
        ))
    {
        for (int i = 0; i < 1000; i++)
        {
            var hid = file.Create();
            handles.Add(hid);
            file.Write(hid, sample, i, sample.Length - i);
        }
        file.Commit();
        File.Copy(temp.TempPath, temp2.TempPath, true);
    }
    using (TransactedCompoundFile file = new TransactedCompoundFile(temp2.TempPath))
    {
        for (int i = 0; i < 1000; i++)
        {
            CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(handles[i])));
        }
    }
}
VB.NET Copy Code
Using temp As New TempFile()
    Using temp2 As New TempFile()
        Dim sample As Byte() = New Byte(1024) {}
        New Random().NextBytes(sample)
        Dim [handles] As New List(Of UInteger)()
        Using file As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
            Key .FileOptions = FileOptions.WriteThrough _
        })
            Dim i As Integer = 0
            While i < 1000
                Dim hid As var = file.Create()
                [handles].Add(hid)
                file.Write(hid, sample, i, sample.Length - i)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
            file.Commit()
            File.Copy(temp.TempPath, temp2.TempPath, True)
        End Using
        Using file As New TransactedCompoundFile(temp2.TempPath)
            Dim i As Integer = 0
            While i < 1000
                CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read([handles](i))))
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FilePath Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : FilePath Property

Glossary Item Box

Retrieves the file name that was provided to the constructor

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FilePath As String
C#
public string FilePath {get;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    TransactedCompoundFile.Options o = new TransactedCompoundFile.Options(temp.TempPath);
    Assert.AreEqual(temp.TempPath, o.FilePath);
    Assert.AreEqual(4096, o.BlockSize);
    Assert.AreEqual(8192, o.BlockSize = 8192);
    Assert.AreEqual(false, o.CreateNew);
    Assert.AreEqual(true, o.CreateNew = true);
    Assert.AreEqual(false, o.ReadOnly);
    Assert.AreEqual(true, o.ReadOnly = true);
    Assert.AreEqual(false, o.CommitOnDispose);
    Assert.AreEqual(true, o.CommitOnDispose = true);
    Assert.AreEqual(false, o.CommitOnWrite);
    Assert.AreEqual(true, o.CommitOnWrite = true);
    Assert.AreEqual(FileOptions.None, o.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough, o.FileOptions = FileOptions.WriteThrough);
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Default, o.LoadingRule);
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Primary, o.LoadingRule = TransactedCompoundFile.LoadingRule.Primary);

    TransactedCompoundFile.Options copy = (TransactedCompoundFile.Options) ((ICloneable) o).Clone();
    Assert.AreEqual(FileOptions.WriteThrough, copy.FileOptions);
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim o As New TransactedCompoundFile.Options(temp.TempPath)
    Assert.AreEqual(temp.TempPath, o.FilePath)
    Assert.AreEqual(4096, o.BlockSize)
    Assert.AreEqual(8192, o.BlockSize = 8192)
    Assert.AreEqual(False, o.CreateNew)
    Assert.AreEqual(True, o.CreateNew = True)
    Assert.AreEqual(False, o.[ReadOnly])
    Assert.AreEqual(True, o.[ReadOnly] = True)
    Assert.AreEqual(False, o.CommitOnDispose)
    Assert.AreEqual(True, o.CommitOnDispose = True)
    Assert.AreEqual(False, o.CommitOnWrite)
    Assert.AreEqual(True, o.CommitOnWrite = True)
    Assert.AreEqual(FileOptions.None, o.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough, o.FileOptions = FileOptions.WriteThrough)
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.[Default], o.LoadingRule)
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Primary, o.LoadingRule = TransactedCompoundFile.LoadingRule.Primary)

    Dim copy As TransactedCompoundFile.Options = DirectCast((DirectCast(o, ICloneable)).Clone(), TransactedCompoundFile.Options)
    Assert.AreEqual(FileOptions.WriteThrough, copy.FileOptions)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LoadingRule Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : LoadingRule Property

Glossary Item Box

See comments on the LoadingRule enumerated type and Commit(Action,T)

Syntax

Visual Basic (Declaration)
Public Property LoadingRule As TransactedCompoundFile.LoadingRule
C#
public TransactedCompoundFile.LoadingRule LoadingRule {get; set;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp1 = new TempFile())
using (TempFile temp2 = new TempFile())
{
    var options = new TransactedCompoundFile.Options(temp1.TempPath) { BlockSize = 512 };

    const int count = 4;
    byte[] sample1 = new byte[options.MaxWriteSize / 3];
    byte[] sample2 = (byte[])sample1.Clone();
    new Random().NextBytes(sample1);
    new Random().NextBytes(sample2);

    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            Assert.AreEqual(h, file.Create());
        for (uint h = 1u; h < count; h++)
            file.Write(h, sample1, 0, sample1.Length);
        file.Commit();//persist.
        for (uint h = 1u; h < count; h++)
            file.Write(h, sample2, 0, sample2.Length);

        file.Commit(x => temp1.CopyTo(temp2.TempPath, true), 0);
    }

    options = new TransactedCompoundFile.Options(temp2.TempPath) { BlockSize = 512, CommitOnDispose = false };

    //Verify primary has sample2 data
    options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary;
    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            CompareBytes(sample2, 0, sample2.Length, IOStream.ReadAllBytes(file.Read(h)));
    }
    //Verify secondary has sample1 data
    options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary;
    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            CompareBytes(sample1, 0, sample1.Length, IOStream.ReadAllBytes(file.Read(h)));
    }
}
VB.NET Copy Code
Using temp1 As New TempFile()
    Using temp2 As New TempFile()
        Dim options As var = New TransactedCompoundFile.Options(temp1.TempPath) With { _
            Key .BlockSize = 512 _
        }

        Const  count As Integer = 4
        Dim sample1 As Byte() = New Byte(options.MaxWriteSize / 3) {}
        Dim sample2 As Byte() = DirectCast(sample1.Clone(), Byte())
        New Random().NextBytes(sample1)
        New Random().NextBytes(sample2)

        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                Assert.AreEqual(h, file.Create())
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
            Dim h As UInteger = 1UI
            While h < count
                file.Write(h, sample1, 0, sample1.Length)
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
            file.Commit()
            'persist.
            Dim h As UInteger = 1UI
            While h < count
                file.Write(h, sample2, 0, sample2.Length)
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While

            file.Commit(Function(x) temp1.CopyTo(temp2.TempPath, True), 0)
        End Using

        options = New TransactedCompoundFile.Options(temp2.TempPath) With { _
            Key .BlockSize = 512, _
            Key .CommitOnDispose = False _
        }

        'Verify primary has sample2 data
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary
        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                CompareBytes(sample2, 0, sample2.Length, IOStream.ReadAllBytes(file.Read(h)))
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
        End Using
        'Verify secondary has sample1 data
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary
        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                CompareBytes(sample1, 0, sample1.Length, IOStream.ReadAllBytes(file.Read(h)))
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members
TransactedCompoundFile.LoadingRule

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxWriteSize Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : MaxWriteSize Property

Glossary Item Box

Returns the maximum number of bytes that can be written to a single handle base on the current BlockSize setting.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MaxWriteSize As Integer
C#
public int MaxWriteSize {get;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp1 = new TempFile())
using (TempFile temp2 = new TempFile())
{
    var options = new TransactedCompoundFile.Options(temp1.TempPath) { BlockSize = 512 };

    const int count = 4;
    byte[] sample1 = new byte[options.MaxWriteSize / 3];
    byte[] sample2 = (byte[])sample1.Clone();
    new Random().NextBytes(sample1);
    new Random().NextBytes(sample2);

    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            Assert.AreEqual(h, file.Create());
        for (uint h = 1u; h < count; h++)
            file.Write(h, sample1, 0, sample1.Length);
        file.Commit();//persist.
        for (uint h = 1u; h < count; h++)
            file.Write(h, sample2, 0, sample2.Length);

        file.Commit(x => temp1.CopyTo(temp2.TempPath, true), 0);
    }

    options = new TransactedCompoundFile.Options(temp2.TempPath) { BlockSize = 512, CommitOnDispose = false };

    //Verify primary has sample2 data
    options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary;
    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            CompareBytes(sample2, 0, sample2.Length, IOStream.ReadAllBytes(file.Read(h)));
    }
    //Verify secondary has sample1 data
    options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary;
    using (TransactedCompoundFile file = new TransactedCompoundFile(options))
    {
        for (uint h = 1u; h < count; h++)
            CompareBytes(sample1, 0, sample1.Length, IOStream.ReadAllBytes(file.Read(h)));
    }
}
VB.NET Copy Code
Using temp1 As New TempFile()
    Using temp2 As New TempFile()
        Dim options As var = New TransactedCompoundFile.Options(temp1.TempPath) With { _
            Key .BlockSize = 512 _
        }

        Const  count As Integer = 4
        Dim sample1 As Byte() = New Byte(options.MaxWriteSize / 3) {}
        Dim sample2 As Byte() = DirectCast(sample1.Clone(), Byte())
        New Random().NextBytes(sample1)
        New Random().NextBytes(sample2)

        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                Assert.AreEqual(h, file.Create())
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
            Dim h As UInteger = 1UI
            While h < count
                file.Write(h, sample1, 0, sample1.Length)
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
            file.Commit()
            'persist.
            Dim h As UInteger = 1UI
            While h < count
                file.Write(h, sample2, 0, sample2.Length)
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While

            file.Commit(Function(x) temp1.CopyTo(temp2.TempPath, True), 0)
        End Using

        options = New TransactedCompoundFile.Options(temp2.TempPath) With { _
            Key .BlockSize = 512, _
            Key .CommitOnDispose = False _
        }

        'Verify primary has sample2 data
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Primary
        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                CompareBytes(sample2, 0, sample2.Length, IOStream.ReadAllBytes(file.Read(h)))
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
        End Using
        'Verify secondary has sample1 data
        options.LoadingRule = TransactedCompoundFile.LoadingRule.Secondary
        Using file As New TransactedCompoundFile(options)
            Dim h As UInteger = 1UI
            While h < count
                CompareBytes(sample1, 0, sample1.Length, IOStream.ReadAllBytes(file.Read(h)))
                System.Math.Max(System.Threading.Interlocked.Increment(h),h - 1)
            End While
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadOnly Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactedCompoundFile.Options Class : ReadOnly Property

Glossary Item Box

Gets or sets a flag that controls if the file is opened in read-only mode. For ReadOnly files, another writer may exist; however, changes to the file will not be reflected until reload.

Syntax

Visual Basic (Declaration)
Public Property ReadOnly As Boolean
C#
public bool ReadOnly {get; set;}

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    TransactedCompoundFile.Options o = new TransactedCompoundFile.Options(temp.TempPath);
    Assert.AreEqual(temp.TempPath, o.FilePath);
    Assert.AreEqual(4096, o.BlockSize);
    Assert.AreEqual(8192, o.BlockSize = 8192);
    Assert.AreEqual(false, o.CreateNew);
    Assert.AreEqual(true, o.CreateNew = true);
    Assert.AreEqual(false, o.ReadOnly);
    Assert.AreEqual(true, o.ReadOnly = true);
    Assert.AreEqual(false, o.CommitOnDispose);
    Assert.AreEqual(true, o.CommitOnDispose = true);
    Assert.AreEqual(false, o.CommitOnWrite);
    Assert.AreEqual(true, o.CommitOnWrite = true);
    Assert.AreEqual(FileOptions.None, o.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough, o.FileOptions = FileOptions.WriteThrough);
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Default, o.LoadingRule);
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Primary, o.LoadingRule = TransactedCompoundFile.LoadingRule.Primary);

    TransactedCompoundFile.Options copy = (TransactedCompoundFile.Options) ((ICloneable) o).Clone();
    Assert.AreEqual(FileOptions.WriteThrough, copy.FileOptions);
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim o As New TransactedCompoundFile.Options(temp.TempPath)
    Assert.AreEqual(temp.TempPath, o.FilePath)
    Assert.AreEqual(4096, o.BlockSize)
    Assert.AreEqual(8192, o.BlockSize = 8192)
    Assert.AreEqual(False, o.CreateNew)
    Assert.AreEqual(True, o.CreateNew = True)
    Assert.AreEqual(False, o.[ReadOnly])
    Assert.AreEqual(True, o.[ReadOnly] = True)
    Assert.AreEqual(False, o.CommitOnDispose)
    Assert.AreEqual(True, o.CommitOnDispose = True)
    Assert.AreEqual(False, o.CommitOnWrite)
    Assert.AreEqual(True, o.CommitOnWrite = True)
    Assert.AreEqual(FileOptions.None, o.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough, o.FileOptions = FileOptions.WriteThrough)
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.[Default], o.LoadingRule)
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Primary, o.LoadingRule = TransactedCompoundFile.LoadingRule.Primary)

    Dim copy As TransactedCompoundFile.Options = DirectCast((DirectCast(o, ICloneable)).Clone(), TransactedCompoundFile.Options)
    Assert.AreEqual(FileOptions.WriteThrough, copy.FileOptions)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactedCompoundFile.Options Class
TransactedCompoundFile.Options Members

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactFile Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactFile Class

Glossary Item Box

Creates a temp file based on the given file being replaced and when a call to Commit() is made the target file is replaced with the current contents of the temporary file.

Syntax

Visual Basic (Declaration)
Public Class TransactFile
   Inherits TempFile
   Implements CSharpTest.Net.Interfaces.ITransactable
C#
public class TransactFile : TempFile, CSharpTest.Net.Interfaces.ITransactable

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();

using (TempFile replace = new TempFile())
using (TransactFile temp = new TransactFile(replace.TempPath))
{
    temp.WriteAllText(testdata);
    Assert.IsTrue(temp.Exists);
    temp.Rollback();
    Assert.IsFalse(temp.Exists);
}
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()

Using replace As New TempFile()
    Using temp As New TransactFile(replace.TempPath)
        temp.WriteAllText(testdata)
        Assert.IsTrue(temp.Exists)
        temp.Rollback()
        Assert.IsFalse(temp.Exists)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IO.TempFile
CSharpTest.Net.IO.TransactFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactFile Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactFile.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TransactFile Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactFile Class

Glossary Item Box

The following tables list the members exposed by TransactFile.

Public Constructors

 | Name | Description
Public Constructor | TransactFile Constructor | Creates a temp file based on the given file being replaced and when a call to Commit() is made the target file is replaced with the current contents of the temporary file.
Top

Public Properties

 | Name | Description
Public Property | Exists | Returns true if the current temp file exists. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | Info | Returns the FileInfo object for this temp file. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | Length | Gets or sets the current length of the temp file. If setting the length on a file that does not exist one will be created. If getting the length of a file that doesnt exist zero will be returned. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | TargetFile | Returns the originally provided filename that is being replaced
Public Property | TempPath | Returns the temporary file path being managed. (Inherited from CSharpTest.Net.IO.TempFile)
Top

Public Methods

 | Name | Description
Public Method | Commit | Commits the replace operation on the file
Public Method | CopyTo | Overloaded. Copies the file content to the specified target file name (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Create | Re-Creates and Opens the temporary file for writing, multiple calls will truncate existing data. (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Delete | Deletes the current temp file immediatly if it exists. (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Detatch | Detatches this instance from the temporary file and returns the temp file's path (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Dispose | Overloaded. Overridden. Disposes of the open stream and the temporary file.
Public Method | Open | Open or Create the temporary file for reading and writing (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Read | Overloaded. Opens the temporary file for reading (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | ReadAllBytes | Reads all bytes from the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | ReadAllText | Reads all UTF8 text from the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Rollback | Aborts the operation and reverts pending changes
Public Method | WriteAllBytes | Writes all bytes to the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | WriteAllText | Writes all UTF8 text to the file (Inherited from CSharpTest.Net.IO.TempFile)
Top

See Also

Reference

TransactFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactFile Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactFile Class : TransactFile Constructor

targetName

Glossary Item Box

Creates a temp file based on the given file being replaced and when a call to Commit() is made the target file is replaced with the current contents of the temporary file.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal targetName As String _
)
C#
public TransactFile(
   string targetName
)

Parameters

targetName

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();

using (TempFile replace = new TempFile())
using (TransactFile temp = new TransactFile(replace.TempPath))
{
    temp.WriteAllText(testdata);
    Assert.IsTrue(temp.Exists);
    temp.Rollback();
    Assert.IsFalse(temp.Exists);
}
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()

Using replace As New TempFile()
    Using temp As New TransactFile(replace.TempPath)
        temp.WriteAllText(testdata)
        Assert.IsTrue(temp.Exists)
        temp.Rollback()
        Assert.IsFalse(temp.Exists)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactFile Class
TransactFile Members

Source Code

Library/IO/TransactFile.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TransactFile Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactFile Class

Glossary Item Box

For a list of all members of this type, see TransactFile members.

Public Methods

 | Name | Description
Public Method | Commit | Commits the replace operation on the file
Public Method | CopyTo | Overloaded. Copies the file content to the specified target file name (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Create | Re-Creates and Opens the temporary file for writing, multiple calls will truncate existing data. (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Delete | Deletes the current temp file immediatly if it exists. (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Detatch | Detatches this instance from the temporary file and returns the temp file's path (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Dispose | Overloaded. Overridden. Disposes of the open stream and the temporary file.
Public Method | Open | Open or Create the temporary file for reading and writing (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Read | Overloaded. Opens the temporary file for reading (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | ReadAllBytes | Reads all bytes from the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | ReadAllText | Reads all UTF8 text from the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | Rollback | Aborts the operation and reverts pending changes
Public Method | WriteAllBytes | Writes all bytes to the file (Inherited from CSharpTest.Net.IO.TempFile)
Public Method | WriteAllText | Writes all UTF8 text to the file (Inherited from CSharpTest.Net.IO.TempFile)
Top

See Also

Reference

TransactFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Commit Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactFile Class : Commit Method

Glossary Item Box

Commits the replace operation on the file

Syntax

Visual Basic (Declaration)
Public Sub Commit()
C#
public void Commit()

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();
string tmpPath;

using (TempFile replace = new TempFile())
{
    using (TransactFile temp = new TransactFile(replace.TempPath))
    {
        Assert.AreEqual(temp.TargetFile, replace.TempPath);
        tmpPath = temp.TempPath;
        Assert.IsTrue(temp.Exists);
        temp.WriteAllText(testdata);
        //missing commit:
        //temp.Commit();
    }
    Assert.AreEqual(0, replace.Length);
    Assert.IsFalse(File.Exists(tmpPath));

    //now for real
    using (TransactFile temp = new TransactFile(replace.TempPath))
    {
        tmpPath = temp.TempPath;
        Assert.IsTrue(temp.Exists);
        temp.WriteAllText(testdata);
        temp.Commit();
    }
    Assert.IsFalse(File.Exists(tmpPath));
    Assert.AreEqual(testdata, replace.ReadAllText());
}
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()
Dim tmpPath As String

Using replace As New TempFile()
    Using temp As New TransactFile(replace.TempPath)
        Assert.AreEqual(temp.TargetFile, replace.TempPath)
        tmpPath = temp.TempPath
        Assert.IsTrue(temp.Exists)
            'missing commit:
            'temp.Commit();
        temp.WriteAllText(testdata)
    End Using
    Assert.AreEqual(0, replace.Length)
    Assert.IsFalse(File.Exists(tmpPath))

    'now for real
    Using temp As New TransactFile(replace.TempPath)
        tmpPath = temp.TempPath
        Assert.IsTrue(temp.Exists)
        temp.WriteAllText(testdata)
        temp.Commit()
    End Using
    Assert.IsFalse(File.Exists(tmpPath))
    Assert.AreEqual(testdata, replace.ReadAllText())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactFile Class
TransactFile Members

Source Code

Library/IO/TransactFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactFile Class : Dispose Method

Glossary Item Box

Disposes of the open stream and the temporary file.

Overload List

Overload | Description
Dispose(Boolean) | Disposes of the open stream and the temporary file.
Dispose() | Disposes of the temporary file (Inherited from CSharpTest.Net.IO.TempFile)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactFile Class
TransactFile Members
Base Implementation in Dispose


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactFile Class > Dispose Method : Dispose(Boolean) Method

disposing

Glossary Item Box

Disposes of the open stream and the temporary file.

Syntax

Visual Basic (Declaration)
Protected Overloads Overrides Sub Dispose( _
   ByVal disposing As Boolean _
)
C#
protected override void Dispose(
   bool disposing
)

Parameters

disposing

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactFile Class
TransactFile Members
Overload List
Base Implementation in Dispose(Boolean)


%%PageItemTitle%%

[image]
CSharpTest.Net
Rollback Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactFile Class : Rollback Method

Glossary Item Box

Aborts the operation and reverts pending changes

Syntax

Visual Basic (Declaration)
Public Sub Rollback()
C#
public void Rollback()

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();

using (TempFile replace = new TempFile())
using (TransactFile temp = new TransactFile(replace.TempPath))
{
    temp.WriteAllText(testdata);
    Assert.IsTrue(temp.Exists);
    temp.Rollback();
    Assert.IsFalse(temp.Exists);
}
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()

Using replace As New TempFile()
    Using temp As New TransactFile(replace.TempPath)
        temp.WriteAllText(testdata)
        Assert.IsTrue(temp.Exists)
        temp.Rollback()
        Assert.IsFalse(temp.Exists)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactFile Class
TransactFile Members

Source Code

Library/IO/TransactFile.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TransactFile Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactFile Class

Glossary Item Box

For a list of all members of this type, see TransactFile members.

Public Properties

 | Name | Description
Public Property | Exists | Returns true if the current temp file exists. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | Info | Returns the FileInfo object for this temp file. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | Length | Gets or sets the current length of the temp file. If setting the length on a file that does not exist one will be created. If getting the length of a file that doesnt exist zero will be returned. (Inherited from CSharpTest.Net.IO.TempFile)
Public Property | TargetFile | Returns the originally provided filename that is being replaced
Public Property | TempPath | Returns the temporary file path being managed. (Inherited from CSharpTest.Net.IO.TempFile)
Top

See Also

Reference

TransactFile Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/TransactFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TargetFile Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TransactFile Class : TargetFile Property

Glossary Item Box

Returns the originally provided filename that is being replaced

Syntax

Visual Basic (Declaration)
Public ReadOnly Property TargetFile As String
C#
public string TargetFile {get;}

Example

Library/Library.Test/TestReplaceFile.cs

C# Copy Code
string testdata = Guid.NewGuid().ToString();
string tmpPath;

using (TempFile replace = new TempFile())
{
    using (TransactFile temp = new TransactFile(replace.TempPath))
    {
        Assert.AreEqual(temp.TargetFile, replace.TempPath);
        tmpPath = temp.TempPath;
        Assert.IsTrue(temp.Exists);
        temp.WriteAllText(testdata);
        //missing commit:
        //temp.Commit();
    }
    Assert.AreEqual(0, replace.Length);
    Assert.IsFalse(File.Exists(tmpPath));

    //now for real
    using (TransactFile temp = new TransactFile(replace.TempPath))
    {
        tmpPath = temp.TempPath;
        Assert.IsTrue(temp.Exists);
        temp.WriteAllText(testdata);
        temp.Commit();
    }
    Assert.IsFalse(File.Exists(tmpPath));
    Assert.AreEqual(testdata, replace.ReadAllText());
}
VB.NET Copy Code
Dim testdata As String = Guid.NewGuid().ToString()
Dim tmpPath As String

Using replace As New TempFile()
    Using temp As New TransactFile(replace.TempPath)
        Assert.AreEqual(temp.TargetFile, replace.TempPath)
        tmpPath = temp.TempPath
        Assert.IsTrue(temp.Exists)
            'missing commit:
            'temp.Commit();
        temp.WriteAllText(testdata)
    End Using
    Assert.AreEqual(0, replace.Length)
    Assert.IsFalse(File.Exists(tmpPath))

    'now for real
    Using temp As New TransactFile(replace.TempPath)
        tmpPath = temp.TempPath
        Assert.IsTrue(temp.Exists)
        temp.WriteAllText(testdata)
        temp.Commit()
    End Using
    Assert.IsFalse(File.Exists(tmpPath))
    Assert.AreEqual(testdata, replace.ReadAllText())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactFile Class
TransactFile Members

Source Code

Library/IO/TransactFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TransactedCompoundFile.LoadingRule Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile.LoadingRule Enumeration

Glossary Item Box

Defines the loading rule to apply when using a transacted file that was interrupted durring the commit process.

Syntax

Visual Basic (Declaration)
Public Enum TransactedCompoundFile.LoadingRule
   Inherits System.Enum
C#
public enum TransactedCompoundFile.LoadingRule : System.Enum

Members

Member | Description
Default | Load all from Primary if valid, else load all from Secondary. If both fail, load either Primary or Secondary for each segment. This is the normal option, use the other options only when recovering from a commit that was incomplete.
Primary | If you previously called Commit(Action,T) on a prior instance and the Action delegate *was* called, then setting this value will ensure that only the primary state storage is loaded, thereby ensuring you load the 'previous' state.
Secondary | If you previously called Commit(Action,T) on a prior instance and the Action delegate was *not* called, then setting this value will ensure that only the secondary state storage is loaded, thereby ensuring you load the 'previous' state.

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    TransactedCompoundFile.Options o = new TransactedCompoundFile.Options(temp.TempPath);
    Assert.AreEqual(temp.TempPath, o.FilePath);
    Assert.AreEqual(4096, o.BlockSize);
    Assert.AreEqual(8192, o.BlockSize = 8192);
    Assert.AreEqual(false, o.CreateNew);
    Assert.AreEqual(true, o.CreateNew = true);
    Assert.AreEqual(false, o.ReadOnly);
    Assert.AreEqual(true, o.ReadOnly = true);
    Assert.AreEqual(false, o.CommitOnDispose);
    Assert.AreEqual(true, o.CommitOnDispose = true);
    Assert.AreEqual(false, o.CommitOnWrite);
    Assert.AreEqual(true, o.CommitOnWrite = true);
    Assert.AreEqual(FileOptions.None, o.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough, o.FileOptions = FileOptions.WriteThrough);
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Default, o.LoadingRule);
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Primary, o.LoadingRule = TransactedCompoundFile.LoadingRule.Primary);

    TransactedCompoundFile.Options copy = (TransactedCompoundFile.Options) ((ICloneable) o).Clone();
    Assert.AreEqual(FileOptions.WriteThrough, copy.FileOptions);
}
VB.NET Copy Code
Using temp As New TempFile()
    Dim o As New TransactedCompoundFile.Options(temp.TempPath)
    Assert.AreEqual(temp.TempPath, o.FilePath)
    Assert.AreEqual(4096, o.BlockSize)
    Assert.AreEqual(8192, o.BlockSize = 8192)
    Assert.AreEqual(False, o.CreateNew)
    Assert.AreEqual(True, o.CreateNew = True)
    Assert.AreEqual(False, o.[ReadOnly])
    Assert.AreEqual(True, o.[ReadOnly] = True)
    Assert.AreEqual(False, o.CommitOnDispose)
    Assert.AreEqual(True, o.CommitOnDispose = True)
    Assert.AreEqual(False, o.CommitOnWrite)
    Assert.AreEqual(True, o.CommitOnWrite = True)
    Assert.AreEqual(FileOptions.None, o.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough, o.FileOptions = FileOptions.WriteThrough)
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.[Default], o.LoadingRule)
    Assert.AreEqual(TransactedCompoundFile.LoadingRule.Primary, o.LoadingRule = TransactedCompoundFile.LoadingRule.Primary)

    Dim copy As TransactedCompoundFile.Options = DirectCast((DirectCast(o, ICloneable)).Clone(), TransactedCompoundFile.Options)
    Assert.AreEqual(FileOptions.WriteThrough, copy.FileOptions)
End Using

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.IO.TransactedCompoundFile.LoadingRule

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.IO Namespace
TransactedCompoundFile.LoadingRule TransactedCompoundFile.Options.LoadingRule

Source Code

Library/IO/TransactedCompoundFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc32 Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : Crc32 Structure

Glossary Item Box

Provides a simple CRC32 checksum for a set of bytes

Syntax

Visual Basic (Declaration)
Public Structure Crc32
   Inherits System.ValueType
C#
public struct Crc32 : System.ValueType

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Assert.AreEqual("00000000", new Crc32().ToString());
Assert.AreEqual("00100100", new Crc32(0x00100100).ToString());
Assert.AreEqual("F0100100", new Crc32(unchecked((int)0xF0100100)).ToString());
VB.NET Copy Code
Assert.AreEqual("00000000", New Crc32().ToString())
Assert.AreEqual("00100100", New Crc32(&H100100).ToString())
Assert.AreEqual("F0100100", New Crc32(DirectCast(&Hf0100100UI, Integer)).ToString())

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.IO.Crc32

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Members
CSharpTest.Net.IO Namespace

Used By

TransactionLog.CommitTransaction(TransactionToken)
Boolean Crc32.Equals(Object)

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Crc32 Structure Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : Crc32 Structure

Glossary Item Box

The following tables list the members exposed by Crc32.

Public Constructors

 | Name | Description
Public Constructor | Crc32 Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Value | Returns the computed CRC32 value
Top

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds a byte to the checksum
Public Method | Equals | Overloaded. Returns true if the other object is equal to this one
Public Method | GetHashCode | Extracts the correct hash code
Public Method | ToString | Returns the computed CRC32 value as a Hex string
Top

Public Operators

public Operator Addition | Overloaded. Adds a byte to the checksum
public Operator Equality | Overloaded. Compares the two objects for equality
public Operator Inequality | Overloaded. Compares the two objects for equality
Top

See Also

Reference

Crc32 Structure
CSharpTest.Net.IO Namespace

Used By

TransactionLog.CommitTransaction(TransactionToken)
Boolean Crc32.Equals(Object)

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc32 Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : Crc32 Constructor

Glossary Item Box

Overload List

Overload | Description
Crc32 Constructor(Int32) | Resumes the computation of a CRC32 value
Crc32 Constructor(String) | Initailizes the Crc32 value to the checksum of the string as a series of 16-bit values
Crc32 Constructor(Byte[]) | Initailizes the Crc32 value to the checksum of the bytes provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc32 Constructor(Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Crc32 Constructor : Crc32 Constructor(Int32)

crc

Glossary Item Box

Resumes the computation of a CRC32 value

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal crc As Integer _
)
C#
public Crc32(
   int crc
)

Parameters

crc

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Assert.AreEqual("00000000", new Crc32().ToString());
Assert.AreEqual("00100100", new Crc32(0x00100100).ToString());
Assert.AreEqual("F0100100", new Crc32(unchecked((int)0xF0100100)).ToString());
VB.NET Copy Code
Assert.AreEqual("00000000", New Crc32().ToString())
Assert.AreEqual("00100100", New Crc32(&H100100).ToString())
Assert.AreEqual("F0100100", New Crc32(DirectCast(&Hf0100100UI, Integer)).ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc32 Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Crc32 Constructor : Crc32 Constructor(String)

text

Glossary Item Box

Initailizes the Crc32 value to the checksum of the string as a series of 16-bit values

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal text As String _
)
C#
public Crc32(
   string text
)

Parameters

text

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 all = new Crc32("hello there world");
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
crc += "hello ";
crc += "there ";
crc += "world";
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc32("hello there world")
Dim crc As New Crc32()
Assert.AreEqual(0, crc.Value)
crc += "hello "
crc += "there "
crc += "world"
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc32 Constructor(Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Crc32 Constructor : Crc32 Constructor(Byte[])

bytes

Glossary Item Box

Initailizes the Crc32 value to the checksum of the bytes provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bytes() As Byte _
)
C#
public Crc32(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 all = new Crc32(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc32(New Byte() {&H2, &H3, &H4, &H5, &H6})
Dim crc As New Crc32()
Assert.AreEqual(0, crc.Value)
crc.Add(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8}, 1, 5)
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Used By

Int32 BinaryComparer.GetHashCode(Byte[])

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Crc32 Structure Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : Crc32 Structure

Glossary Item Box

For a list of all members of this type, see Crc32 members.

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds a byte to the checksum
Public Method | Equals | Overloaded. Returns true if the other object is equal to this one
Public Method | GetHashCode | Extracts the correct hash code
Public Method | ToString | Returns the computed CRC32 value as a Hex string
Top

See Also

Reference

Crc32 Structure
CSharpTest.Net.IO Namespace

Used By

TransactionLog.CommitTransaction(TransactionToken)
Boolean Crc32.Equals(Object)

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : Add Method

Glossary Item Box

Adds a byte to the checksum

Overload List

Overload | Description
Add(Byte) | Adds a byte to the checksum
Add(Byte[]) | Adds an entire array of bytes to the checksum
Add(Byte[],Int32,Int32) | Adds a range from an array of bytes to the checksum
Add(String) | Adds a string to the checksum as a series of 16-bit values (big endian)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(Byte) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Add Method : Add(Byte) Method

b

Glossary Item Box

Adds a byte to the checksum

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal b As Byte _
)
C#
public void Add(
   byte b
)

Parameters

b

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
Assert.AreEqual(0, crc.GetHashCode());

crc.Add(0x1b);

Assert.AreNotEqual(0, crc.Value);
Assert.AreEqual(crc.Value, crc.GetHashCode());
VB.NET Copy Code
Dim crc As New Crc32()
Assert.AreEqual(0, crc.Value)
Assert.AreEqual(0, crc.GetHashCode())

crc.Add(&H1b)

Assert.AreNotEqual(0, crc.Value)
Assert.AreEqual(crc.Value, crc.GetHashCode())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Add Method : Add(Byte[]) Method

bytes

Glossary Item Box

Adds an entire array of bytes to the checksum

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal bytes() As Byte _
)
C#
public void Add(
   byte[] bytes
)

Parameters

bytes

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(Byte[],Int32,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Add Method : Add(Byte[],Int32,Int32) Method

bytes
start
length

Glossary Item Box

Adds a range from an array of bytes to the checksum

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal bytes() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer _
)
C#
public void Add(
   byte[] bytes,
   int start,
   int length
)

Parameters

bytes
start
length

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 all = new Crc32(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc32(New Byte() {&H2, &H3, &H4, &H5, &H6})
Dim crc As New Crc32()
Assert.AreEqual(0, crc.Value)
crc.Add(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8}, 1, 5)
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Used By

TransactionLog.CommitTransaction(TransactionToken)
Crc32.Add(Byte[])

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Add Method : Add(String) Method

text

Glossary Item Box

Adds a string to the checksum as a series of 16-bit values (big endian)

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal text As String _
)
C#
public void Add(
   string text
)

Parameters

text

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : Equals Method

Glossary Item Box

Returns true if the other object is equal to this one

Overload List

Overload | Description
Equals(Object) | Returns true if the other object is equal to this one
Equals(Crc32) | Returns true if the other object is equal to this one
Equals(Int32) | Returns true if the CRC32 provided is equal to this one

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Base Implementation in Equals


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Equals Method : Equals(Object) Method

obj

Glossary Item Box

Returns true if the other object is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Equals( _
   ByVal obj As Object _
) As Boolean
C#
public override bool Equals(
   object obj
)

Parameters

obj

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List
Base Implementation in Equals(Object)

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Crc32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Equals Method : Equals(Crc32) Method

other

Glossary Item Box

Returns true if the other object is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Function Equals( _
   ByVal other As Crc32 _
) As Boolean
C#
public bool Equals(
   Crc32 other
)

Parameters

other

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 empty = new Crc32();
Crc32 value = new Crc32("Hello");
Crc32 copy = new Crc32(value.Value);

Assert.IsTrue(value.Equals(copy));
Assert.IsFalse(value.Equals(empty));
Assert.IsTrue(value.Equals(copy.Value));
Assert.IsFalse(value.Equals(empty.Value));

Assert.IsTrue(value.Equals((object)copy));
Assert.IsFalse(value.Equals((object)empty));
Assert.IsTrue(value.Equals((object)copy.Value));
Assert.IsFalse(value.Equals((object)empty.Value));
VB.NET Copy Code
Dim empty As New Crc32()
Dim value As New Crc32("Hello")
Dim copy As New Crc32(value.Value)

Assert.IsTrue(value.Equals(copy))
Assert.IsFalse(value.Equals(empty))
Assert.IsTrue(value.Equals(copy.Value))
Assert.IsFalse(value.Equals(empty.Value))

Assert.IsTrue(value.Equals(DirectCast(copy, Object)))
Assert.IsFalse(value.Equals(DirectCast(empty, Object)))
Assert.IsTrue(value.Equals(DirectCast(copy.Value, Object)))
Assert.IsFalse(value.Equals(DirectCast(empty.Value, Object)))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Equals Method : Equals(Int32) Method

crc32

Glossary Item Box

Returns true if the CRC32 provided is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Function Equals( _
   ByVal crc32 As Integer _
) As Boolean
C#
public bool Equals(
   int crc32
)

Parameters

crc32

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 empty = new Crc32();
Crc32 value = new Crc32("Hello");
Crc32 copy = new Crc32(value.Value);

Assert.IsTrue(value.Equals(copy));
Assert.IsFalse(value.Equals(empty));
Assert.IsTrue(value.Equals(copy.Value));
Assert.IsFalse(value.Equals(empty.Value));

Assert.IsTrue(value.Equals((object)copy));
Assert.IsFalse(value.Equals((object)empty));
Assert.IsTrue(value.Equals((object)copy.Value));
Assert.IsFalse(value.Equals((object)empty.Value));
VB.NET Copy Code
Dim empty As New Crc32()
Dim value As New Crc32("Hello")
Dim copy As New Crc32(value.Value)

Assert.IsTrue(value.Equals(copy))
Assert.IsFalse(value.Equals(empty))
Assert.IsTrue(value.Equals(copy.Value))
Assert.IsFalse(value.Equals(empty.Value))

Assert.IsTrue(value.Equals(DirectCast(copy, Object)))
Assert.IsFalse(value.Equals(DirectCast(empty, Object)))
Assert.IsTrue(value.Equals(DirectCast(copy.Value, Object)))
Assert.IsFalse(value.Equals(DirectCast(empty.Value, Object)))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : GetHashCode Method

Glossary Item Box

Extracts the correct hash code

Syntax

Visual Basic (Declaration)
Public Overrides Function GetHashCode() As Integer
C#
public override int GetHashCode()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Base Implementation in GetHashCode

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : ToString Method

Glossary Item Box

Returns the computed CRC32 value as a Hex string

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Base Implementation in ToString

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Crc32 Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : Crc32 Structure

Glossary Item Box

For a list of all members of this type, see Crc32 members.

Public Properties

 | Name | Description
Public Property | Value | Returns the computed CRC32 value
Top

See Also

Reference

Crc32 Structure
CSharpTest.Net.IO Namespace

Used By

TransactionLog.CommitTransaction(TransactionToken)
Boolean Crc32.Equals(Object)

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : Value Property

Glossary Item Box

Returns the computed CRC32 value

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Value As Integer
C#
public int Value {get;}

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 all = new Crc32(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc32(New Byte() {&H2, &H3, &H4, &H5, &H6})
Dim crc As New Crc32()
Assert.AreEqual(0, crc.Value)
crc.Add(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8}, 1, 5)
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members

Used By

TransactionLog.CommitTransaction(TransactionToken)
Int32 BinaryComparer.GetHashCode(Byte[])
String Crc32.ToString()
Int32 Crc32.GetHashCode()
Boolean Crc32.Equals(Object)
Boolean Crc32.Equals(Int32)

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Addition Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : Addition Operator

Glossary Item Box

Adds a byte to the checksum

Overload List

Overload | Description
Addition(Crc32,Byte) | Adds a byte to the checksum
Addition(Crc32,Byte[]) | Adds an entire array of bytes to the checksum
Addition(Crc32,String) | Adds a string to the checksum as a series of 16-bit values

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Addition(Crc32,Byte) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Addition Operator : Addition(Crc32,Byte) Operator

chksum
b

Glossary Item Box

Adds a byte to the checksum

Syntax

Visual Basic (Declaration)
Overloads Public Operator +( _
   ByVal chksum As Crc32, _
   ByVal b As Byte _
) As Crc32
C#
public Crc32 operator +(
   Crc32 chksum,
   byte b
)

Parameters

chksum
b

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 all = new Crc32(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 });
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
crc += new byte[] { 0x1, 0x2, 0x3, 0x4 };
crc += 0x5;
crc += 0x6;
crc += 0x7;
crc += 0x8;
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc32(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8})
Dim crc As New Crc32()
Assert.AreEqual(0, crc.Value)
crc += New Byte() {&H1, &H2, &H3, &H4}
crc += &H5
crc += &H6
crc += &H7
crc += &H8
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Addition(Crc32,Byte[]) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Addition Operator : Addition(Crc32,Byte[]) Operator

chksum
bytes

Glossary Item Box

Adds an entire array of bytes to the checksum

Syntax

Visual Basic (Declaration)
Overloads Public Operator +( _
   ByVal chksum As Crc32, _
   ByVal bytes() As Byte _
) As Crc32
C#
public Crc32 operator +(
   Crc32 chksum,
   byte[] bytes
)

Parameters

chksum
bytes

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 all = new Crc32(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 });
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
crc += new byte[] { 0x1, 0x2, 0x3, 0x4 };
crc += 0x5;
crc += 0x6;
crc += 0x7;
crc += 0x8;
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc32(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8})
Dim crc As New Crc32()
Assert.AreEqual(0, crc.Value)
crc += New Byte() {&H1, &H2, &H3, &H4}
crc += &H5
crc += &H6
crc += &H7
crc += &H8
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Addition(Crc32,String) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Addition Operator : Addition(Crc32,String) Operator

chksum
text

Glossary Item Box

Adds a string to the checksum as a series of 16-bit values

Syntax

Visual Basic (Declaration)
Overloads Public Operator +( _
   ByVal chksum As Crc32, _
   ByVal text As String _
) As Crc32
C#
public Crc32 operator +(
   Crc32 chksum,
   string text
)

Parameters

chksum
text

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 all = new Crc32("hello there world");
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
crc += "hello ";
crc += "there ";
crc += "world";
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc32("hello there world")
Dim crc As New Crc32()
Assert.AreEqual(0, crc.Value)
crc += "hello "
crc += "there "
crc += "world"
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : Equality Operator

Glossary Item Box

Compares the two objects for equality

Overload List

Overload | Description
Equality(Crc32,Crc32) | Compares the two objects for equality
Equality(Crc32,Int32) | Compares the two objects for equality

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality(Crc32,Crc32) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Equality Operator : Equality(Crc32,Crc32) Operator

x
y

Glossary Item Box

Compares the two objects for equality

Syntax

Visual Basic (Declaration)
Overloads Public Operator =( _
   ByVal x As Crc32, _
   ByVal y As Crc32 _
) As Boolean
C#
public bool operator ==(
   Crc32 x,
   Crc32 y
)

Parameters

x
y

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 empty = new Crc32();
Crc32 value = new Crc32("Hello");
Crc32 copy = new Crc32(value.Value);

Assert.IsTrue(value == copy);
Assert.IsFalse(value == empty);
Assert.IsTrue(value == copy.Value);
Assert.IsFalse(value == empty.Value);

Assert.IsFalse(value != copy);
Assert.IsTrue(value != empty);
Assert.IsFalse(value != copy.Value);
Assert.IsTrue(value != empty.Value);
VB.NET Copy Code
Dim empty As New Crc32()
Dim value As New Crc32("Hello")
Dim copy As New Crc32(value.Value)

Assert.IsTrue(value = copy)
Assert.IsFalse(value = empty)
Assert.IsTrue(value = copy.Value)
Assert.IsFalse(value = empty.Value)

Assert.IsFalse(value <> copy)
Assert.IsTrue(value <> empty)
Assert.IsFalse(value <> copy.Value)
Assert.IsTrue(value <> empty.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality(Crc32,Int32) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Equality Operator : Equality(Crc32,Int32) Operator

x
y

Glossary Item Box

Compares the two objects for equality

Syntax

Visual Basic (Declaration)
Overloads Public Operator =( _
   ByVal x As Crc32, _
   ByVal y As Integer _
) As Boolean
C#
public bool operator ==(
   Crc32 x,
   int y
)

Parameters

x
y

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 empty = new Crc32();
Crc32 value = new Crc32("Hello");
Crc32 copy = new Crc32(value.Value);

Assert.IsTrue(value == copy);
Assert.IsFalse(value == empty);
Assert.IsTrue(value == copy.Value);
Assert.IsFalse(value == empty.Value);

Assert.IsFalse(value != copy);
Assert.IsTrue(value != empty);
Assert.IsFalse(value != copy.Value);
Assert.IsTrue(value != empty.Value);
VB.NET Copy Code
Dim empty As New Crc32()
Dim value As New Crc32("Hello")
Dim copy As New Crc32(value.Value)

Assert.IsTrue(value = copy)
Assert.IsFalse(value = empty)
Assert.IsTrue(value = copy.Value)
Assert.IsFalse(value = empty.Value)

Assert.IsFalse(value <> copy)
Assert.IsTrue(value <> empty)
Assert.IsFalse(value <> copy.Value)
Assert.IsTrue(value <> empty.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure : Inequality Operator

Glossary Item Box

Compares the two objects for equality

Overload List

Overload | Description
Inequality(Crc32,Crc32) | Compares the two objects for equality
Inequality(Crc32,Int32) | Compares the two objects for equality

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality(Crc32,Crc32) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Inequality Operator : Inequality(Crc32,Crc32) Operator

x
y

Glossary Item Box

Compares the two objects for equality

Syntax

Visual Basic (Declaration)
Overloads Public Operator <>( _
   ByVal x As Crc32, _
   ByVal y As Crc32 _
) As Boolean
C#
public bool operator !=(
   Crc32 x,
   Crc32 y
)

Parameters

x
y

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 empty = new Crc32();
Crc32 value = new Crc32("Hello");
Crc32 copy = new Crc32(value.Value);

Assert.IsTrue(value == copy);
Assert.IsFalse(value == empty);
Assert.IsTrue(value == copy.Value);
Assert.IsFalse(value == empty.Value);

Assert.IsFalse(value != copy);
Assert.IsTrue(value != empty);
Assert.IsFalse(value != copy.Value);
Assert.IsTrue(value != empty.Value);
VB.NET Copy Code
Dim empty As New Crc32()
Dim value As New Crc32("Hello")
Dim copy As New Crc32(value.Value)

Assert.IsTrue(value = copy)
Assert.IsFalse(value = empty)
Assert.IsTrue(value = copy.Value)
Assert.IsFalse(value = empty.Value)

Assert.IsFalse(value <> copy)
Assert.IsTrue(value <> empty)
Assert.IsFalse(value <> copy.Value)
Assert.IsTrue(value <> empty.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality(Crc32,Int32) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc32 Structure > Inequality Operator : Inequality(Crc32,Int32) Operator

x
y

Glossary Item Box

Compares the two objects for equality

Syntax

Visual Basic (Declaration)
Overloads Public Operator <>( _
   ByVal x As Crc32, _
   ByVal y As Integer _
) As Boolean
C#
public bool operator !=(
   Crc32 x,
   int y
)

Parameters

x
y

Example

Library/Library.Test/TestCrc32.cs

C# Copy Code
Crc32 empty = new Crc32();
Crc32 value = new Crc32("Hello");
Crc32 copy = new Crc32(value.Value);

Assert.IsTrue(value == copy);
Assert.IsFalse(value == empty);
Assert.IsTrue(value == copy.Value);
Assert.IsFalse(value == empty.Value);

Assert.IsFalse(value != copy);
Assert.IsTrue(value != empty);
Assert.IsFalse(value != copy.Value);
Assert.IsTrue(value != empty.Value);
VB.NET Copy Code
Dim empty As New Crc32()
Dim value As New Crc32("Hello")
Dim copy As New Crc32(value.Value)

Assert.IsTrue(value = copy)
Assert.IsFalse(value = empty)
Assert.IsTrue(value = copy.Value)
Assert.IsFalse(value = empty.Value)

Assert.IsFalse(value <> copy)
Assert.IsTrue(value <> empty)
Assert.IsFalse(value <> copy.Value)
Assert.IsTrue(value <> empty.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc32 Structure
Crc32 Members
Overload List

Source Code

Library/IO/Crc32.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc64 Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : Crc64 Structure

Glossary Item Box

Provides a simple CRC64 checksum for a set of bytes using algorithm (CRC-64/XZ)

Syntax

Visual Basic (Declaration)
Public Structure Crc64
   Inherits System.ValueType
C#
public struct Crc64 : System.ValueType

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Assert.AreEqual("0000000000000000", new Crc64().ToString());
Assert.AreEqual("0000000000100100", new Crc64(0x00100100).ToString());
Assert.AreEqual("FFFFFFFFF0100100", new Crc64(unchecked((int)0xF0100100)).ToString());
Assert.AreEqual("F010010011100110", new Crc64(unchecked((long)0xF010010011100110ul)).ToString());
VB.NET Copy Code
Assert.AreEqual("0000000000000000", New Crc64().ToString())
Assert.AreEqual("0000000000100100", New Crc64(&H100100).ToString())
Assert.AreEqual("FFFFFFFFF0100100", New Crc64(DirectCast(&Hf0100100UI, Integer)).ToString())
Assert.AreEqual("F010010011100110", New Crc64(DirectCast(&Hf010010011100110UL, Long)).ToString())

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.IO.Crc64

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/Crc64.cs

Used By

Boolean Crc64.Equals(Object)


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Crc64 Structure Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : Crc64 Structure

Glossary Item Box

The following tables list the members exposed by Crc64.

Public Constructors

 | Name | Description
Public Constructor | Crc64 Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Value | Returns the computed CRC64 value
Top

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds a byte to the checksum
Public Method | Equals | Overloaded. Returns true if the other object is equal to this one
Public Method | GetHashCode | Extracts the correct hash code
Public Method | ToString | Returns the computed CRC64 value as a Hex string
Top

Public Operators

public Operator Addition | Overloaded. Adds a byte to the checksum
public Operator Equality | Overloaded. Compares the two objects for equality
public Operator Inequality | Overloaded. Compares the two objects for equality
Top

See Also

Reference

Crc64 Structure
CSharpTest.Net.IO Namespace

Source Code

Library/IO/Crc64.cs

Used By

Boolean Crc64.Equals(Object)


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc64 Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : Crc64 Constructor

Glossary Item Box

Overload List

Overload | Description
Crc64 Constructor(Int64) | Resumes the computation of a CRC64 value
Crc64 Constructor(String) | Initailizes the Crc64 value to the checksum of the string as a series of 16-bit values
Crc64 Constructor(Byte[]) | Initailizes the Crc64 value to the checksum of the bytes provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc64 Constructor(Int64)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Crc64 Constructor : Crc64 Constructor(Int64)

crc

Glossary Item Box

Resumes the computation of a CRC64 value

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal crc As Long _
)
C#
public Crc64(
   long crc
)

Parameters

crc

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Assert.AreEqual("0000000000000000", new Crc64().ToString());
Assert.AreEqual("0000000000100100", new Crc64(0x00100100).ToString());
Assert.AreEqual("FFFFFFFFF0100100", new Crc64(unchecked((int)0xF0100100)).ToString());
Assert.AreEqual("F010010011100110", new Crc64(unchecked((long)0xF010010011100110ul)).ToString());
VB.NET Copy Code
Assert.AreEqual("0000000000000000", New Crc64().ToString())
Assert.AreEqual("0000000000100100", New Crc64(&H100100).ToString())
Assert.AreEqual("FFFFFFFFF0100100", New Crc64(DirectCast(&Hf0100100UI, Integer)).ToString())
Assert.AreEqual("F010010011100110", New Crc64(DirectCast(&Hf010010011100110UL, Long)).ToString())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc64 Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Crc64 Constructor : Crc64 Constructor(String)

text

Glossary Item Box

Initailizes the Crc64 value to the checksum of the string as a series of 16-bit values

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal text As String _
)
C#
public Crc64(
   string text
)

Parameters

text

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 all = new Crc64("hello there world");
Crc64 crc = new Crc64();
Assert.AreEqual(0, crc.Value);
crc += "hello ";
crc += "there ";
crc += "world";
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc64("hello there world")
Dim crc As New Crc64()
Assert.AreEqual(0, crc.Value)
crc += "hello "
crc += "there "
crc += "world"
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Crc64 Constructor(Byte[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Crc64 Constructor : Crc64 Constructor(Byte[])

bytes

Glossary Item Box

Initailizes the Crc64 value to the checksum of the bytes provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bytes() As Byte _
)
C#
public Crc64(
   byte[] bytes
)

Parameters

bytes

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 all = new Crc64(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
Crc64 crc = new Crc64();
Assert.AreEqual(0, crc.Value);
crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc64(New Byte() {&H2, &H3, &H4, &H5, &H6})
Dim crc As New Crc64()
Assert.AreEqual(0, crc.Value)
crc.Add(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8}, 1, 5)
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Crc64 Structure Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : Crc64 Structure

Glossary Item Box

For a list of all members of this type, see Crc64 members.

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds a byte to the checksum
Public Method | Equals | Overloaded. Returns true if the other object is equal to this one
Public Method | GetHashCode | Extracts the correct hash code
Public Method | ToString | Returns the computed CRC64 value as a Hex string
Top

See Also

Reference

Crc64 Structure
CSharpTest.Net.IO Namespace

Source Code

Library/IO/Crc64.cs

Used By

Boolean Crc64.Equals(Object)


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : Add Method

Glossary Item Box

Adds a byte to the checksum

Overload List

Overload | Description
Add(Byte) | Adds a byte to the checksum
Add(Byte[]) | Adds an entire array of bytes to the checksum
Add(Byte[],Int32,Int32) | Adds a range from an array of bytes to the checksum
Add(String) | Adds a string to the checksum as a series of 16-bit values (big endian)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(Byte) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Add Method : Add(Byte) Method

b

Glossary Item Box

Adds a byte to the checksum

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal b As Byte _
)
C#
public void Add(
   byte b
)

Parameters

b

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 crc = new Crc64();
Assert.AreEqual(0, crc.Value);
Assert.AreEqual(0, crc.GetHashCode());

crc.Add(0x1b);

Assert.AreNotEqual(0, crc.Value);
Assert.AreEqual((int)crc.Value ^ (int)(crc.Value >> 32), crc.GetHashCode());
VB.NET Copy Code
Dim crc As New Crc64()
Assert.AreEqual(0, crc.Value)
Assert.AreEqual(0, crc.GetHashCode())

crc.Add(&H1b)

Assert.AreNotEqual(0, crc.Value)
Assert.AreEqual(DirectCast(crc.Value, Integer) Xor DirectCast((crc.Value >> 32), Integer), crc.GetHashCode())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(Byte[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Add Method : Add(Byte[]) Method

bytes

Glossary Item Box

Adds an entire array of bytes to the checksum

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal bytes() As Byte _
)
C#
public void Add(
   byte[] bytes
)

Parameters

bytes

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(Byte[],Int32,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Add Method : Add(Byte[],Int32,Int32) Method

bytes
start
length

Glossary Item Box

Adds a range from an array of bytes to the checksum

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal bytes() As Byte, _
   ByVal start As Integer, _
   ByVal length As Integer _
)
C#
public void Add(
   byte[] bytes,
   int start,
   int length
)

Parameters

bytes
start
length

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 all = new Crc64(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
Crc64 crc = new Crc64();
Assert.AreEqual(0, crc.Value);
crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc64(New Byte() {&H2, &H3, &H4, &H5, &H6})
Dim crc As New Crc64()
Assert.AreEqual(0, crc.Value)
crc.Add(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8}, 1, 5)
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Used By

Crc64.Add(Byte[])

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Add Method : Add(String) Method

text

Glossary Item Box

Adds a string to the checksum as a series of 16-bit values (big endian)

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal text As String _
)
C#
public void Add(
   string text
)

Parameters

text

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : Equals Method

Glossary Item Box

Returns true if the other object is equal to this one

Overload List

Overload | Description
Equals(Object) | Returns true if the other object is equal to this one
Equals(Crc64) | Returns true if the other object is equal to this one
Equals(Int64) | Returns true if the CRC64 provided is equal to this one

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Base Implementation in Equals


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Equals Method : Equals(Object) Method

obj

Glossary Item Box

Returns true if the other object is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function Equals( _
   ByVal obj As Object _
) As Boolean
C#
public override bool Equals(
   object obj
)

Parameters

obj

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List
Base Implementation in Equals(Object)

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Crc64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Equals Method : Equals(Crc64) Method

other

Glossary Item Box

Returns true if the other object is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Function Equals( _
   ByVal other As Crc64 _
) As Boolean
C#
public bool Equals(
   Crc64 other
)

Parameters

other

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 empty = new Crc64();
Crc64 value = new Crc64("Hello");
Crc64 copy = new Crc64(value.Value);

Assert.IsTrue(value.Equals(copy));
Assert.IsFalse(value.Equals(empty));
Assert.IsTrue(value.Equals(copy.Value));
Assert.IsFalse(value.Equals(empty.Value));

Assert.IsTrue(value.Equals((object)copy));
Assert.IsFalse(value.Equals((object)empty));
Assert.IsTrue(value.Equals((object)copy.Value));
Assert.IsFalse(value.Equals((object)empty.Value));
VB.NET Copy Code
Dim empty As New Crc64()
Dim value As New Crc64("Hello")
Dim copy As New Crc64(value.Value)

Assert.IsTrue(value.Equals(copy))
Assert.IsFalse(value.Equals(empty))
Assert.IsTrue(value.Equals(copy.Value))
Assert.IsFalse(value.Equals(empty.Value))

Assert.IsTrue(value.Equals(DirectCast(copy, Object)))
Assert.IsFalse(value.Equals(DirectCast(empty, Object)))
Assert.IsTrue(value.Equals(DirectCast(copy.Value, Object)))
Assert.IsFalse(value.Equals(DirectCast(empty.Value, Object)))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equals(Int64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Equals Method : Equals(Int64) Method

crc64

Glossary Item Box

Returns true if the CRC64 provided is equal to this one

Syntax

Visual Basic (Declaration)
Public Overloads Function Equals( _
   ByVal crc64 As Long _
) As Boolean
C#
public bool Equals(
   long crc64
)

Parameters

crc64

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 empty = new Crc64();
Crc64 value = new Crc64("Hello");
Crc64 copy = new Crc64(value.Value);

Assert.IsTrue(value.Equals(copy));
Assert.IsFalse(value.Equals(empty));
Assert.IsTrue(value.Equals(copy.Value));
Assert.IsFalse(value.Equals(empty.Value));

Assert.IsTrue(value.Equals((object)copy));
Assert.IsFalse(value.Equals((object)empty));
Assert.IsTrue(value.Equals((object)copy.Value));
Assert.IsFalse(value.Equals((object)empty.Value));
VB.NET Copy Code
Dim empty As New Crc64()
Dim value As New Crc64("Hello")
Dim copy As New Crc64(value.Value)

Assert.IsTrue(value.Equals(copy))
Assert.IsFalse(value.Equals(empty))
Assert.IsTrue(value.Equals(copy.Value))
Assert.IsFalse(value.Equals(empty.Value))

Assert.IsTrue(value.Equals(DirectCast(copy, Object)))
Assert.IsFalse(value.Equals(DirectCast(empty, Object)))
Assert.IsTrue(value.Equals(DirectCast(copy.Value, Object)))
Assert.IsFalse(value.Equals(DirectCast(empty.Value, Object)))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetHashCode Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : GetHashCode Method

Glossary Item Box

Extracts the correct hash code

Syntax

Visual Basic (Declaration)
Public Overrides Function GetHashCode() As Integer
C#
public override int GetHashCode()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Base Implementation in GetHashCode

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : ToString Method

Glossary Item Box

Returns the computed CRC64 value as a Hex string

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Base Implementation in ToString

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Crc64 Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : Crc64 Structure

Glossary Item Box

For a list of all members of this type, see Crc64 members.

Public Properties

 | Name | Description
Public Property | Value | Returns the computed CRC64 value
Top

See Also

Reference

Crc64 Structure
CSharpTest.Net.IO Namespace

Source Code

Library/IO/Crc64.cs

Used By

Boolean Crc64.Equals(Object)


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : Value Property

Glossary Item Box

Returns the computed CRC64 value

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Value As Long
C#
public long Value {get;}

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 all = new Crc64(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
Crc64 crc = new Crc64();
Assert.AreEqual(0, crc.Value);
crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc64(New Byte() {&H2, &H3, &H4, &H5, &H6})
Dim crc As New Crc64()
Assert.AreEqual(0, crc.Value)
crc.Add(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8}, 1, 5)
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members

Used By

String Crc64.ToString()
Int32 Crc64.GetHashCode()
Boolean Crc64.Equals(Object)
Boolean Crc64.Equals(Int64)

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Addition Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : Addition Operator

Glossary Item Box

Adds a byte to the checksum

Overload List

Overload | Description
Addition(Crc64,Byte) | Adds a byte to the checksum
Addition(Crc64,Byte[]) | Adds an entire array of bytes to the checksum
Addition(Crc64,String) | Adds a string to the checksum as a series of 16-bit values

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Addition(Crc64,Byte) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Addition Operator : Addition(Crc64,Byte) Operator

chksum
b

Glossary Item Box

Adds a byte to the checksum

Syntax

Visual Basic (Declaration)
Overloads Public Operator +( _
   ByVal chksum As Crc64, _
   ByVal b As Byte _
) As Crc64
C#
public Crc64 operator +(
   Crc64 chksum,
   byte b
)

Parameters

chksum
b

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 all = new Crc64(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 });
Crc64 crc = new Crc64();
Assert.AreEqual(0, crc.Value);
crc += new byte[] { 0x1, 0x2, 0x3, 0x4 };
crc += 0x5;
crc += 0x6;
crc += 0x7;
crc += 0x8;
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc64(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8})
Dim crc As New Crc64()
Assert.AreEqual(0, crc.Value)
crc += New Byte() {&H1, &H2, &H3, &H4}
crc += &H5
crc += &H6
crc += &H7
crc += &H8
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Addition(Crc64,Byte[]) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Addition Operator : Addition(Crc64,Byte[]) Operator

chksum
bytes

Glossary Item Box

Adds an entire array of bytes to the checksum

Syntax

Visual Basic (Declaration)
Overloads Public Operator +( _
   ByVal chksum As Crc64, _
   ByVal bytes() As Byte _
) As Crc64
C#
public Crc64 operator +(
   Crc64 chksum,
   byte[] bytes
)

Parameters

chksum
bytes

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 all = new Crc64(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 });
Crc64 crc = new Crc64();
Assert.AreEqual(0, crc.Value);
crc += new byte[] { 0x1, 0x2, 0x3, 0x4 };
crc += 0x5;
crc += 0x6;
crc += 0x7;
crc += 0x8;
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc64(New Byte() {&H1, &H2, &H3, &H4, &H5, &H6, _
    &H7, &H8})
Dim crc As New Crc64()
Assert.AreEqual(0, crc.Value)
crc += New Byte() {&H1, &H2, &H3, &H4}
crc += &H5
crc += &H6
crc += &H7
crc += &H8
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Addition(Crc64,String) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Addition Operator : Addition(Crc64,String) Operator

chksum
text

Glossary Item Box

Adds a string to the checksum as a series of 16-bit values

Syntax

Visual Basic (Declaration)
Overloads Public Operator +( _
   ByVal chksum As Crc64, _
   ByVal text As String _
) As Crc64
C#
public Crc64 operator +(
   Crc64 chksum,
   string text
)

Parameters

chksum
text

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 all = new Crc64("hello there world");
Crc64 crc = new Crc64();
Assert.AreEqual(0, crc.Value);
crc += "hello ";
crc += "there ";
crc += "world";
Assert.AreEqual(all.Value, crc.Value);
VB.NET Copy Code
Dim all As New Crc64("hello there world")
Dim crc As New Crc64()
Assert.AreEqual(0, crc.Value)
crc += "hello "
crc += "there "
crc += "world"
Assert.AreEqual(all.Value, crc.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : Equality Operator

Glossary Item Box

Compares the two objects for equality

Overload List

Overload | Description
Equality(Crc64,Crc64) | Compares the two objects for equality
Equality(Crc64,Int64) | Compares the two objects for equality

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality(Crc64,Crc64) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Equality Operator : Equality(Crc64,Crc64) Operator

x
y

Glossary Item Box

Compares the two objects for equality

Syntax

Visual Basic (Declaration)
Overloads Public Operator =( _
   ByVal x As Crc64, _
   ByVal y As Crc64 _
) As Boolean
C#
public bool operator ==(
   Crc64 x,
   Crc64 y
)

Parameters

x
y

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 empty = new Crc64();
Crc64 value = new Crc64("Hello");
Crc64 copy = new Crc64(value.Value);

Assert.IsTrue(value == copy);
Assert.IsFalse(value == empty);
Assert.IsTrue(value == copy.Value);
Assert.IsFalse(value == empty.Value);

Assert.IsFalse(value != copy);
Assert.IsTrue(value != empty);
Assert.IsFalse(value != copy.Value);
Assert.IsTrue(value != empty.Value);
VB.NET Copy Code
Dim empty As New Crc64()
Dim value As New Crc64("Hello")
Dim copy As New Crc64(value.Value)

Assert.IsTrue(value = copy)
Assert.IsFalse(value = empty)
Assert.IsTrue(value = copy.Value)
Assert.IsFalse(value = empty.Value)

Assert.IsFalse(value <> copy)
Assert.IsTrue(value <> empty)
Assert.IsFalse(value <> copy.Value)
Assert.IsTrue(value <> empty.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Equality(Crc64,Int64) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Equality Operator : Equality(Crc64,Int64) Operator

x
y

Glossary Item Box

Compares the two objects for equality

Syntax

Visual Basic (Declaration)
Overloads Public Operator =( _
   ByVal x As Crc64, _
   ByVal y As Long _
) As Boolean
C#
public bool operator ==(
   Crc64 x,
   long y
)

Parameters

x
y

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 empty = new Crc64();
Crc64 value = new Crc64("Hello");
Crc64 copy = new Crc64(value.Value);

Assert.IsTrue(value == copy);
Assert.IsFalse(value == empty);
Assert.IsTrue(value == copy.Value);
Assert.IsFalse(value == empty.Value);

Assert.IsFalse(value != copy);
Assert.IsTrue(value != empty);
Assert.IsFalse(value != copy.Value);
Assert.IsTrue(value != empty.Value);
VB.NET Copy Code
Dim empty As New Crc64()
Dim value As New Crc64("Hello")
Dim copy As New Crc64(value.Value)

Assert.IsTrue(value = copy)
Assert.IsFalse(value = empty)
Assert.IsTrue(value = copy.Value)
Assert.IsFalse(value = empty.Value)

Assert.IsFalse(value <> copy)
Assert.IsTrue(value <> empty)
Assert.IsFalse(value <> copy.Value)
Assert.IsTrue(value <> empty.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure : Inequality Operator

Glossary Item Box

Compares the two objects for equality

Overload List

Overload | Description
Inequality(Crc64,Crc64) | Compares the two objects for equality
Inequality(Crc64,Int64) | Compares the two objects for equality

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality(Crc64,Crc64) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Inequality Operator : Inequality(Crc64,Crc64) Operator

x
y

Glossary Item Box

Compares the two objects for equality

Syntax

Visual Basic (Declaration)
Overloads Public Operator <>( _
   ByVal x As Crc64, _
   ByVal y As Crc64 _
) As Boolean
C#
public bool operator !=(
   Crc64 x,
   Crc64 y
)

Parameters

x
y

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 empty = new Crc64();
Crc64 value = new Crc64("Hello");
Crc64 copy = new Crc64(value.Value);

Assert.IsTrue(value == copy);
Assert.IsFalse(value == empty);
Assert.IsTrue(value == copy.Value);
Assert.IsFalse(value == empty.Value);

Assert.IsFalse(value != copy);
Assert.IsTrue(value != empty);
Assert.IsFalse(value != copy.Value);
Assert.IsTrue(value != empty.Value);
VB.NET Copy Code
Dim empty As New Crc64()
Dim value As New Crc64("Hello")
Dim copy As New Crc64(value.Value)

Assert.IsTrue(value = copy)
Assert.IsFalse(value = empty)
Assert.IsTrue(value = copy.Value)
Assert.IsFalse(value = empty.Value)

Assert.IsFalse(value <> copy)
Assert.IsTrue(value <> empty)
Assert.IsFalse(value <> copy.Value)
Assert.IsTrue(value <> empty.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Inequality(Crc64,Int64) Operator
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > Crc64 Structure > Inequality Operator : Inequality(Crc64,Int64) Operator

x
y

Glossary Item Box

Compares the two objects for equality

Syntax

Visual Basic (Declaration)
Overloads Public Operator <>( _
   ByVal x As Crc64, _
   ByVal y As Long _
) As Boolean
C#
public bool operator !=(
   Crc64 x,
   long y
)

Parameters

x
y

Example

Library/Library.Test/TestCrc64.cs

C# Copy Code
Crc64 empty = new Crc64();
Crc64 value = new Crc64("Hello");
Crc64 copy = new Crc64(value.Value);

Assert.IsTrue(value == copy);
Assert.IsFalse(value == empty);
Assert.IsTrue(value == copy.Value);
Assert.IsFalse(value == empty.Value);

Assert.IsFalse(value != copy);
Assert.IsTrue(value != empty);
Assert.IsFalse(value != copy.Value);
Assert.IsTrue(value != empty.Value);
VB.NET Copy Code
Dim empty As New Crc64()
Dim value As New Crc64("Hello")
Dim copy As New Crc64(value.Value)

Assert.IsTrue(value = copy)
Assert.IsFalse(value = empty)
Assert.IsTrue(value = copy.Value)
Assert.IsFalse(value = empty.Value)

Assert.IsFalse(value <> copy)
Assert.IsTrue(value <> empty)
Assert.IsFalse(value <> copy.Value)
Assert.IsTrue(value <> empty.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Crc64 Structure
Crc64 Members
Overload List

Source Code

Library/IO/Crc64.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFile.Info Structure
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile.Info Structure

Glossary Item Box

Provides a simple struct to capture file info, given by FindFile.FileFoundEventArgs.GetInfo method

Syntax

Visual Basic (Declaration)
Public Structure FindFile.Info
   Inherits System.ValueType
C#
public struct FindFile.Info : System.ValueType

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.IO.FindFile.Info

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Members
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FindFile.Info Structure Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile.Info Structure

Glossary Item Box

The following tables list the members exposed by FindFile.Info.

Public Properties

 | Name | Description
Public Property | Attributes | Gets or sets the file or folder attributes
Public Property | CreationTimeUtc | Gets or sets the file or folder CreationTime in Utc
Public Property | Extension | Returns the extenion or String.Empty
Public Property | FullPath | Gets or sets the full path of the file or folder
Public Property | FullPathUnc | Returns the UNC path to the file or folder
Public Property | LastAccessTimeUtc | Gets or sets the file or folder LastAccessTime in Utc
Public Property | LastWriteTimeUtc | Gets or sets the file or folder LastWriteTime in Utc
Public Property | Length | Gets or sets the length in bytes
Public Property | Name | Returns the file or folder name (with extension)
Public Property | ParentPath | Returns the parent folder's full path
Public Property | ParentPathUnc | Returns the UNC path to the parent folder
Top

See Also

Reference

FindFile.Info Structure
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
FindFile.Info Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FindFile.Info Structure

Glossary Item Box

For a list of all members of this type, see FindFile.Info members.

Public Properties

 | Name | Description
Public Property | Attributes | Gets or sets the file or folder attributes
Public Property | CreationTimeUtc | Gets or sets the file or folder CreationTime in Utc
Public Property | Extension | Returns the extenion or String.Empty
Public Property | FullPath | Gets or sets the full path of the file or folder
Public Property | FullPathUnc | Returns the UNC path to the file or folder
Public Property | LastAccessTimeUtc | Gets or sets the file or folder LastAccessTime in Utc
Public Property | LastWriteTimeUtc | Gets or sets the file or folder LastWriteTime in Utc
Public Property | Length | Gets or sets the length in bytes
Public Property | Name | Returns the file or folder name (with extension)
Public Property | ParentPath | Returns the parent folder's full path
Public Property | ParentPathUnc | Returns the UNC path to the parent folder
Top

See Also

Reference

FindFile.Info Structure
CSharpTest.Net.IO Namespace

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%%

[image]
CSharpTest.Net
Attributes Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : Attributes Property

Glossary Item Box

Gets or sets the file or folder attributes

Syntax

Visual Basic (Declaration)
Public Property Attributes As FileAttributes
C#
public FileAttributes Attributes {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%%

[image]
CSharpTest.Net
CreationTimeUtc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : CreationTimeUtc Property

Glossary Item Box

Gets or sets the file or folder CreationTime in Utc

Syntax

Visual Basic (Declaration)
Public Property CreationTimeUtc As Date
C#
public DateTime CreationTimeUtc {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%%

[image]
CSharpTest.Net
Extension Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : Extension Property

Glossary Item Box

Returns the extenion or String.Empty

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Extension As String
C#
public string Extension {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FullPath Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : FullPath Property

Glossary Item Box

Gets or sets the full path of the file or folder

Syntax

Visual Basic (Declaration)
Public Property FullPath As String
C#
public string FullPath {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%%

[image]
CSharpTest.Net
FullPathUnc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : FullPathUnc Property

Glossary Item Box

Returns the UNC path to the file or folder

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FullPathUnc As String
C#
public string FullPathUnc {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LastAccessTimeUtc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : LastAccessTimeUtc Property

Glossary Item Box

Gets or sets the file or folder LastAccessTime in Utc

Syntax

Visual Basic (Declaration)
Public Property LastAccessTimeUtc As Date
C#
public DateTime LastAccessTimeUtc {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%%

[image]
CSharpTest.Net
LastWriteTimeUtc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : LastWriteTimeUtc Property

Glossary Item Box

Gets or sets the file or folder LastWriteTime in Utc

Syntax

Visual Basic (Declaration)
Public Property LastWriteTimeUtc As Date
C#
public DateTime LastWriteTimeUtc {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%%

[image]
CSharpTest.Net
Length Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : Length Property

Glossary Item Box

Gets or sets the length in bytes

Syntax

Visual Basic (Declaration)
Public Property Length As Long
C#
public long Length {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs

Used By

FindFile.Info FindFile.FileFoundEventArgs.GetInfo()


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : Name Property

Glossary Item Box

Returns the file or folder name (with extension)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Name As String
C#
public string Name {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ParentPath Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : ParentPath Property

Glossary Item Box

Returns the parent folder's full path

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ParentPath As String
C#
public string ParentPath {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ParentPathUnc Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > FindFile.Info Structure : ParentPathUnc Property

Glossary Item Box

Returns the UNC path to the parent folder

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ParentPathUnc As String
C#
public string ParentPathUnc {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FindFile.Info Structure
FindFile.Info Members

Source Code

Library/IO/FindFile.cs


%%ItemTitle%%

CSharpTest.Net.IpcChannel Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.IpcChannel Namespace

Glossary Item Box

Classes

 | Class | Description
Class | IpcChannelRegistrar | Provides a default implementation of the channel registrar usuing the system registry as the storage facility.
Class | IpcEvent | Provides a means of subscribing to a named event on an IpcEventChannel, access via: IpcEventChannel["Name"].OnEvent += new IpcSignalEventArgs(MyHandler);
Class | IpcEventChannel | Provides a means to send and recieve events (optionally with arguments) across thread/process boundaries to a group of listeners of an event channel. Subscribe to desired events, call Start/StopListening, or just send events to other listeners on the same channel name. Provides the implmentation to send an event message to a group of instances
Class | IpcSignalEventArgs | Represents an event raised by the IpcEventChannel to subscribers.

Interfaces

 | Interface | Description
Interface | IIpcChannelRegistrar | Interface to provide a means of channel member registration and cross-process serialization of arguments for specific events. Implementations must be thread-safe even across process boundaries.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
IpcChannelRegistrar Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcChannelRegistrar Class

Glossary Item Box

Provides a default implementation of the channel registrar usuing the system registry as the storage facility.

Syntax

Visual Basic (Declaration)
Public Class IpcChannelRegistrar
   Implements IIpcChannelRegistrar
C#
public class IpcChannelRegistrar : IIpcChannelRegistrar

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
_registrar = new IpcChannelRegistrar(Registry.CurrentUser, KeyPath);
VB.NET Copy Code
_registrar = New IpcChannelRegistrar(Registry.CurrentUser, KeyPath)

Inheritance Hierarchy

System.Object
CSharpTest.Net.IpcChannel.IpcChannelRegistrar

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Members
CSharpTest.Net.IpcChannel Namespace

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IpcChannelRegistrar Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcChannelRegistrar Class

Glossary Item Box

The following tables list the members exposed by IpcChannelRegistrar.

Public Constructors

 | Name | Description
Public Constructor | IpcChannelRegistrar Constructor | Creates a ChannelRegistrar baseed in the hive specified at the allChannelsRoot path provided
Top

Public Methods

 | Name | Description
Public Method | GetRegisteredInstances | Overloaded. Enumerates the registered instanceIds for the provided channel name
Public Method | ReadParameters | Retreives the arguments for the event being sent to the specified instance
Public Method | RegisterInstance | Registers a member (instanceId) for the provided channel name
Public Method | UnregisterInstance | Unregisters a member (instanceId) from the provided channel name
Public Method | WriteParameters | Serializes the arguments for the event being sent to the specified instance
Top

See Also

Reference

IpcChannelRegistrar Class
CSharpTest.Net.IpcChannel Namespace

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpcChannelRegistrar Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class : IpcChannelRegistrar Constructor

rootHive
One of the registry hives ex: Registry.CurrentUser
allChannelsRoot
The path to store the ex: @"Software\YourProduct\IpcChannels"

Glossary Item Box

Creates a ChannelRegistrar baseed in the hive specified at the allChannelsRoot path provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal rootHive As RegistryKey, _
   ByVal allChannelsRoot As String _
)
C#
public IpcChannelRegistrar(
   RegistryKey rootHive,
   string allChannelsRoot
)

Parameters

rootHive
One of the registry hives ex: Registry.CurrentUser
allChannelsRoot
The path to store the ex: @"Software\YourProduct\IpcChannels"

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
_registrar = new IpcChannelRegistrar(Registry.CurrentUser, KeyPath);
VB.NET Copy Code
_registrar = New IpcChannelRegistrar(Registry.CurrentUser, KeyPath)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IpcChannelRegistrar Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcChannelRegistrar Class

Glossary Item Box

For a list of all members of this type, see IpcChannelRegistrar members.

Public Methods

 | Name | Description
Public Method | GetRegisteredInstances | Overloaded. Enumerates the registered instanceIds for the provided channel name
Public Method | ReadParameters | Retreives the arguments for the event being sent to the specified instance
Public Method | RegisterInstance | Registers a member (instanceId) for the provided channel name
Public Method | UnregisterInstance | Unregisters a member (instanceId) from the provided channel name
Public Method | WriteParameters | Serializes the arguments for the event being sent to the specified instance
Top

See Also

Reference

IpcChannelRegistrar Class
CSharpTest.Net.IpcChannel Namespace

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetRegisteredInstances Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class : GetRegisteredInstances Method

Glossary Item Box

Enumerates the registered instanceIds for the provided channel name

Overload List

Overload | Description
GetRegisteredInstances(String) | Enumerates the registered instanceIds for the provided channel name
GetRegisteredInstances(String,String) | Enumerates the registered instanceIds who's name is instanceName for the provided channel name
GetRegisteredInstances(String,IEnumerable<String>) | Enumerates the registered instanceIds who's name is instanceName for the provided channel name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetRegisteredInstances(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class > GetRegisteredInstances Method : GetRegisteredInstances(String) Method

channelName

Glossary Item Box

Enumerates the registered instanceIds for the provided channel name

Syntax

Visual Basic (Declaration)
Public Overloads Function GetRegisteredInstances( _
   ByVal channelName As String _
) As IEnumerable(Of String)
C#
public IEnumerable<string> GetRegisteredInstances(
   string channelName
)

Parameters

channelName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members
Overload List

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetRegisteredInstances(String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class > GetRegisteredInstances Method : GetRegisteredInstances(String,String) Method

channelName
nameFilter

Glossary Item Box

Enumerates the registered instanceIds who's name is instanceName for the provided channel name

Syntax

Visual Basic (Declaration)
Public Overloads Function GetRegisteredInstances( _
   ByVal channelName As String, _
   ByVal nameFilter As String _
) As IEnumerable(Of String)
C#
public IEnumerable<string> GetRegisteredInstances(
   string channelName,
   string nameFilter
)

Parameters

channelName
nameFilter

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members
Overload List

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetRegisteredInstances(String,IEnumerable<String>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class > GetRegisteredInstances Method : GetRegisteredInstances(String,IEnumerable<String>) Method

channelName
nameFilterIn

Glossary Item Box

Enumerates the registered instanceIds who's name is instanceName for the provided channel name

Syntax

Visual Basic (Declaration)
Public Overloads Function GetRegisteredInstances( _
   ByVal channelName As String, _
   ByVal nameFilterIn As IEnumerable(Of String) _
) As IEnumerable(Of String)
C#
public IEnumerable<string> GetRegisteredInstances(
   string channelName,
   IEnumerable<string> nameFilterIn
)

Parameters

channelName
nameFilterIn

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members
Overload List

Used By

IEnumerable IpcChannelRegistrar.GetRegisteredInstances(String)
IEnumerable IpcChannelRegistrar.GetRegisteredInstances(String,String)

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadParameters Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class : ReadParameters Method

channelName
instanceId
eventName

Glossary Item Box

Retreives the arguments for the event being sent to the specified instance

Syntax

Visual Basic (Declaration)
Public Function ReadParameters( _
   ByVal channelName As String, _
   ByVal instanceId As String, _
   ByVal eventName As String _
) As String()
C#
public string[] ReadParameters(
   string channelName,
   string instanceId,
   string eventName
)

Parameters

channelName
instanceId
eventName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegisterInstance Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class : RegisterInstance Method

channelName
instanceId
name

Glossary Item Box

Registers a member (instanceId) for the provided channel name

Syntax

Visual Basic (Declaration)
Public Sub RegisterInstance( _
   ByVal channelName As String, _
   ByVal instanceId As String, _
   ByVal name As String _
)
C#
public void RegisterInstance(
   string channelName,
   string instanceId,
   string name
)

Parameters

channelName
instanceId
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UnregisterInstance Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class : UnregisterInstance Method

channelName
instanceId

Glossary Item Box

Unregisters a member (instanceId) from the provided channel name

Syntax

Visual Basic (Declaration)
Public Sub UnregisterInstance( _
   ByVal channelName As String, _
   ByVal instanceId As String _
)
C#
public void UnregisterInstance(
   string channelName,
   string instanceId
)

Parameters

channelName
instanceId

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteParameters Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcChannelRegistrar Class : WriteParameters Method

channelName
instanceId
eventName
arguments

Glossary Item Box

Serializes the arguments for the event being sent to the specified instance

Syntax

Visual Basic (Declaration)
Public Function WriteParameters( _
   ByVal channelName As String, _
   ByVal instanceId As String, _
   ByVal eventName As String, _
   ByVal arguments() As String _
) As Boolean
C#
public bool WriteParameters(
   string channelName,
   string instanceId,
   string eventName,
   string[] arguments
)

Parameters

channelName
instanceId
eventName
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcChannelRegistrar Class
IpcChannelRegistrar Members

Source Code

Library/IpcChannel/IpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpcEvent Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEvent Class

Glossary Item Box

Provides a means of subscribing to a named event on an IpcEventChannel, access via: IpcEventChannel["Name"].OnEvent += new IpcSignalEventArgs(MyHandler);

Syntax

Visual Basic (Declaration)
Public MustInherit Class IpcEvent
C#
public abstract class IpcEvent

Inheritance Hierarchy

System.Object
CSharpTest.Net.IpcChannel.IpcEvent

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEvent Members
CSharpTest.Net.IpcChannel Namespace
IpcEvent IpcEventChannel.Item

Source Code

Library/IpcChannel/IpcEvent.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IpcEvent Class Members
See Also Fields Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEvent Class

Glossary Item Box

The following tables list the members exposed by IpcEvent.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | Used to compare IpcEvent instances by name
Top

Public Properties

 | Name | Description
Public Property | LocalName | Retrieves the name of this event
Top

Protected Methods

 | Name | Description
Protected Method | RaiseEvent | Not intended for external use.
Top

Public Events

 | Name | Description
Public Event | OnEvent | Allows you to subscribe or unsubscribe to the event
Top

See Also

Reference

IpcEvent Class
CSharpTest.Net.IpcChannel Namespace
IpcEvent IpcEventChannel.Item

Source Code

Library/IpcChannel/IpcEvent.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IpcEvent Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEvent Class

Glossary Item Box

For a list of all members of this type, see IpcEvent members.

Protected Methods

 | Name | Description
Protected Method | RaiseEvent | Not intended for external use.
Top

See Also

Reference

IpcEvent Class
CSharpTest.Net.IpcChannel Namespace
IpcEvent IpcEventChannel.Item

Source Code

Library/IpcChannel/IpcEvent.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RaiseEvent Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEvent Class : RaiseEvent Method

channel
args

Glossary Item Box

Not intended for external use.

Syntax

Visual Basic (Declaration)
Protected Sub RaiseEvent( _
   ByVal channel As IpcEventChannel, _
   ByVal ParamArray args() As String _
)
C#
protected void RaiseEvent(
   IpcEventChannel channel,
   params string[] args
)

Parameters

channel
args

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEvent Class
IpcEvent Members


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IpcEvent Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEvent Class

Glossary Item Box

For a list of all members of this type, see IpcEvent members.

Public Properties

 | Name | Description
Public Property | LocalName | Retrieves the name of this event
Top

See Also

Reference

IpcEvent Class
CSharpTest.Net.IpcChannel Namespace
IpcEvent IpcEventChannel.Item

Source Code

Library/IpcChannel/IpcEvent.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEvent Class : LocalName Property

Glossary Item Box

Retrieves the name of this event

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LocalName As String
C#
public string LocalName {get;}

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel channel = new IpcEventChannel(_registrar, _channel))
{
    Assert.AreEqual("Test", channel["Test"].LocalName);
    Assert.AreEqual("TEST", channel["TEST"].LocalName);
    Assert.AreEqual("test", channel["test"].LocalName);

    int count = 0;
    foreach (IpcEvent e in channel.GetEvents())
    {
        Assert.AreEqual("test", e.LocalName.ToLower());
        count++;
    }
    Assert.AreEqual(3, count);
}
VB.NET Copy Code
Using channel As New IpcEventChannel(_registrar, _channel)
    Assert.AreEqual("Test", channel("Test").LocalName)
    Assert.AreEqual("TEST", channel("TEST").LocalName)
    Assert.AreEqual("test", channel("test").LocalName)

    Dim count As Integer = 0
    For Each e As IpcEvent In channel.GetEvents()
        Assert.AreEqual("test", e.LocalName.ToLower())
        System.Math.Max(System.Threading.Interlocked.Increment(count),count - 1)
    Next
    Assert.AreEqual(3, count)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEvent Class
IpcEvent Members

Source Code

Library/IpcChannel/IpcEvent.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
IpcEvent Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEvent Class

Glossary Item Box

For a list of all members of this type, see IpcEvent members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Comparer | Used to compare IpcEvent instances by name
Top

See Also

Reference

IpcEvent Class
CSharpTest.Net.IpcChannel Namespace
IpcEvent IpcEventChannel.Item

Source Code

Library/IpcChannel/IpcEvent.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Comparer Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEvent Class : Comparer Field

Glossary Item Box

Used to compare IpcEvent instances by name

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Comparer As IComparer
C#
public static readonly IComparer Comparer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEvent Class
IpcEvent Members

Source Code

Library/IpcChannel/IpcEvent.cs

Used By

IpcEventChannel.RaiseLocal(String,String[])


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
IpcEvent Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEvent Class

Glossary Item Box

For a list of all members of this type, see IpcEvent members.

Public Events

 | Name | Description
Public Event | OnEvent | Allows you to subscribe or unsubscribe to the event
Top

See Also

Reference

IpcEvent Class
CSharpTest.Net.IpcChannel Namespace
IpcEvent IpcEventChannel.Item

Source Code

Library/IpcChannel/IpcEvent.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnEvent Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEvent Class : OnEvent Event

Glossary Item Box

Allows you to subscribe or unsubscribe to the event

Syntax

Visual Basic (Declaration)
Public Event OnEvent As EventHandler(Of IpcSignalEventArgs)
C#
public event EventHandler<IpcSignalEventArgs> OnEvent

Event Data

The event handler receives an argument of type IpcSignalEventArgs containing data related to this event. The following IpcSignalEventArgs properties provide information specific to this event.

Property | Description
Arguments | Gets any arguments sent with the event
EventChannel | Gets the channel rasing the event
EventName | Gets the name of the event

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEvent Class
IpcEvent Members

Source Code

Library/IpcChannel/IpcEvent.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpcEventChannel Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEventChannel Class

Glossary Item Box

Provides a means to send and recieve events (optionally with arguments) across thread/process boundaries to a group of listeners of an event channel. Subscribe to desired events, call Start/StopListening, or just send events to other listeners on the same channel name. Provides the implmentation to send an event message to a group of instances

Object Model

IpcEventChannel ClassIpcEvent ClassIIpcChannelRegistrar Interface

Syntax

Visual Basic (Declaration)
Public Class IpcEventChannel
C#
public class IpcEventChannel

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.IpcChannel.IpcEventChannel

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Members
CSharpTest.Net.IpcChannel Namespace
IpcEventChannel IpcSignalEventArgs.EventChannel

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IpcEventChannel Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEventChannel Class

Glossary Item Box

The following tables list the members exposed by IpcEventChannel.

Public Constructors

 | Name | Description
Public Constructor | IpcEventChannel Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | ChannelName | Returns the channel name of this instance
Public Property | DefaultTimeout | Gets/Sets the number of milliseconds to wait when starting/stopping threads or waiting for a known state
Public Property | ExecutionTimeout | Gets/Sets the number of milliseconds to wait for an event to complete processing
Public Property | InCall | Returns true if the current thread is processing an event
Public Property | InstanceId | Returns the identity of this channel when listening
Public Property | Item | Registers/Gets an IpcEvent instance for the specified event name
Public Property | Registrar | Returns the storage registrar of this channel
Top

Public Methods

 | Name | Description
Public Method | Broadcast | Overloaded. Sends the event to all channel subscribers
Public Method | Dispose | Disposes of all resources used by this channel
Public Method | EnableAsyncSend | Enables a background worker thread to continue sending messages that are incomplete after the expiration of the timeout specified in the Broadcast/SendTo method. This is required to avoid dead-locks if your broadcasting messages within an IpcEvent.OnEvent event handler.
Public Method | GetEvents | Returns an enumeration of all known events of this instance
Public Method | RaiseLocal | Synchronously dispatches the event to this instance's subscribers
Public Method | SendTo | Overloaded. Sends the event to all channel subscribers with the given identity or name (case-insensitive)
Public Method | StartListening | Overloaded. Starts listening for events being posted to this channel on a new thread
Public Method | StopAsyncSending | Shutsdown the worker thread created by a call to EnableAsyncSend() allowing up to the number of milliseconds in timeout to shutdown the worker and complete any pending work. If timeout is 0, the worker will be aborted.
Public Method | StopListening | Overloaded. Stops listening to incoming events on the channel
Top

Public Events

 | Name | Description
Public Event | OnError | Raised when an event subscriber does not handle an exception
Public Event | OnModified | Raised when the collection of event names changes
Top

See Also

Reference

IpcEventChannel Class
CSharpTest.Net.IpcChannel Namespace
IpcEventChannel IpcSignalEventArgs.EventChannel

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpcEventChannel Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : IpcEventChannel Constructor

Glossary Item Box

Overload List

Overload | Description
IpcEventChannel Constructor(String,String) | Creates an IpcEventChannel that persists state in Registry.LocalMachine at hklmKeyPath + channelName
IpcEventChannel Constructor(IIpcChannelRegistrar,String) | Creates an IpcEventChannel that persists state in IChannelRegistrar provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members


%%PageItemTitle%%

[image]
CSharpTest.Net
IpcEventChannel Constructor(String,String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > IpcEventChannel Constructor : IpcEventChannel Constructor(String,String)

hkcuKeyPath
The registry current-user path to all channels ex: @"Software\MyProduct\IpcChannels"
channelName
The name of the channel to subscribe or send events to

Glossary Item Box

Creates an IpcEventChannel that persists state in Registry.LocalMachine at hklmKeyPath + channelName

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal hkcuKeyPath As String, _
   ByVal channelName As String _
)
C#
public IpcEventChannel(
   string hkcuKeyPath,
   string channelName
)

Parameters

hkcuKeyPath
The registry current-user path to all channels ex: @"Software\MyProduct\IpcChannels"
channelName
The name of the channel to subscribe or send events to

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel ch1 = new IpcEventChannel(@"CSharpTest.Net\IpcChannelTest", _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(@"CSharpTest.Net\IpcChannelTest", _channel))
{
    Assert.AreNotEqual(ch1.InstanceId, ch2.InstanceId);
}
VB.NET Copy Code
Using ch1 As New IpcEventChannel("CSharpTest.Net\IpcChannelTest", _channel)
    Using ch2 As New IpcEventChannel("CSharpTest.Net\IpcChannelTest", _channel)
        Assert.AreNotEqual(ch1.InstanceId, ch2.InstanceId)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpcEventChannel Constructor(IIpcChannelRegistrar,String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > IpcEventChannel Constructor : IpcEventChannel Constructor(IIpcChannelRegistrar,String)

registrar
The serialization provider for registration
channelName
The name of the channel to subscribe or send events to

Glossary Item Box

Creates an IpcEventChannel that persists state in IChannelRegistrar provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal registrar As IIpcChannelRegistrar, _
   ByVal channelName As String _
)
C#
public IpcEventChannel(
   IIpcChannelRegistrar registrar,
   string channelName
)

Parameters

registrar
The serialization provider for registration
channelName
The name of the channel to subscribe or send events to

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IpcEventChannel Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEventChannel Class

Glossary Item Box

For a list of all members of this type, see IpcEventChannel members.

Public Methods

 | Name | Description
Public Method | Broadcast | Overloaded. Sends the event to all channel subscribers
Public Method | Dispose | Disposes of all resources used by this channel
Public Method | EnableAsyncSend | Enables a background worker thread to continue sending messages that are incomplete after the expiration of the timeout specified in the Broadcast/SendTo method. This is required to avoid dead-locks if your broadcasting messages within an IpcEvent.OnEvent event handler.
Public Method | GetEvents | Returns an enumeration of all known events of this instance
Public Method | RaiseLocal | Synchronously dispatches the event to this instance's subscribers
Public Method | SendTo | Overloaded. Sends the event to all channel subscribers with the given identity or name (case-insensitive)
Public Method | StartListening | Overloaded. Starts listening for events being posted to this channel on a new thread
Public Method | StopAsyncSending | Shutsdown the worker thread created by a call to EnableAsyncSend() allowing up to the number of milliseconds in timeout to shutdown the worker and complete any pending work. If timeout is 0, the worker will be aborted.
Public Method | StopListening | Overloaded. Stops listening to incoming events on the channel
Top

See Also

Reference

IpcEventChannel Class
CSharpTest.Net.IpcChannel Namespace
IpcEventChannel IpcSignalEventArgs.EventChannel

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Broadcast Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : Broadcast Method

Glossary Item Box

Sends the event to all channel subscribers

Overload List

Overload | Description
Broadcast(String,String[]) | Sends the event to all channel subscribers
Broadcast(Int32,String,String[]) | Sends the event to all channel subscribers, waiting at most waitTime

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Broadcast(String,String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > Broadcast Method : Broadcast(String,String[]) Method

eventName
arguments

Glossary Item Box

Sends the event to all channel subscribers

Syntax

Visual Basic (Declaration)
Public Overloads Function Broadcast( _
   ByVal eventName As String, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int Broadcast(
   string eventName,
   params string[] arguments
)

Parameters

eventName
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Source Code

Library/IpcChannel/IpcEventSender.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Broadcast(Int32,String,String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > Broadcast Method : Broadcast(Int32,String,String[]) Method

waitTime
eventName
arguments

Glossary Item Box

Sends the event to all channel subscribers, waiting at most waitTime

Syntax

Visual Basic (Declaration)
Public Overloads Function Broadcast( _
   ByVal waitTime As Integer, _
   ByVal eventName As String, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int Broadcast(
   int waitTime,
   string eventName,
   params string[] arguments
)

Parameters

waitTime
eventName
arguments

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");

    ManualResetEvent ready = new ManualResetEvent(false);
    ManualResetEvent die = new ManualResetEvent(false);
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e)
    {
        ready.Set();
        die.WaitOne();
        Thread.CurrentThread.Abort();
    };

    sender.Broadcast(100, "Message");
    Assert.IsTrue(ready.WaitOne(1000, false));

    sender.EnableAsyncSend();
    sender.Broadcast(0, "Message");
    die.Set();
    sender.StopAsyncSending(true, 1000);
    ch1.StopListening();
}
VB.NET Copy Code
Using ch1 As New IpcEventChannel(_registrar, _channel)
    Using sender As New IpcEventChannel(_registrar, _channel)
        ch1.StartListening("ch1")

        Dim ready As New ManualResetEvent(False)
        Dim die As New ManualResetEvent(False)
        ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
            ready.[Set]()
            die.WaitOne()
            Thread.CurrentThread.Abort()
        End Function

        sender.Broadcast(100, "Message")
        Assert.IsTrue(ready.WaitOne(1000, False))

        sender.EnableAsyncSend()
        sender.Broadcast(0, "Message")
        die.[Set]()
        sender.StopAsyncSending(True, 1000)
        ch1.StopListening()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Used By

Int32 IpcEventChannel.Broadcast(String,String[])

Source Code

Library/IpcChannel/IpcEventSender.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : Dispose Method

Glossary Item Box

Disposes of all resources used by this channel

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EnableAsyncSend Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : EnableAsyncSend Method

Glossary Item Box

Enables a background worker thread to continue sending messages that are incomplete after the expiration of the timeout specified in the Broadcast/SendTo method. This is required to avoid dead-locks if your broadcasting messages within an IpcEvent.OnEvent event handler.

Syntax

Visual Basic (Declaration)
Public Sub EnableAsyncSend()
C#
public void EnableAsyncSend()

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");

    ManualResetEvent ready = new ManualResetEvent(false);
    ManualResetEvent die = new ManualResetEvent(false);
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e)
    {
        ready.Set();
        die.WaitOne();
        Thread.CurrentThread.Abort();
    };

    sender.Broadcast(100, "Message");
    Assert.IsTrue(ready.WaitOne(1000, false));

    sender.EnableAsyncSend();
    sender.Broadcast(0, "Message");
    die.Set();
    sender.StopAsyncSending(true, 1000);
    ch1.StopListening();
}
VB.NET Copy Code
Using ch1 As New IpcEventChannel(_registrar, _channel)
    Using sender As New IpcEventChannel(_registrar, _channel)
        ch1.StartListening("ch1")

        Dim ready As New ManualResetEvent(False)
        Dim die As New ManualResetEvent(False)
        ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
            ready.[Set]()
            die.WaitOne()
            Thread.CurrentThread.Abort()
        End Function

        sender.Broadcast(100, "Message")
        Assert.IsTrue(ready.WaitOne(1000, False))

        sender.EnableAsyncSend()
        sender.Broadcast(0, "Message")
        die.[Set]()
        sender.StopAsyncSending(True, 1000)
        ch1.StopListening()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventSender.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEvents Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : GetEvents Method

Glossary Item Box

Returns an enumeration of all known events of this instance

Syntax

Visual Basic (Declaration)
Public Function GetEvents() As IEnumerable(Of IpcEvent)
C#
public IEnumerable<IpcEvent> GetEvents()

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel channel = new IpcEventChannel(_registrar, _channel))
{
    Assert.AreEqual("Test", channel["Test"].LocalName);
    Assert.AreEqual("TEST", channel["TEST"].LocalName);
    Assert.AreEqual("test", channel["test"].LocalName);

    int count = 0;
    foreach (IpcEvent e in channel.GetEvents())
    {
        Assert.AreEqual("test", e.LocalName.ToLower());
        count++;
    }
    Assert.AreEqual(3, count);
}
VB.NET Copy Code
Using channel As New IpcEventChannel(_registrar, _channel)
    Assert.AreEqual("Test", channel("Test").LocalName)
    Assert.AreEqual("TEST", channel("TEST").LocalName)
    Assert.AreEqual("test", channel("test").LocalName)

    Dim count As Integer = 0
    For Each e As IpcEvent In channel.GetEvents()
        Assert.AreEqual("test", e.LocalName.ToLower())
        System.Math.Max(System.Threading.Interlocked.Increment(count),count - 1)
    Next
    Assert.AreEqual(3, count)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RaiseLocal Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : RaiseLocal Method

eventName
args

Glossary Item Box

Synchronously dispatches the event to this instance's subscribers

Syntax

Visual Basic (Declaration)
Public Sub RaiseLocal( _
   ByVal eventName As String, _
   ByVal ParamArray args() As String _
)
C#
public void RaiseLocal(
   string eventName,
   params string[] args
)

Parameters

eventName
args

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
    ch1.RaiseLocal("UnknownName");
VB.NET Copy Code
Using ch1 As New IpcEventChannel(_registrar, _channel)
    ch1.RaiseLocal("UnknownName")
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SendTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : SendTo Method

Glossary Item Box

Sends the event to all channel subscribers with the given identity or name (case-insensitive)

Overload List

Overload | Description
SendTo(String,String,String[]) | Sends the event to all channel subscribers with the given identity or name (case-insensitive)
SendTo(Int32,String,String,String[]) | Sends the event to all channel subscribers with the given identity or name (case-insensitive)
SendTo(IEnumerable<String>,String,String[]) | Sends the event to the specified list of instance identities or names (case-insensitive)
SendTo(Int32,IEnumerable<String>,String,String[]) | Sends the event to the specified list of instance identities or names (case-insensitive)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SendTo(String,String,String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > SendTo Method : SendTo(String,String,String[]) Method

instance
eventName
arguments

Glossary Item Box

Sends the event to all channel subscribers with the given identity or name (case-insensitive)

Syntax

Visual Basic (Declaration)
Public Overloads Function SendTo( _
   ByVal instance As String, _
   ByVal eventName As String, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int SendTo(
   string instance,
   string eventName,
   params string[] arguments
)

Parameters

instance
eventName
arguments

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Source Code

Library/IpcChannel/IpcEventSender.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SendTo(Int32,String,String,String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > SendTo Method : SendTo(Int32,String,String,String[]) Method

waitTime
instance
eventName
arguments

Glossary Item Box

Sends the event to all channel subscribers with the given identity or name (case-insensitive)

Syntax

Visual Basic (Declaration)
Public Overloads Function SendTo( _
   ByVal waitTime As Integer, _
   ByVal instance As String, _
   ByVal eventName As String, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int SendTo(
   int waitTime,
   string instance,
   string eventName,
   params string[] arguments
)

Parameters

waitTime
instance
eventName
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Used By

Int32 IpcEventChannel.SendTo(String,String,String[])

Source Code

Library/IpcChannel/IpcEventSender.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SendTo(IEnumerable<String>,String,String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > SendTo Method : SendTo(IEnumerable<String>,String,String[]) Method

instances
eventName
arguments

Glossary Item Box

Sends the event to the specified list of instance identities or names (case-insensitive)

Syntax

Visual Basic (Declaration)
Public Overloads Function SendTo( _
   ByVal instances As IEnumerable(Of String), _
   ByVal eventName As String, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int SendTo(
   IEnumerable<string> instances,
   string eventName,
   params string[] arguments
)

Parameters

instances
eventName
arguments

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Source Code

Library/IpcChannel/IpcEventSender.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SendTo(Int32,IEnumerable<String>,String,String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > SendTo Method : SendTo(Int32,IEnumerable<String>,String,String[]) Method

waitTime
instances
eventName
arguments

Glossary Item Box

Sends the event to the specified list of instance identities or names (case-insensitive)

Syntax

Visual Basic (Declaration)
Public Overloads Function SendTo( _
   ByVal waitTime As Integer, _
   ByVal instances As IEnumerable(Of String), _
   ByVal eventName As String, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int SendTo(
   int waitTime,
   IEnumerable<string> instances,
   string eventName,
   params string[] arguments
)

Parameters

waitTime
instances
eventName
arguments

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Used By

Int32 IpcEventChannel.SendTo(IEnumerable,String,String[])

Source Code

Library/IpcChannel/IpcEventSender.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StartListening Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : StartListening Method

Glossary Item Box

Starts listening for events being posted to this channel on a new thread

Overload List

Overload | Description
StartListening() | Starts listening for events being posted to this channel on a new thread
StartListening(String) | Same as StartListening but specifies a name that can be used to lookup this instance

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members


%%PageItemTitle%%

[image]
CSharpTest.Net
StartListening() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > StartListening Method : StartListening() Method

Glossary Item Box

Starts listening for events being posted to this channel on a new thread

Syntax

Visual Basic (Declaration)
Public Overloads Sub StartListening()
C#
public void StartListening()

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel channel = new IpcEventChannel(_registrar, _channel))
{
    channel.StartListening();
    channel.StopListening();
    channel.StartListening();
    channel.StopListening();
}
VB.NET Copy Code
Using channel As New IpcEventChannel(_registrar, _channel)
    channel.StartListening()
    channel.StopListening()
    channel.StartListening()
    channel.StopListening()
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StartListening(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > StartListening Method : StartListening(String) Method

instanceName

Glossary Item Box

Same as StartListening but specifies a name that can be used to lookup this instance

Syntax

Visual Basic (Declaration)
Public Overloads Sub StartListening( _
   ByVal instanceName As String _
)
C#
public void StartListening(
   string instanceName
)

Parameters

instanceName

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Used By

IpcEventChannel.StartListening()

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StopAsyncSending Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : StopAsyncSending Method

completeWork
timeout

Glossary Item Box

Shutsdown the worker thread created by a call to EnableAsyncSend() allowing up to the number of milliseconds in timeout to shutdown the worker and complete any pending work. If timeout is 0, the worker will be aborted.

Syntax

Visual Basic (Declaration)
Public Sub StopAsyncSending( _
   ByVal completeWork As Boolean, _
   ByVal timeout As Integer _
)
C#
public void StopAsyncSending(
   bool completeWork,
   int timeout
)

Parameters

completeWork
timeout

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");

    ManualResetEvent ready = new ManualResetEvent(false);
    ManualResetEvent die = new ManualResetEvent(false);
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e)
    {
        ready.Set();
        die.WaitOne();
        Thread.CurrentThread.Abort();
    };

    sender.Broadcast(100, "Message");
    Assert.IsTrue(ready.WaitOne(1000, false));

    sender.EnableAsyncSend();
    sender.Broadcast(0, "Message");
    die.Set();
    sender.StopAsyncSending(true, 1000);
    ch1.StopListening();
}
VB.NET Copy Code
Using ch1 As New IpcEventChannel(_registrar, _channel)
    Using sender As New IpcEventChannel(_registrar, _channel)
        ch1.StartListening("ch1")

        Dim ready As New ManualResetEvent(False)
        Dim die As New ManualResetEvent(False)
        ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
            ready.[Set]()
            die.WaitOne()
            Thread.CurrentThread.Abort()
        End Function

        sender.Broadcast(100, "Message")
        Assert.IsTrue(ready.WaitOne(1000, False))

        sender.EnableAsyncSend()
        sender.Broadcast(0, "Message")
        die.[Set]()
        sender.StopAsyncSending(True, 1000)
        ch1.StopListening()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventSender.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StopListening Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : StopListening Method

Glossary Item Box

Stops listening to incoming events on the channel

Overload List

Overload | Description
StopListening() | Stops listening to incoming events on the channel
StopListening(Int32) | Stops listening to incoming events on the channel

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members


%%PageItemTitle%%

[image]
CSharpTest.Net
StopListening() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > StopListening Method : StopListening() Method

Glossary Item Box

Stops listening to incoming events on the channel

Syntax

Visual Basic (Declaration)
Public Overloads Sub StopListening()
C#
public void StopListening()

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StopListening(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class > StopListening Method : StopListening(Int32) Method

timeout

Glossary Item Box

Stops listening to incoming events on the channel

Syntax

Visual Basic (Declaration)
Public Overloads Sub StopListening( _
   ByVal timeout As Integer _
)
C#
public void StopListening(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
Overload List

Used By

IpcEventChannel.Dispose()
IpcEventChannel.StopListening()

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IpcEventChannel Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEventChannel Class

Glossary Item Box

For a list of all members of this type, see IpcEventChannel members.

Public Properties

 | Name | Description
Public Property | ChannelName | Returns the channel name of this instance
Public Property | DefaultTimeout | Gets/Sets the number of milliseconds to wait when starting/stopping threads or waiting for a known state
Public Property | ExecutionTimeout | Gets/Sets the number of milliseconds to wait for an event to complete processing
Public Property | InCall | Returns true if the current thread is processing an event
Public Property | InstanceId | Returns the identity of this channel when listening
Public Property | Item | Registers/Gets an IpcEvent instance for the specified event name
Public Property | Registrar | Returns the storage registrar of this channel
Top

See Also

Reference

IpcEventChannel Class
CSharpTest.Net.IpcChannel Namespace
IpcEventChannel IpcSignalEventArgs.EventChannel

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ChannelName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : ChannelName Property

Glossary Item Box

Returns the channel name of this instance

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ChannelName As String
C#
public string ChannelName {get;}

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel channel = new IpcEventChannel(_registrar, _channel))
    Assert.AreEqual(_channel, channel.ChannelName);
VB.NET Copy Code
Using channel As New IpcEventChannel(_registrar, _channel)
    Assert.AreEqual(_channel, channel.ChannelName)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Used By

Int32 IpcEventChannel.Broadcast(Int32,String,String[])
Int32 IpcEventChannel.SendTo(Int32,String,String,String[])
Int32 IpcEventChannel.SendTo(Int32,IEnumerable,String,String[])

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultTimeout Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : DefaultTimeout Property

Glossary Item Box

Gets/Sets the number of milliseconds to wait when starting/stopping threads or waiting for a known state

Syntax

Visual Basic (Declaration)
Public Property DefaultTimeout As Integer
C#
public int DefaultTimeout {get; set;}

Example

channel.DefaultTimeout = 60000;

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Used By

IpcEventChannel.StopListening()

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExecutionTimeout Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : ExecutionTimeout Property

Glossary Item Box

Gets/Sets the number of milliseconds to wait for an event to complete processing

Syntax

Visual Basic (Declaration)
Public Property ExecutionTimeout As Integer
C#
public int ExecutionTimeout {get; set;}

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Used By

Int32 IpcEventChannel.Broadcast(String,String[])
Int32 IpcEventChannel.SendTo(String,String,String[])
Int32 IpcEventChannel.SendTo(IEnumerable,String,String[])

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InCall Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : InCall Property

Glossary Item Box

Returns true if the current thread is processing an event

Syntax

Visual Basic (Declaration)
Public ReadOnly Property InCall As Boolean
C#
public bool InCall {get;}

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel channel = new IpcEventChannel(_registrar, _channel))
    Assert.IsFalse(channel.InCall);
VB.NET Copy Code
Using channel As New IpcEventChannel(_registrar, _channel)
    Assert.IsFalse(channel.InCall)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InstanceId Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : InstanceId Property

Glossary Item Box

Returns the identity of this channel when listening

Syntax

Visual Basic (Declaration)
Public ReadOnly Property InstanceId As String
C#
public string InstanceId {get;}

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel ch1 = new IpcEventChannel(@"CSharpTest.Net\IpcChannelTest", _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(@"CSharpTest.Net\IpcChannelTest", _channel))
{
    Assert.AreNotEqual(ch1.InstanceId, ch2.InstanceId);
}
VB.NET Copy Code
Using ch1 As New IpcEventChannel("CSharpTest.Net\IpcChannelTest", _channel)
    Using ch2 As New IpcEventChannel("CSharpTest.Net\IpcChannelTest", _channel)
        Assert.AreNotEqual(ch1.InstanceId, ch2.InstanceId)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : Item Property

name

Glossary Item Box

Registers/Gets an IpcEvent instance for the specified event name

Syntax

Visual Basic (Declaration)
Public ReadOnly Default Property Item( _
   ByVal name As String _
) As IpcEvent
C#
public IpcEvent this[
   string name
]; {get;}

Parameters

name

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel sender = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch1 = new IpcEventChannel(_registrar, _channel))
using (IpcEventChannel ch2 = new IpcEventChannel(_registrar, _channel))
{
    ch1.StartListening("ch1");
    ch2.StartListening("ch2");

    int ch1Count = 0, ch2Count = 0;
    ch1["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch1Count++; };
    ch2["Message"].OnEvent += delegate(object o, IpcSignalEventArgs e) { ch2Count++; };

    sender.ExecutionTimeout = 1000;
    Assert.AreEqual(1, sender.SendTo("CH1", "Message"));
    Assert.AreEqual(1, sender.SendTo(new string[] { "CH2" }, "Message"));
    Assert.AreEqual(2, sender.SendTo(1000, new string[] { "ch1", "ch2" }, "Message"));

    ch1.StopListening();
    Assert.AreEqual(2, ch1Count);
    ch2.StopListening();
    Assert.AreEqual(2, ch2Count);
}
VB.NET Copy Code
Using sender As New IpcEventChannel(_registrar, _channel)
    Using ch1 As New IpcEventChannel(_registrar, _channel)
        Using ch2 As New IpcEventChannel(_registrar, _channel)
            ch1.StartListening("ch1")
            ch2.StartListening("ch2")

            Dim ch1Count As Integer = 0, ch2Count As Integer = 0
            ch1("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch1Count),ch1Count - 1)
            End Function
            ch2("Message").OnEvent += Function(o As Object, e As IpcSignalEventArgs) Do
                System.Math.Max(System.Threading.Interlocked.Increment(ch2Count),ch2Count - 1)
            End Function

            sender.ExecutionTimeout = 1000
            Assert.AreEqual(1, sender.SendTo("CH1", "Message"))
            Assert.AreEqual(1, sender.SendTo(New String() {"CH2"}, "Message"))
            Assert.AreEqual(2, sender.SendTo(1000, New String() {"ch1", "ch2"}, "Message"))

            ch1.StopListening()
            Assert.AreEqual(2, ch1Count)
            ch2.StopListening()
            Assert.AreEqual(2, ch2Count)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
IpcEvent

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Registrar Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : Registrar Property

Glossary Item Box

Returns the storage registrar of this channel

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Registrar As IIpcChannelRegistrar
C#
public IIpcChannelRegistrar Registrar {get;}

Example

Library/Library.Test/TestIpcChannel.cs

C# Copy Code
using (IpcEventChannel channel = new IpcEventChannel(_registrar, _channel))
    Assert.IsTrue(ReferenceEquals(_registrar, channel.Registrar));
VB.NET Copy Code
Using channel As New IpcEventChannel(_registrar, _channel)
    Assert.IsTrue(ReferenceEquals(_registrar, channel.Registrar))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members
IIpcChannelRegistrar

Used By

Int32 IpcEventChannel.Broadcast(Int32,String,String[])
Int32 IpcEventChannel.SendTo(Int32,String,String,String[])
Int32 IpcEventChannel.SendTo(Int32,IEnumerable,String,String[])

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
IpcEventChannel Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcEventChannel Class

Glossary Item Box

For a list of all members of this type, see IpcEventChannel members.

Public Events

 | Name | Description
Public Event | OnError | Raised when an event subscriber does not handle an exception
Public Event | OnModified | Raised when the collection of event names changes
Top

See Also

Reference

IpcEventChannel Class
CSharpTest.Net.IpcChannel Namespace
IpcEventChannel IpcSignalEventArgs.EventChannel

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnError Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : OnError Event

Glossary Item Box

Raised when an event subscriber does not handle an exception

Syntax

Visual Basic (Declaration)
Public Event OnError As ErrorEventHandler
C#
public event ErrorEventHandler OnError

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnModified Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcEventChannel Class : OnModified Event

Glossary Item Box

Raised when the collection of event names changes

Syntax

Visual Basic (Declaration)
Public Event OnModified As EventHandler
C#
public event EventHandler OnModified

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcEventChannel Class
IpcEventChannel Members

Source Code

Library/IpcChannel/IpcEventChannel.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpcSignalEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcSignalEventArgs Class

Glossary Item Box

Represents an event raised by the IpcEventChannel to subscribers.

Object Model

IpcSignalEventArgs ClassIpcEventChannel Class

Syntax

Visual Basic (Declaration)
Public Class IpcSignalEventArgs
   Inherits System.EventArgs
C#
public class IpcSignalEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.IpcChannel.IpcSignalEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcSignalEventArgs Members
CSharpTest.Net.IpcChannel Namespace

Source Code

Library/IpcChannel/IpcSignalEventArgs.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IpcSignalEventArgs Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcSignalEventArgs Class

Glossary Item Box

The following tables list the members exposed by IpcSignalEventArgs.

Public Properties

 | Name | Description
Public Property | Arguments | Gets any arguments sent with the event
Public Property | EventChannel | Gets the channel rasing the event
Public Property | EventName | Gets the name of the event
Top

See Also

Reference

IpcSignalEventArgs Class
CSharpTest.Net.IpcChannel Namespace

Source Code

Library/IpcChannel/IpcSignalEventArgs.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IpcSignalEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IpcSignalEventArgs Class

Glossary Item Box

For a list of all members of this type, see IpcSignalEventArgs members.

Public Properties

 | Name | Description
Public Property | Arguments | Gets any arguments sent with the event
Public Property | EventChannel | Gets the channel rasing the event
Public Property | EventName | Gets the name of the event
Top

See Also

Reference

IpcSignalEventArgs Class
CSharpTest.Net.IpcChannel Namespace

Source Code

Library/IpcChannel/IpcSignalEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Arguments Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcSignalEventArgs Class : Arguments Property

Glossary Item Box

Gets any arguments sent with the event

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Arguments As String()
C#
public string[] Arguments {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcSignalEventArgs Class
IpcSignalEventArgs Members

Source Code

Library/IpcChannel/IpcSignalEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventChannel Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcSignalEventArgs Class : EventChannel Property

Glossary Item Box

Gets the channel rasing the event

Syntax

Visual Basic (Declaration)
Public ReadOnly Property EventChannel As IpcEventChannel
C#
public IpcEventChannel EventChannel {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcSignalEventArgs Class
IpcSignalEventArgs Members
IpcEventChannel

Source Code

Library/IpcChannel/IpcSignalEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IpcSignalEventArgs Class : EventName Property

Glossary Item Box

Gets the name of the event

Syntax

Visual Basic (Declaration)
Public ReadOnly Property EventName As String
C#
public string EventName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IpcSignalEventArgs Class
IpcSignalEventArgs Members

Source Code

Library/IpcChannel/IpcSignalEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IIpcChannelRegistrar Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IIpcChannelRegistrar Interface

Glossary Item Box

Interface to provide a means of channel member registration and cross-process serialization of arguments for specific events. Implementations must be thread-safe even across process boundaries.

Syntax

Visual Basic (Declaration)
Public Interface IIpcChannelRegistrar
C#
public interface IIpcChannelRegistrar

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Members
CSharpTest.Net.IpcChannel Namespace
IIpcChannelRegistrar IpcEventChannel.Registrar

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IIpcChannelRegistrar Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IIpcChannelRegistrar Interface

Glossary Item Box

The following tables list the members exposed by IIpcChannelRegistrar.

Public Methods

 | Name | Description
Method | GetRegisteredInstances | Overloaded. Enumerates the registered instanceIds for the provided channel name
Method | ReadParameters | Retreives the arguments for the event being sent to the specified instance
Method | RegisterInstance | Registers a member (instanceId) for the provided channel name
Method | UnregisterInstance | Unregisters a member (instanceId) from the provided channel name
Method | WriteParameters | Serializes the arguments for the event being sent to the specified instance
Top

See Also

Reference

IIpcChannelRegistrar Interface
CSharpTest.Net.IpcChannel Namespace
IIpcChannelRegistrar IpcEventChannel.Registrar

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IIpcChannelRegistrar Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace : IIpcChannelRegistrar Interface

Glossary Item Box

For a list of all members of this type, see IIpcChannelRegistrar members.

Public Methods

 | Name | Description
Method | GetRegisteredInstances | Overloaded. Enumerates the registered instanceIds for the provided channel name
Method | ReadParameters | Retreives the arguments for the event being sent to the specified instance
Method | RegisterInstance | Registers a member (instanceId) for the provided channel name
Method | UnregisterInstance | Unregisters a member (instanceId) from the provided channel name
Method | WriteParameters | Serializes the arguments for the event being sent to the specified instance
Top

See Also

Reference

IIpcChannelRegistrar Interface
CSharpTest.Net.IpcChannel Namespace
IIpcChannelRegistrar IpcEventChannel.Registrar

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetRegisteredInstances Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IIpcChannelRegistrar Interface : GetRegisteredInstances Method

Glossary Item Box

Enumerates the registered instanceIds for the provided channel name

Overload List

Overload | Description
GetRegisteredInstances(String) | Enumerates the registered instanceIds for the provided channel name
GetRegisteredInstances(String,String) | Enumerates the registered instanceIds who's name is instanceName for the provided channel name
GetRegisteredInstances(String,IEnumerable<String>) | Enumerates the registered instanceIds who's name is instanceName for the provided channel name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Interface
IIpcChannelRegistrar Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetRegisteredInstances(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IIpcChannelRegistrar Interface > GetRegisteredInstances Method : GetRegisteredInstances(String) Method

channelName

Glossary Item Box

Enumerates the registered instanceIds for the provided channel name

Syntax

Visual Basic (Declaration)
Overloads Function GetRegisteredInstances( _
   ByVal channelName As String _
) As IEnumerable(Of String)
C#
IEnumerable<string> GetRegisteredInstances(
   string channelName
)

Parameters

channelName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Interface
IIpcChannelRegistrar Members
Overload List

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs

Used By

Int32 IpcEventChannel.Broadcast(Int32,String,String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
GetRegisteredInstances(String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IIpcChannelRegistrar Interface > GetRegisteredInstances Method : GetRegisteredInstances(String,String) Method

channelName
instanceName

Glossary Item Box

Enumerates the registered instanceIds who's name is instanceName for the provided channel name

Syntax

Visual Basic (Declaration)
Overloads Function GetRegisteredInstances( _
   ByVal channelName As String, _
   ByVal instanceName As String _
) As IEnumerable(Of String)
C#
IEnumerable<string> GetRegisteredInstances(
   string channelName,
   string instanceName
)

Parameters

channelName
instanceName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Interface
IIpcChannelRegistrar Members
Overload List

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs

Used By

Int32 IpcEventChannel.SendTo(Int32,String,String,String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
GetRegisteredInstances(String,IEnumerable<String>) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IIpcChannelRegistrar Interface > GetRegisteredInstances Method : GetRegisteredInstances(String,IEnumerable<String>) Method

channelName
instanceNames

Glossary Item Box

Enumerates the registered instanceIds who's name is instanceName for the provided channel name

Syntax

Visual Basic (Declaration)
Overloads Function GetRegisteredInstances( _
   ByVal channelName As String, _
   ByVal instanceNames As IEnumerable(Of String) _
) As IEnumerable(Of String)
C#
IEnumerable<string> GetRegisteredInstances(
   string channelName,
   IEnumerable<string> instanceNames
)

Parameters

channelName
instanceNames

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Interface
IIpcChannelRegistrar Members
Overload List

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs

Used By

Int32 IpcEventChannel.SendTo(Int32,IEnumerable,String,String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadParameters Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IIpcChannelRegistrar Interface : ReadParameters Method

channelName
instanceId
eventName

Glossary Item Box

Retreives the arguments for the event being sent to the specified instance

Syntax

Visual Basic (Declaration)
Function ReadParameters( _
   ByVal channelName As String, _
   ByVal instanceId As String, _
   ByVal eventName As String _
) As String()
C#
string[] ReadParameters(
   string channelName,
   string instanceId,
   string eventName
)

Parameters

channelName
instanceId
eventName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Interface
IIpcChannelRegistrar Members

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegisterInstance Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IIpcChannelRegistrar Interface : RegisterInstance Method

channelName
instanceId
instanceName

Glossary Item Box

Registers a member (instanceId) for the provided channel name

Syntax

Visual Basic (Declaration)
Sub RegisterInstance( _
   ByVal channelName As String, _
   ByVal instanceId As String, _
   ByVal instanceName As String _
)
C#
void RegisterInstance(
   string channelName,
   string instanceId,
   string instanceName
)

Parameters

channelName
instanceId
instanceName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Interface
IIpcChannelRegistrar Members

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UnregisterInstance Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IIpcChannelRegistrar Interface : UnregisterInstance Method

channelName
instanceId

Glossary Item Box

Unregisters a member (instanceId) from the provided channel name

Syntax

Visual Basic (Declaration)
Sub UnregisterInstance( _
   ByVal channelName As String, _
   ByVal instanceId As String _
)
C#
void UnregisterInstance(
   string channelName,
   string instanceId
)

Parameters

channelName
instanceId

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Interface
IIpcChannelRegistrar Members

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteParameters Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IpcChannel Namespace > IIpcChannelRegistrar Interface : WriteParameters Method

channelName
instanceId
eventName
arguments

Glossary Item Box

Serializes the arguments for the event being sent to the specified instance

Syntax

Visual Basic (Declaration)
Function WriteParameters( _
   ByVal channelName As String, _
   ByVal instanceId As String, _
   ByVal eventName As String, _
   ByVal arguments() As String _
) As Boolean
C#
bool WriteParameters(
   string channelName,
   string instanceId,
   string eventName,
   string[] arguments
)

Parameters

channelName
instanceId
eventName
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IIpcChannelRegistrar Interface
IIpcChannelRegistrar Members

Source Code

Library/IpcChannel/IIpcChannelRegistrar.cs


%%ItemTitle%%

CSharpTest.Net.Processes Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Processes Namespace

Glossary Item Box

Classes

 | Class | Description
Class | AssemblyRunner | Create an AppDomain configured to run the .Net Assembly provided and marshalls Console input/output to and from the app domain when run. This allow a more performant execution of .Net command-line tools while keeping with *most* of the behavior of running out-of-process. Some serious side effects can occur when using Environment.* settings like CurrentDirectory and ExitCode since these are shared with the appdomain.
Class | ProcessExitedEventArgs | Carries the exit code of the exited process.
Class | ProcessOutputEventArgs | The event args that contains information about the line of text written to either std::out or std::in on the created process.
Class | ProcessRunner | Creates/Spawns a process with the standard error/out/in all mapped. Subscribe to the OutputReceived event prior to start/run to listen to the program output, write to the StandardInput for input.
Class | ScriptEngine | Defines the information needed to run various types of scripts on a Windows host
Class | ScriptRunner | Defines a way to run scripts as an external process and capture their output.

Interfaces

 | Interface | Description
Interface | IRunner | The common interface between spawning processes, and spawning scripts.

Delegates

 | Delegate | Description
Delegate | ProcessExitedEventHandler | Raised when a process started with the ProcessRunner exits
Delegate | ProcessOutputEventHandler | A delegate that handles the write to either std::out or std::in for a process

Enumerations

 | Enumeration | Description
Enumeration | ScriptEngine.Language | Defines the languages we know how to run, or 'Other' when user-defined
Enumeration | ScriptEngine.Options | Options for script execution

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
AssemblyRunner Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : AssemblyRunner Class

Glossary Item Box

Create an AppDomain configured to run the .Net Assembly provided and marshalls Console input/output to and from the app domain when run. This allow a more performant execution of .Net command-line tools while keeping with *most* of the behavior of running out-of-process. Some serious side effects can occur when using Environment.* settings like CurrentDirectory and ExitCode since these are shared with the appdomain.

Syntax

Visual Basic (Declaration)
Public Class AssemblyRunner
   Implements IRunner
C#
public class AssemblyRunner : IRunner

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    ManualResetEvent gotExit = new ManualResetEvent(false);
    runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("-wait");
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start();
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(gotExit.WaitOne(30000, false));
}
VB.NET Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))

Using runner As New AssemblyRunner(Exe)
    Dim gotExit As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As [Object], e As ProcessExitedEventArgs) Do
        gotExit.[Set]()
    End Function
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("-wait")
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start()
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(gotExit.WaitOne(30000, False))
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Processes.AssemblyRunner

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Members
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AssemblyRunner Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : AssemblyRunner Class

Glossary Item Box

The following tables list the members exposed by AssemblyRunner.

Public Constructors

 | Name | Description
Public Constructor | AssemblyRunner Constructor | Constructs the AppDomain for the given executable by using it's path for the base directory and configuraiton file.
Top

Public Properties

 | Name | Description
Public Property | ExitCode | Waits for the process to exit and returns the exit code
Public Property | IsDisposed | Returns true if this object's worker domain has been unloaded.
Public Property | IsRunning | Returns true if this instance is running a process
Public Property | WorkingDirectory | Gets or sets the initial working directory for the process.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Kill | Kills the process if it is still running
Public Method | Run | Overloaded. Runs the process and returns the exit code.
Public Method | Start | Overloaded. Starts the process and returns.
Public Method | ToString | Returns a debug-view string of process/arguments to execute
Public Method | WaitForExit | Overloaded. Closes std::in and waits for the process to exit
Top

Protected Methods

 | Name | Description
Protected Method | Finalize | Ensures clean-up of the app domain... This has to be pushed off of the GC Cleanup thread as AppDoamin.Unload will fail on GC thread.
Top

Public Events

 | Name | Description
Public Event | OutputReceived | Notifies caller of writes to the std::err or std::out
Public Event | ProcessExited | Notifies caller when the process exits
Top

See Also

Reference

AssemblyRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AssemblyRunner Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : AssemblyRunner Constructor

executable

Glossary Item Box

Constructs the AppDomain for the given executable by using it's path for the base directory and configuraiton file.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal executable As String _
)
C#
public AssemblyRunner(
   string executable
)

Parameters

executable

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    ManualResetEvent gotExit = new ManualResetEvent(false);
    runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("-wait");
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start();
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(gotExit.WaitOne(30000, false));
}
VB.NET Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))

Using runner As New AssemblyRunner(Exe)
    Dim gotExit As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As [Object], e As ProcessExitedEventArgs) Do
        gotExit.[Set]()
    End Function
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("-wait")
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start()
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(gotExit.WaitOne(30000, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AssemblyRunner Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : AssemblyRunner Class

Glossary Item Box

For a list of all members of this type, see AssemblyRunner members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Kill | Kills the process if it is still running
Public Method | Run | Overloaded. Runs the process and returns the exit code.
Public Method | Start | Overloaded. Starts the process and returns.
Public Method | ToString | Returns a debug-view string of process/arguments to execute
Public Method | WaitForExit | Overloaded. Closes std::in and waits for the process to exit
Top

Protected Methods

 | Name | Description
Protected Method | Finalize | Ensures clean-up of the app domain... This has to be pushed off of the GC Cleanup thread as AppDoamin.Unload will fail on GC thread.
Top

See Also

Reference

AssemblyRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Overridable Sub Dispose()
C#
public virtual void Dispose()

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
AssemblyRunner runner = new AssemblyRunner(Exe);
runner.Dispose();
Assert.IsTrue(runner.IsDisposed);
VB.NET Copy Code
Dim runner As New AssemblyRunner(Exe)
runner.Dispose()
Assert.IsTrue(runner.IsDisposed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Finalize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : Finalize Method

Glossary Item Box

Ensures clean-up of the app domain... This has to be pushed off of the GC Cleanup thread as AppDoamin.Unload will fail on GC thread.

Syntax

Visual Basic (Declaration)
Protected Overrides Sub Finalize()
C#
protected override void Finalize()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Base Implementation in Finalize


%%PageItemTitle%%

[image]
CSharpTest.Net
Kill Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : Kill Method

Glossary Item Box

Kills the process if it is still running

Syntax

Visual Basic (Declaration)
Public Sub Kill()
C#
public void Kill()

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    ManualResetEvent gotExit = new ManualResetEvent(false);
    runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("-wait");
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start();
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(gotExit.WaitOne(30000, false));
}
VB.NET Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))

Using runner As New AssemblyRunner(Exe)
    Dim gotExit As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As [Object], e As ProcessExitedEventArgs) Do
        gotExit.[Set]()
    End Function
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("-wait")
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start()
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(gotExit.WaitOne(30000, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Used By

AssemblyRunner.Dispose()

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : Run Method

Glossary Item Box

Runs the process and returns the exit code.

Overload List

Overload | Description
Run() | Runs the process and returns the exit code.
Run(String[]) | Runs the process with additional arguments and returns the exit code.
Run(TextReader,String[]) | Runs the process with additional arguments and returns the exit code.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Run() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > Run Method : Run() Method

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run() As Integer
C#
public int Run()

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    int exitCode = -1;
    bool receivedExit = false;
    ProcessExitedEventHandler handler =
            delegate(object o, ProcessExitedEventArgs e)
            { receivedExit = true; exitCode = e.ExitCode; };

    runner.ProcessExited += handler;
    runner.ProcessExited -= handler;

    Assert.AreEqual(0, runner.Run());
    Assert.IsFalse(receivedExit);
    Assert.AreEqual(-1, exitCode);
}
VB.NET Copy Code
Using runner As New AssemblyRunner(Exe)
    Dim exitCode As Integer = -1
    Dim receivedExit As Boolean = False
    Dim handler As ProcessExitedEventHandler = Function(o As Object, e As ProcessExitedEventArgs) Do
        receivedExit = True
        exitCode = e.ExitCode
    End Function

    runner.ProcessExited += handler
    runner.ProcessExited -= handler

    Assert.AreEqual(0, runner.Run())
    Assert.IsFalse(receivedExit)
    Assert.AreEqual(-1, exitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > Run Method : Run(String[]) Method

arguments

Glossary Item Box

Runs the process with additional arguments and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run( _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int Run(
   params string[] arguments
)

Parameters

arguments

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    StringWriter wtr = new StringWriter();
    StringWriter err = new StringWriter();
    ProcessOutputEventHandler handler =
            delegate(object o, ProcessOutputEventArgs e)
            { if (e.Error) err.WriteLine(e.Data); else wtr.WriteLine(e.Data); };

    runner.OutputReceived += handler;

    Assert.AreEqual(1, runner.Run("command-line-argrument"));
    Assert.AreEqual("std-err", err.ToString().Trim());

    StringReader rdr = new StringReader(wtr.ToString());
    Assert.AreEqual("WorkingDirectory = " + Environment.CurrentDirectory, rdr.ReadLine());
    Assert.AreEqual("argument[0] = command-line-argrument", rdr.ReadLine());
    Assert.AreEqual("std-input:", rdr.ReadLine());
    Assert.AreEqual(null, rdr.ReadLine());
}
VB.NET Copy Code
Using runner As New AssemblyRunner(Exe)
    Dim wtr As New StringWriter()
    Dim err As New StringWriter()
    Dim handler As ProcessOutputEventHandler = Function(o As Object, e As ProcessOutputEventArgs) Do
        If e.[Error] Then
            err.WriteLine(e.Data)
        Else
            wtr.WriteLine(e.Data)
        End If
    End Function

    runner.OutputReceived += handler

    Assert.AreEqual(1, runner.Run("command-line-argrument"))
    Assert.AreEqual("std-err", err.ToString().Trim())

    Dim rdr As New StringReader(wtr.ToString())
    Assert.AreEqual("WorkingDirectory = " + Environment.CurrentDirectory, rdr.ReadLine())
    Assert.AreEqual("argument[0] = command-line-argrument", rdr.ReadLine())
    Assert.AreEqual("std-input:", rdr.ReadLine())
    Assert.AreEqual(Nothing, rdr.ReadLine())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Used By

Int32 AssemblyRunner.Run()

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(TextReader,String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > Run Method : Run(TextReader,String[]) Method

input
arguments

Glossary Item Box

Runs the process with additional arguments and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run( _
   ByVal input As TextReader, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int Run(
   TextReader input,
   params string[] arguments
)

Parameters

input
arguments

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };
    int exitCode = runner.Run(new StringReader("Hello World\r\nWhatever!\r\nAnother line."));
    Assert.AreEqual(0, exitCode);

    // 0 == WorkingDirectory =
    // 1 == std-input:
    Assert.AreEqual("Hello World", lines[2]);
    Assert.AreEqual("Whatever!", lines[3]);
    Assert.AreEqual("Another line.", lines[4]);
}
VB.NET Copy Code
Using runner As New AssemblyRunner(Exe)
    Dim lines As New List(Of String)()
    runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
        lines.Add(e.Data)
    End Function
    Dim exitCode As Integer = runner.Run(New StringReader("Hello World" & vbCr & vbLf & "Whatever!" & vbCr & vbLf & "Another line."))
    Assert.AreEqual(0, exitCode)

    ' 0 == WorkingDirectory =
    ' 1 == std-input:
    Assert.AreEqual("Hello World", lines(2))
    Assert.AreEqual("Whatever!", lines(3))
    Assert.AreEqual("Another line.", lines(4))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Used By

Int32 AssemblyRunner.Run(String[])

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : Start Method

Glossary Item Box

Starts the process and returns.

Overload List

Overload | Description
Start() | Starts the process and returns.
Start(String[]) | Starts the process with additional arguments and returns.
Start(TextReader,String[]) | Starts the process with additional arguments and returns.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Start() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > Start Method : Start() Method

Glossary Item Box

Starts the process and returns.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Start()
C#
public void Start()

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    ManualResetEvent gotExit = new ManualResetEvent(false);
    runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("-wait");
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start();
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(gotExit.WaitOne(30000, false));
}
VB.NET Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))

Using runner As New AssemblyRunner(Exe)
    Dim gotExit As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As [Object], e As ProcessExitedEventArgs) Do
        gotExit.[Set]()
    End Function
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("-wait")
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start()
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(gotExit.WaitOne(30000, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start(String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > Start Method : Start(String[]) Method

arguments

Glossary Item Box

Starts the process with additional arguments and returns.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Start( _
   ByVal ParamArray arguments() As String _
)
C#
public void Start(
   params string[] arguments
)

Parameters

arguments

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    ManualResetEvent gotExit = new ManualResetEvent(false);
    runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("-wait");
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start();
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(gotExit.WaitOne(30000, false));
}
VB.NET Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))

Using runner As New AssemblyRunner(Exe)
    Dim gotExit As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As [Object], e As ProcessExitedEventArgs) Do
        gotExit.[Set]()
    End Function
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("-wait")
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start()
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(gotExit.WaitOne(30000, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Used By

AssemblyRunner.Start()

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start(TextReader,String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > Start Method : Start(TextReader,String[]) Method

input
arguments

Glossary Item Box

Starts the process with additional arguments and returns.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Start( _
   ByVal input As TextReader, _
   ByVal ParamArray arguments() As String _
)
C#
public void Start(
   TextReader input,
   params string[] arguments
)

Parameters

input
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Used By

AssemblyRunner.Start(String[])

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : ToString Method

Glossary Item Box

Returns a debug-view string of process/arguments to execute

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Base Implementation in ToString

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : WaitForExit Method

Glossary Item Box

Closes std::in and waits for the process to exit

Overload List

Overload | Description
WaitForExit() | Closes std::in and waits for the process to exit
WaitForExit(TimeSpan) | Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given
WaitForExit(TimeSpan,Boolean) | Waits for the process to exit, returns false if the process did not exit in the time given

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > WaitForExit Method : WaitForExit() Method

Glossary Item Box

Closes std::in and waits for the process to exit

Syntax

Visual Basic (Declaration)
Public Overloads Sub WaitForExit()
C#
public void WaitForExit()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit(TimeSpan) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > WaitForExit Method : WaitForExit(TimeSpan) Method

timeout

Glossary Item Box

Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given

Syntax

Visual Basic (Declaration)
Public Overloads Function WaitForExit( _
   ByVal timeout As TimeSpan _
) As Boolean
C#
public bool WaitForExit(
   TimeSpan timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Used By

AssemblyRunner.Kill()

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit(TimeSpan,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > WaitForExit Method : WaitForExit(TimeSpan,Boolean) Method

timeout
closeStdInput

Glossary Item Box

Waits for the process to exit, returns false if the process did not exit in the time given

Syntax

Visual Basic (Declaration)
Public Overloads Function WaitForExit( _
   ByVal timeout As TimeSpan, _
   ByVal closeStdInput As Boolean _
) As Boolean
C#
public bool WaitForExit(
   TimeSpan timeout,
   bool closeStdInput
)

Parameters

timeout
closeStdInput

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    ManualResetEvent gotExit = new ManualResetEvent(false);
    runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("-wait");
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start();
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(gotExit.WaitOne(30000, false));
}
VB.NET Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))

Using runner As New AssemblyRunner(Exe)
    Dim gotExit As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As [Object], e As ProcessExitedEventArgs) Do
        gotExit.[Set]()
    End Function
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("-wait")
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start()
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(gotExit.WaitOne(30000, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members
Overload List

Used By

AssemblyRunner.WaitForExit()
Boolean AssemblyRunner.WaitForExit(TimeSpan)

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
AssemblyRunner Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : AssemblyRunner Class

Glossary Item Box

For a list of all members of this type, see AssemblyRunner members.

Public Properties

 | Name | Description
Public Property | ExitCode | Waits for the process to exit and returns the exit code
Public Property | IsDisposed | Returns true if this object's worker domain has been unloaded.
Public Property | IsRunning | Returns true if this instance is running a process
Public Property | WorkingDirectory | Gets or sets the initial working directory for the process.
Top

See Also

Reference

AssemblyRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExitCode Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : ExitCode Property

Glossary Item Box

Waits for the process to exit and returns the exit code

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ExitCode As Integer
C#
public int ExitCode {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Used By

Int32 AssemblyRunner.Run(TextReader,String[])

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsDisposed Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : IsDisposed Property

Glossary Item Box

Returns true if this object's worker domain has been unloaded.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsDisposed As Boolean
C#
public bool IsDisposed {get;}

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
AssemblyRunner runner = new AssemblyRunner(Exe);
runner.Dispose();
Assert.IsTrue(runner.IsDisposed);
VB.NET Copy Code
Dim runner As New AssemblyRunner(Exe)
runner.Dispose()
Assert.IsTrue(runner.IsDisposed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsRunning Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : IsRunning Property

Glossary Item Box

Returns true if this instance is running a process

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsRunning As Boolean
C#
public bool IsRunning {get;}

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    ManualResetEvent gotExit = new ManualResetEvent(false);
    runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("-wait");
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start();
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(gotExit.WaitOne(30000, false));
}
VB.NET Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))

Using runner As New AssemblyRunner(Exe)
    Dim gotExit As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As [Object], e As ProcessExitedEventArgs) Do
        gotExit.[Set]()
    End Function
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("-wait")
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start()
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(gotExit.WaitOne(30000, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WorkingDirectory Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : WorkingDirectory Property

Glossary Item Box

Gets or sets the initial working directory for the process.

Syntax

Visual Basic (Declaration)
Public Property WorkingDirectory As String
C#
public string WorkingDirectory {get; set;}

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
using (TempDirectory dir = new TempDirectory())
using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };

    Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory);
    runner.WorkingDirectory = dir.TempPath;
    Assert.AreEqual(dir.TempPath, runner.WorkingDirectory);

    int exitCode = runner.Run();
    Assert.AreEqual(0, exitCode);
    Assert.AreEqual("WorkingDirectory = " + dir.TempPath, lines[0]);
}
VB.NET Copy Code
Using dir As New TempDirectory()
    Using runner As New AssemblyRunner(Exe)
        Dim lines As New List(Of String)()
        runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
            lines.Add(e.Data)
        End Function

        Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory)
        runner.WorkingDirectory = dir.TempPath
        Assert.AreEqual(dir.TempPath, runner.WorkingDirectory)

        Dim exitCode As Integer = runner.Run()
        Assert.AreEqual(0, exitCode)
        Assert.AreEqual("WorkingDirectory = " + dir.TempPath, lines(0))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
AssemblyRunner Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : AssemblyRunner Class

Glossary Item Box

For a list of all members of this type, see AssemblyRunner members.

Public Events

 | Name | Description
Public Event | OutputReceived | Notifies caller of writes to the std::err or std::out
Public Event | ProcessExited | Notifies caller when the process exits
Top

See Also

Reference

AssemblyRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OutputReceived Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : OutputReceived Event

Glossary Item Box

Notifies caller of writes to the std::err or std::out

Syntax

Visual Basic (Declaration)
Public Event OutputReceived As ProcessOutputEventHandler
C#
public event ProcessOutputEventHandler OutputReceived

Event Data

The event handler receives an argument of type ProcessOutputEventArgs containing data related to this event. The following ProcessOutputEventArgs properties provide information specific to this event.

Property | Description
Data | Returns the line of text written to standard out/error
Error | Returns true if the line of text was written to std::error

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
using (TempDirectory dir = new TempDirectory())
using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };

    Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory);
    runner.WorkingDirectory = dir.TempPath;
    Assert.AreEqual(dir.TempPath, runner.WorkingDirectory);

    int exitCode = runner.Run();
    Assert.AreEqual(0, exitCode);
    Assert.AreEqual("WorkingDirectory = " + dir.TempPath, lines[0]);
}
VB.NET Copy Code
Using dir As New TempDirectory()
    Using runner As New AssemblyRunner(Exe)
        Dim lines As New List(Of String)()
        runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
            lines.Add(e.Data)
        End Function

        Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory)
        runner.WorkingDirectory = dir.TempPath
        Assert.AreEqual(dir.TempPath, runner.WorkingDirectory)

        Dim exitCode As Integer = runner.Run()
        Assert.AreEqual(0, exitCode)
        Assert.AreEqual("WorkingDirectory = " + dir.TempPath, lines(0))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessExited Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : ProcessExited Event

Glossary Item Box

Notifies caller when the process exits

Syntax

Visual Basic (Declaration)
Public Event ProcessExited As ProcessExitedEventHandler
C#
public event ProcessExitedEventHandler ProcessExited

Event Data

The event handler receives an argument of type ProcessExitedEventArgs containing data related to this event. The following ProcessExitedEventArgs properties provide information specific to this event.

Property | Description
ExitCode | Returns the environment exit code of the process

Example

Library/Library.Test/TestAssemblyRunner.cs

C# Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));

using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    ManualResetEvent gotExit = new ManualResetEvent(false);
    runner.ProcessExited += delegate(Object o, ProcessExitedEventArgs e) { gotExit.Set(); };
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("-wait");
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start();
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(gotExit.WaitOne(30000, false));
}
VB.NET Copy Code
Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))

Using runner As New AssemblyRunner(Exe)
    Dim gotExit As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As [Object], e As ProcessExitedEventArgs) Do
        gotExit.[Set]()
    End Function
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("-wait")
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start()
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(gotExit.WaitOne(30000, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AssemblyRunner Class
AssemblyRunner Members

Source Code

Library/Processes/AssemblyRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessExitedEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessExitedEventArgs Class

Glossary Item Box

Carries the exit code of the exited process.

Syntax

Visual Basic (Declaration)
Public Class ProcessExitedEventArgs
   Inherits System.EventArgs
C#
public class ProcessExitedEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Processes.ProcessExitedEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessExitedEventArgs Members
CSharpTest.Net.Processes Namespace
ProcessExitedEventHandler.Invoke(Object,ProcessExitedEventArgs)
IAsyncResult ProcessExitedEventHandler.BeginInvoke(Object,ProcessExitedEventArgs,AsyncCallback,Object)

Source Code

Library/Processes/ProcessExitedEventArgs.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ProcessExitedEventArgs Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessExitedEventArgs Class

Glossary Item Box

The following tables list the members exposed by ProcessExitedEventArgs.

Public Properties

 | Name | Description
Public Property | ExitCode | Returns the environment exit code of the process
Top

See Also

Reference

ProcessExitedEventArgs Class
CSharpTest.Net.Processes Namespace
ProcessExitedEventHandler.Invoke(Object,ProcessExitedEventArgs)
IAsyncResult ProcessExitedEventHandler.BeginInvoke(Object,ProcessExitedEventArgs,AsyncCallback,Object)

Source Code

Library/Processes/ProcessExitedEventArgs.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ProcessExitedEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessExitedEventArgs Class

Glossary Item Box

For a list of all members of this type, see ProcessExitedEventArgs members.

Public Properties

 | Name | Description
Public Property | ExitCode | Returns the environment exit code of the process
Top

See Also

Reference

ProcessExitedEventArgs Class
CSharpTest.Net.Processes Namespace
ProcessExitedEventHandler.Invoke(Object,ProcessExitedEventArgs)
IAsyncResult ProcessExitedEventHandler.BeginInvoke(Object,ProcessExitedEventArgs,AsyncCallback,Object)

Source Code

Library/Processes/ProcessExitedEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExitCode Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessExitedEventArgs Class : ExitCode Property

Glossary Item Box

Returns the environment exit code of the process

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ExitCode As Integer
C#
public int ExitCode {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessExitedEventArgs Class
ProcessExitedEventArgs Members

Source Code

Library/Processes/ProcessExitedEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessOutputEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessOutputEventArgs Class

Glossary Item Box

The event args that contains information about the line of text written to either std::out or std::in on the created process.

Syntax

Visual Basic (Declaration)
Public NotInheritable Class ProcessOutputEventArgs
   Inherits System.EventArgs
C#
public sealed class ProcessOutputEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Processes.ProcessOutputEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessOutputEventArgs Members
CSharpTest.Net.Processes Namespace
ProcessOutputEventHandler.Invoke(Object,ProcessOutputEventArgs)
IAsyncResult ProcessOutputEventHandler.BeginInvoke(Object,ProcessOutputEventArgs,AsyncCallback,Object)

Source Code

Library/Processes/ProcessOutputEventArgs.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ProcessOutputEventArgs Class Members
See Also Properties Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessOutputEventArgs Class

Glossary Item Box

The following tables list the members exposed by ProcessOutputEventArgs.

Public Properties

 | Name | Description
Public Property | Data | Returns the line of text written to standard out/error
Public Property | Error | Returns true if the line of text was written to std::error
Top

See Also

Reference

ProcessOutputEventArgs Class
CSharpTest.Net.Processes Namespace
ProcessOutputEventHandler.Invoke(Object,ProcessOutputEventArgs)
IAsyncResult ProcessOutputEventHandler.BeginInvoke(Object,ProcessOutputEventArgs,AsyncCallback,Object)

Source Code

Library/Processes/ProcessOutputEventArgs.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ProcessOutputEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessOutputEventArgs Class

Glossary Item Box

For a list of all members of this type, see ProcessOutputEventArgs members.

Public Properties

 | Name | Description
Public Property | Data | Returns the line of text written to standard out/error
Public Property | Error | Returns true if the line of text was written to std::error
Top

See Also

Reference

ProcessOutputEventArgs Class
CSharpTest.Net.Processes Namespace
ProcessOutputEventHandler.Invoke(Object,ProcessOutputEventArgs)
IAsyncResult ProcessOutputEventHandler.BeginInvoke(Object,ProcessOutputEventArgs,AsyncCallback,Object)

Source Code

Library/Processes/ProcessOutputEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Data Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessOutputEventArgs Class : Data Property

Glossary Item Box

Returns the line of text written to standard out/error

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Data As String
C#
public string Data {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessOutputEventArgs Class
ProcessOutputEventArgs Members

Source Code

Library/Processes/ProcessOutputEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Error Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessOutputEventArgs Class : Error Property

Glossary Item Box

Returns true if the line of text was written to std::error

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Error As Boolean
C#
public bool Error {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessOutputEventArgs Class
ProcessOutputEventArgs Members

Source Code

Library/Processes/ProcessOutputEventArgs.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessRunner Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessRunner Class

Glossary Item Box

Creates/Spawns a process with the standard error/out/in all mapped. Subscribe to the OutputReceived event prior to start/run to listen to the program output, write to the StandardInput for input.

Syntax

Visual Basic (Declaration)
Public Class ProcessRunner
   Implements IRunner
C#
public class ProcessRunner : IRunner

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));
    ProcessRunner runner = new ProcessRunner("cmd.exe");
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("/K", "ECHO Hello > " + tempfile);
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start("/C", "ECHO", "HELO");
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))
    Dim runner As New ProcessRunner("cmd.exe")
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("/K", "ECHO Hello > " + tempfile)
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start("/C", "ECHO", "HELO")
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.Processes.ProcessRunner

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Members
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ProcessRunner Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessRunner Class

Glossary Item Box

The following tables list the members exposed by ProcessRunner.

Public Constructors

 | Name | Description
Public Constructor | ProcessRunner Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | ExitCode | Waits for the process to exit and returns the exit code
Public Property | IsRunning | Returns true if this instance is running a process
Public Property | PID | Returns the remote process Id
Public Property | StandardInput | Allows writes to the std::in for the process
Public Property | WorkingDirectory | Gets or sets the initial working directory for the process.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Detaches event handlers and closes input streams
Public Method | Kill | Kills the process if it is still running
Public Method | Run | Overloaded. Runs the process and returns the exit code.
Public Method | RunFormatArgs | Calls String.Format() for each argument this runner was constructed with giving the object array as the arguments. Once complete it runs the process with the new set of arguments and returns the exit code.
Public Method | Start | Overloaded. Starts the process and returns.
Public Method | StartFormatArgs | Calls String.Format() for each argument this runner was constructed with giving the object array as the arguments. Once complete it starts the process with the new set of arguments and returns.
Public Method | ToString | Returns a debug-view string of process/arguments to execute
Public Method | WaitForExit | Overloaded. Closes std::in and waits for the process to exit
Top

Public Events

 | Name | Description
Public Event | OutputReceived | Notifies caller of writes to the std::err or std::out
Public Event | ProcessExited | Notifies caller when the process exits
Top

See Also

Reference

ProcessRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessRunner Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : ProcessRunner Constructor

Glossary Item Box

Overload List

Overload | Description
ProcessRunner Constructor(String) | Creates a ProcessRunner for the given executable
ProcessRunner Constructor(String,String[]) | Creates a ProcessRunner for the given executable and arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessRunner Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > ProcessRunner Constructor : ProcessRunner Constructor(String)

executable

Glossary Item Box

Creates a ProcessRunner for the given executable

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal executable As String _
)
C#
public ProcessRunner(
   string executable
)

Parameters

executable

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));
    ProcessRunner runner = new ProcessRunner("cmd.exe");
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("/K", "ECHO Hello > " + tempfile);
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start("/C", "ECHO", "HELO");
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))
    Dim runner As New ProcessRunner("cmd.exe")
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("/K", "ECHO Hello > " + tempfile)
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start("/C", "ECHO", "HELO")
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessRunner Constructor(String,String[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > ProcessRunner Constructor : ProcessRunner Constructor(String,String[])

executable
args

Glossary Item Box

Creates a ProcessRunner for the given executable and arguments

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal executable As String, _
   ByVal ParamArray args() As String _
)
C#
public ProcessRunner(
   string executable,
   params string[] args
)

Parameters

executable
args

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}");

    runner.StartFormatArgs(tempfile);
    Assert.AreEqual(0, runner.ExitCode);

    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);

    File.Delete(tempfile);
    Assert.AreEqual(0, runner.RunFormatArgs(tempfile));

    output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Dim runner As New ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}")

    runner.StartFormatArgs(tempfile)
    Assert.AreEqual(0, runner.ExitCode)

    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)

    File.Delete(tempfile)
    Assert.AreEqual(0, runner.RunFormatArgs(tempfile))

    output = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Used By

TestResXtoMc.TestBuildMcFromResX()

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ProcessRunner Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessRunner Class

Glossary Item Box

For a list of all members of this type, see ProcessRunner members.

Public Methods

 | Name | Description
Public Method | Dispose | Detaches event handlers and closes input streams
Public Method | Kill | Kills the process if it is still running
Public Method | Run | Overloaded. Runs the process and returns the exit code.
Public Method | RunFormatArgs | Calls String.Format() for each argument this runner was constructed with giving the object array as the arguments. Once complete it runs the process with the new set of arguments and returns the exit code.
Public Method | Start | Overloaded. Starts the process and returns.
Public Method | StartFormatArgs | Calls String.Format() for each argument this runner was constructed with giving the object array as the arguments. Once complete it starts the process with the new set of arguments and returns.
Public Method | ToString | Returns a debug-view string of process/arguments to execute
Public Method | WaitForExit | Overloaded. Closes std::in and waits for the process to exit
Top

See Also

Reference

ProcessRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : Dispose Method

Glossary Item Box

Detaches event handlers and closes input streams

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Kill Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : Kill Method

Glossary Item Box

Kills the process if it is still running

Syntax

Visual Basic (Declaration)
Public Sub Kill()
C#
public void Kill()

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));
    ProcessRunner runner = new ProcessRunner("cmd.exe");
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("/K", "ECHO Hello > " + tempfile);
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start("/C", "ECHO", "HELO");
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))
    Dim runner As New ProcessRunner("cmd.exe")
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("/K", "ECHO Hello > " + tempfile)
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start("/C", "ECHO", "HELO")
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs

Used By

ScriptRunner.Kill()


%%PageItemTitle%%

[image]
CSharpTest.Net
Run Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : Run Method

Glossary Item Box

Runs the process and returns the exit code.

Overload List

Overload | Description
Run() | Runs the process and returns the exit code.
Run(String[]) | Runs the process with additional arguments and returns the exit code.
Run(TextReader,String[]) | Runs the process with additional arguments and returns the exit code.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Run() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > Run Method : Run() Method

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run() As Integer
C#
public int Run()

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
using (TempDirectory dir = new TempDirectory())
using (ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "echo CD"))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };

    Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory);
    runner.WorkingDirectory = dir.TempPath;
    Assert.AreEqual(dir.TempPath, runner.WorkingDirectory);

    int exitCode = runner.Run();
    Assert.AreEqual(0, exitCode);
    Assert.AreEqual(dir.TempPath.TrimEnd('\\', '/'), lines[0].TrimEnd('\\', '/'));
}
VB.NET Copy Code
Using dir As New TempDirectory()
    Using runner As New ProcessRunner("cmd.exe", "/C", "echo CD")
        Dim lines As New List(Of String)()
        runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
            lines.Add(e.Data)
        End Function

        Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory)
        runner.WorkingDirectory = dir.TempPath
        Assert.AreEqual(dir.TempPath, runner.WorkingDirectory)

        Dim exitCode As Integer = runner.Run()
        Assert.AreEqual(0, exitCode)
        Assert.AreEqual(dir.TempPath.TrimEnd("\"C, "/"C), lines(0).TrimEnd("\"C, "/"C))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > Run Method : Run(String[]) Method

moreArguments

Glossary Item Box

Runs the process with additional arguments and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run( _
   ByVal ParamArray moreArguments() As String _
) As Integer
C#
public int Run(
   params string[] moreArguments
)

Parameters

moreArguments

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
using (ProcessRunner runner = new ProcessRunner("cmd.exe"))
{
    StringWriter wtr = new StringWriter();
    StringWriter err = new StringWriter();
    ProcessOutputEventHandler handler =
            delegate(object o, ProcessOutputEventArgs e)
            { if (e.Error) err.WriteLine(e.Data); else wtr.WriteLine(e.Data); };

    runner.OutputReceived += handler;

    Assert.AreEqual(0, runner.Run("/C", "dir", "/b", "/on", "/ad-h-s", "c:\\"));
    Assert.AreEqual(String.Empty, err.ToString());

    Assert.AreNotEqual(0, runner.PID);

    StringReader rdr = new StringReader(wtr.ToString());
    List<DirectoryInfo> rootdirs = new List<DirectoryInfo>(new DirectoryInfo("C:\\").GetDirectories());
    rootdirs.Sort(delegate(DirectoryInfo x, DirectoryInfo y) { return StringComparer.OrdinalIgnoreCase.Compare(x.Name, y.Name); });
    foreach (DirectoryInfo di in rootdirs)
    {
        if ((di.Attributes & (FileAttributes.Hidden | FileAttributes.System)) != 0)
            continue;
        Assert.AreEqual(di.Name, rdr.ReadLine());
    }

    Assert.AreEqual(null, rdr.ReadLine());
}
VB.NET Copy Code
Using runner As New ProcessRunner("cmd.exe")
    Dim wtr As New StringWriter()
    Dim err As New StringWriter()
    Dim handler As ProcessOutputEventHandler = Function(o As Object, e As ProcessOutputEventArgs) Do
        If e.[Error] Then
            err.WriteLine(e.Data)
        Else
            wtr.WriteLine(e.Data)
        End If
    End Function

    runner.OutputReceived += handler

    Assert.AreEqual(0, runner.Run("/C", "dir", "/b", "/on", "/ad-h-s", "c:\"))
    Assert.AreEqual([String].Empty, err.ToString())

    Assert.AreNotEqual(0, runner.PID)

    Dim rdr As New StringReader(wtr.ToString())
    Dim rootdirs As New List(Of DirectoryInfo)(New DirectoryInfo("C:\").GetDirectories())
    rootdirs.Sort(Function(x As DirectoryInfo, y As DirectoryInfo) Do
        Return StringComparer.OrdinalIgnoreCase.Compare(x.Name, y.Name)
    End Function)
    For Each di As DirectoryInfo In rootdirs
        If (di.Attributes And (FileAttributes.Hidden Or FileAttributes.System)) <> 0 Then
            Continue For
        End If
        Assert.AreEqual(di.Name, rdr.ReadLine())
    Next

    Assert.AreEqual(Nothing, rdr.ReadLine())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(TextReader,String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > Run Method : Run(TextReader,String[]) Method

input
arguments

Glossary Item Box

Runs the process with additional arguments and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run( _
   ByVal input As TextReader, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int Run(
   TextReader input,
   params string[] arguments
)

Parameters

input
arguments

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
using (ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "sort"))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };
    int exitCode = runner.Run(new StringReader("Hello World\r\nWhatever!\r\nA line that goes first."));
    Assert.AreEqual(0, exitCode);
    Assert.AreEqual("A line that goes first.", lines[0]);
    Assert.AreEqual("Hello World", lines[1]);
    Assert.AreEqual("Whatever!", lines[2]);
}
VB.NET Copy Code
Using runner As New ProcessRunner("cmd.exe", "/C", "sort")
    Dim lines As New List(Of String)()
    runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
        lines.Add(e.Data)
    End Function
    Dim exitCode As Integer = runner.Run(New StringReader("Hello World" & vbCr & vbLf & "Whatever!" & vbCr & vbLf & "A line that goes first."))
    Assert.AreEqual(0, exitCode)
    Assert.AreEqual("A line that goes first.", lines(0))
    Assert.AreEqual("Hello World", lines(1))
    Assert.AreEqual("Whatever!", lines(2))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Used By

Int32 ProcessRunner.Run()
Int32 ProcessRunner.Run(String[])
Int32 ScriptRunner.Run(TextReader,String[])

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RunFormatArgs Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : RunFormatArgs Method

formatArgs

Glossary Item Box

Calls String.Format() for each argument this runner was constructed with giving the object array as the arguments. Once complete it runs the process with the new set of arguments and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Function RunFormatArgs( _
   ByVal ParamArray formatArgs() As Object _
) As Integer
C#
public int RunFormatArgs(
   params object[] formatArgs
)

Parameters

formatArgs

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}");

    runner.StartFormatArgs(tempfile);
    Assert.AreEqual(0, runner.ExitCode);

    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);

    File.Delete(tempfile);
    Assert.AreEqual(0, runner.RunFormatArgs(tempfile));

    output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Dim runner As New ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}")

    runner.StartFormatArgs(tempfile)
    Assert.AreEqual(0, runner.ExitCode)

    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)

    File.Delete(tempfile)
    Assert.AreEqual(0, runner.RunFormatArgs(tempfile))

    output = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Used By

TestResXtoMc.TestBuildMcFromResX()

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : Start Method

Glossary Item Box

Starts the process and returns.

Overload List

Overload | Description
Start() | Starts the process and returns.
Start(String[]) | Starts the process with additional arguments and returns.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Start() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > Start Method : Start() Method

Glossary Item Box

Starts the process and returns.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Start()
C#
public void Start()

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    ProcessRunner runner = new ProcessRunner("cmd.exe");

    runner.Start();
    runner.StandardInput.WriteLine("ECHO Hello > " + tempfile);
    runner.StandardInput.WriteLine("EXIT");

    Assert.IsTrue(runner.WaitForExit(TimeSpan.FromMinutes(1)));
    Assert.AreEqual(0, runner.ExitCode);

    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Dim runner As New ProcessRunner("cmd.exe")

    runner.Start()
    runner.StandardInput.WriteLine("ECHO Hello > " + tempfile)
    runner.StandardInput.WriteLine("EXIT")

    Assert.IsTrue(runner.WaitForExit(TimeSpan.FromMinutes(1)))
    Assert.AreEqual(0, runner.ExitCode)

    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start(String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > Start Method : Start(String[]) Method

moreArguments

Glossary Item Box

Starts the process with additional arguments and returns.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Start( _
   ByVal ParamArray moreArguments() As String _
)
C#
public void Start(
   params string[] moreArguments
)

Parameters

moreArguments

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));
    ProcessRunner runner = new ProcessRunner("cmd.exe");
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("/K", "ECHO Hello > " + tempfile);
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start("/C", "ECHO", "HELO");
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))
    Dim runner As New ProcessRunner("cmd.exe")
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("/K", "ECHO Hello > " + tempfile)
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start("/C", "ECHO", "HELO")
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Used By

ProcessRunner.Start()
ScriptRunner.Start(String[])

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StartFormatArgs Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : StartFormatArgs Method

formatArgs

Glossary Item Box

Calls String.Format() for each argument this runner was constructed with giving the object array as the arguments. Once complete it starts the process with the new set of arguments and returns.

Syntax

Visual Basic (Declaration)
Public Sub StartFormatArgs( _
   ByVal ParamArray formatArgs() As Object _
)
C#
public void StartFormatArgs(
   params object[] formatArgs
)

Parameters

formatArgs

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}");

    runner.StartFormatArgs(tempfile);
    Assert.AreEqual(0, runner.ExitCode);

    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);

    File.Delete(tempfile);
    Assert.AreEqual(0, runner.RunFormatArgs(tempfile));

    output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Dim runner As New ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}")

    runner.StartFormatArgs(tempfile)
    Assert.AreEqual(0, runner.ExitCode)

    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)

    File.Delete(tempfile)
    Assert.AreEqual(0, runner.RunFormatArgs(tempfile))

    output = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : ToString Method

Glossary Item Box

Returns a debug-view string of process/arguments to execute

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Base Implementation in ToString

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : WaitForExit Method

Glossary Item Box

Closes std::in and waits for the process to exit

Overload List

Overload | Description
WaitForExit() | Closes std::in and waits for the process to exit
WaitForExit(TimeSpan) | Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given
WaitForExit(TimeSpan,Boolean) | Waits for the process to exit, returns false if the process did not exit in the time given

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > WaitForExit Method : WaitForExit() Method

Glossary Item Box

Closes std::in and waits for the process to exit

Syntax

Visual Basic (Declaration)
Public Overloads Sub WaitForExit()
C#
public void WaitForExit()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Source Code

Library/Processes/ProcessRunner.cs

Used By

ScriptRunner.WaitForExit()


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit(TimeSpan) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > WaitForExit Method : WaitForExit(TimeSpan) Method

timeout

Glossary Item Box

Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given

Syntax

Visual Basic (Declaration)
Public Overloads Function WaitForExit( _
   ByVal timeout As TimeSpan _
) As Boolean
C#
public bool WaitForExit(
   TimeSpan timeout
)

Parameters

timeout

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    ProcessRunner runner = new ProcessRunner("cmd.exe");

    runner.Start();
    runner.StandardInput.WriteLine("ECHO Hello > " + tempfile);
    runner.StandardInput.WriteLine("EXIT");

    Assert.IsTrue(runner.WaitForExit(TimeSpan.FromMinutes(1)));
    Assert.AreEqual(0, runner.ExitCode);

    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Dim runner As New ProcessRunner("cmd.exe")

    runner.Start()
    runner.StandardInput.WriteLine("ECHO Hello > " + tempfile)
    runner.StandardInput.WriteLine("EXIT")

    Assert.IsTrue(runner.WaitForExit(TimeSpan.FromMinutes(1)))
    Assert.AreEqual(0, runner.ExitCode)

    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Source Code

Library/Processes/ProcessRunner.cs

Used By

Boolean ScriptRunner.WaitForExit(TimeSpan)


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit(TimeSpan,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class > WaitForExit Method : WaitForExit(TimeSpan,Boolean) Method

timeout
closeStdInput

Glossary Item Box

Waits for the process to exit, returns false if the process did not exit in the time given

Syntax

Visual Basic (Declaration)
Public Overloads Function WaitForExit( _
   ByVal timeout As TimeSpan, _
   ByVal closeStdInput As Boolean _
) As Boolean
C#
public bool WaitForExit(
   TimeSpan timeout,
   bool closeStdInput
)

Parameters

timeout
closeStdInput

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));
    ProcessRunner runner = new ProcessRunner("cmd.exe");
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("/K", "ECHO Hello > " + tempfile);
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start("/C", "ECHO", "HELO");
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))
    Dim runner As New ProcessRunner("cmd.exe")
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("/K", "ECHO Hello > " + tempfile)
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start("/C", "ECHO", "HELO")
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members
Overload List

Used By

ProcessRunner.Kill()
ProcessRunner.WaitForExit()
Boolean ProcessRunner.WaitForExit(TimeSpan)

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ProcessRunner Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessRunner Class

Glossary Item Box

For a list of all members of this type, see ProcessRunner members.

Public Properties

 | Name | Description
Public Property | ExitCode | Waits for the process to exit and returns the exit code
Public Property | IsRunning | Returns true if this instance is running a process
Public Property | PID | Returns the remote process Id
Public Property | StandardInput | Allows writes to the std::in for the process
Public Property | WorkingDirectory | Gets or sets the initial working directory for the process.
Top

See Also

Reference

ProcessRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExitCode Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : ExitCode Property

Glossary Item Box

Waits for the process to exit and returns the exit code

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ExitCode As Integer
C#
public int ExitCode {get;}

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}");

    runner.StartFormatArgs(tempfile);
    Assert.AreEqual(0, runner.ExitCode);

    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);

    File.Delete(tempfile);
    Assert.AreEqual(0, runner.RunFormatArgs(tempfile));

    output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Dim runner As New ProcessRunner("cmd.exe", "/C", "ECHO", "Hello", ">{0}")

    runner.StartFormatArgs(tempfile)
    Assert.AreEqual(0, runner.ExitCode)

    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)

    File.Delete(tempfile)
    Assert.AreEqual(0, runner.RunFormatArgs(tempfile))

    output = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsRunning Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : IsRunning Property

Glossary Item Box

Returns true if this instance is running a process

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsRunning As Boolean
C#
public bool IsRunning {get;}

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));
    ProcessRunner runner = new ProcessRunner("cmd.exe");
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("/K", "ECHO Hello > " + tempfile);
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start("/C", "ECHO", "HELO");
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))
    Dim runner As New ProcessRunner("cmd.exe")
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("/K", "ECHO Hello > " + tempfile)
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start("/C", "ECHO", "HELO")
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PID Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : PID Property

Glossary Item Box

Returns the remote process Id

Syntax

Visual Basic (Declaration)
Public ReadOnly Property PID As Integer
C#
public int PID {get;}

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
using (ProcessRunner runner = new ProcessRunner("cmd.exe"))
{
    StringWriter wtr = new StringWriter();
    StringWriter err = new StringWriter();
    ProcessOutputEventHandler handler =
            delegate(object o, ProcessOutputEventArgs e)
            { if (e.Error) err.WriteLine(e.Data); else wtr.WriteLine(e.Data); };

    runner.OutputReceived += handler;

    Assert.AreEqual(0, runner.Run("/C", "dir", "/b", "/on", "/ad-h-s", "c:\\"));
    Assert.AreEqual(String.Empty, err.ToString());

    Assert.AreNotEqual(0, runner.PID);

    StringReader rdr = new StringReader(wtr.ToString());
    List<DirectoryInfo> rootdirs = new List<DirectoryInfo>(new DirectoryInfo("C:\\").GetDirectories());
    rootdirs.Sort(delegate(DirectoryInfo x, DirectoryInfo y) { return StringComparer.OrdinalIgnoreCase.Compare(x.Name, y.Name); });
    foreach (DirectoryInfo di in rootdirs)
    {
        if ((di.Attributes & (FileAttributes.Hidden | FileAttributes.System)) != 0)
            continue;
        Assert.AreEqual(di.Name, rdr.ReadLine());
    }

    Assert.AreEqual(null, rdr.ReadLine());
}
VB.NET Copy Code
Using runner As New ProcessRunner("cmd.exe")
    Dim wtr As New StringWriter()
    Dim err As New StringWriter()
    Dim handler As ProcessOutputEventHandler = Function(o As Object, e As ProcessOutputEventArgs) Do
        If e.[Error] Then
            err.WriteLine(e.Data)
        Else
            wtr.WriteLine(e.Data)
        End If
    End Function

    runner.OutputReceived += handler

    Assert.AreEqual(0, runner.Run("/C", "dir", "/b", "/on", "/ad-h-s", "c:\"))
    Assert.AreEqual([String].Empty, err.ToString())

    Assert.AreNotEqual(0, runner.PID)

    Dim rdr As New StringReader(wtr.ToString())
    Dim rootdirs As New List(Of DirectoryInfo)(New DirectoryInfo("C:\").GetDirectories())
    rootdirs.Sort(Function(x As DirectoryInfo, y As DirectoryInfo) Do
        Return StringComparer.OrdinalIgnoreCase.Compare(x.Name, y.Name)
    End Function)
    For Each di As DirectoryInfo In rootdirs
        If (di.Attributes And (FileAttributes.Hidden Or FileAttributes.System)) <> 0 Then
            Continue For
        End If
        Assert.AreEqual(di.Name, rdr.ReadLine())
    Next

    Assert.AreEqual(Nothing, rdr.ReadLine())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StandardInput Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : StandardInput Property

Glossary Item Box

Allows writes to the std::in for the process

Syntax

Visual Basic (Declaration)
Public ReadOnly Property StandardInput As TextWriter
C#
public TextWriter StandardInput {get;}

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    ProcessRunner runner = new ProcessRunner("cmd.exe");

    runner.Start();
    runner.StandardInput.WriteLine("ECHO Hello > " + tempfile);
    runner.StandardInput.WriteLine("EXIT");

    Assert.IsTrue(runner.WaitForExit(TimeSpan.FromMinutes(1)));
    Assert.AreEqual(0, runner.ExitCode);

    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Dim runner As New ProcessRunner("cmd.exe")

    runner.Start()
    runner.StandardInput.WriteLine("ECHO Hello > " + tempfile)
    runner.StandardInput.WriteLine("EXIT")

    Assert.IsTrue(runner.WaitForExit(TimeSpan.FromMinutes(1)))
    Assert.AreEqual(0, runner.ExitCode)

    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs

Used By

ScriptRunner.Start(String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
WorkingDirectory Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : WorkingDirectory Property

Glossary Item Box

Gets or sets the initial working directory for the process.

Syntax

Visual Basic (Declaration)
Public Property WorkingDirectory As String
C#
public string WorkingDirectory {get; set;}

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
using (TempDirectory dir = new TempDirectory())
using (ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "echo CD"))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };

    Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory);
    runner.WorkingDirectory = dir.TempPath;
    Assert.AreEqual(dir.TempPath, runner.WorkingDirectory);

    int exitCode = runner.Run();
    Assert.AreEqual(0, exitCode);
    Assert.AreEqual(dir.TempPath.TrimEnd('\\', '/'), lines[0].TrimEnd('\\', '/'));
}
VB.NET Copy Code
Using dir As New TempDirectory()
    Using runner As New ProcessRunner("cmd.exe", "/C", "echo CD")
        Dim lines As New List(Of String)()
        runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
            lines.Add(e.Data)
        End Function

        Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory)
        runner.WorkingDirectory = dir.TempPath
        Assert.AreEqual(dir.TempPath, runner.WorkingDirectory)

        Dim exitCode As Integer = runner.Run()
        Assert.AreEqual(0, exitCode)
        Assert.AreEqual(dir.TempPath.TrimEnd("\"C, "/"C), lines(0).TrimEnd("\"C, "/"C))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
ProcessRunner Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessRunner Class

Glossary Item Box

For a list of all members of this type, see ProcessRunner members.

Public Events

 | Name | Description
Public Event | OutputReceived | Notifies caller of writes to the std::err or std::out
Public Event | ProcessExited | Notifies caller when the process exits
Top

See Also

Reference

ProcessRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OutputReceived Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : OutputReceived Event

Glossary Item Box

Notifies caller of writes to the std::err or std::out

Syntax

Visual Basic (Declaration)
Public Event OutputReceived As ProcessOutputEventHandler
C#
public event ProcessOutputEventHandler OutputReceived

Event Data

The event handler receives an argument of type ProcessOutputEventArgs containing data related to this event. The following ProcessOutputEventArgs properties provide information specific to this event.

Property | Description
Data | Returns the line of text written to standard out/error
Error | Returns true if the line of text was written to std::error

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
using (TempDirectory dir = new TempDirectory())
using (ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "echo CD"))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };

    Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory);
    runner.WorkingDirectory = dir.TempPath;
    Assert.AreEqual(dir.TempPath, runner.WorkingDirectory);

    int exitCode = runner.Run();
    Assert.AreEqual(0, exitCode);
    Assert.AreEqual(dir.TempPath.TrimEnd('\\', '/'), lines[0].TrimEnd('\\', '/'));
}
VB.NET Copy Code
Using dir As New TempDirectory()
    Using runner As New ProcessRunner("cmd.exe", "/C", "echo CD")
        Dim lines As New List(Of String)()
        runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
            lines.Add(e.Data)
        End Function

        Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory)
        runner.WorkingDirectory = dir.TempPath
        Assert.AreEqual(dir.TempPath, runner.WorkingDirectory)

        Dim exitCode As Integer = runner.Run()
        Assert.AreEqual(0, exitCode)
        Assert.AreEqual(dir.TempPath.TrimEnd("\"C, "/"C), lines(0).TrimEnd("\"C, "/"C))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Used By

TestResXtoMc.TestBuildMcFromResX()

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessExited Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : ProcessExited Event

Glossary Item Box

Notifies caller when the process exits

Syntax

Visual Basic (Declaration)
Public Event ProcessExited As ProcessExitedEventHandler
C#
public event ProcessExitedEventHandler ProcessExited

Event Data

The event handler receives an argument of type ProcessExitedEventArgs containing data related to this event. The following ProcessExitedEventArgs properties provide information specific to this event.

Property | Description
ExitCode | Returns the environment exit code of the process

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Source Code

Library/Processes/ProcessRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptEngine Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptEngine Class

Glossary Item Box

Defines the information needed to run various types of scripts on a Windows host

Syntax

Visual Basic (Declaration)
Public Class ScriptEngine
C#
public class ScriptEngine

Inheritance Hierarchy

System.Object
CSharpTest.Net.Processes.ScriptEngine

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Members
CSharpTest.Net.Processes Namespace
ScriptEngine ScriptRunner.ScriptEngine

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ScriptEngine Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptEngine Class

Glossary Item Box

The following tables list the members exposed by ScriptEngine.

Public Properties

 | Name | Description
Public Property | ArgumentFormat | The arguments to run the script
Public Property | Executable | The script engine executable
Public Property | FileExtension | The file extension of the script
Public Property | RunOptions | The run options
Public Property | ScriptType | Returns the type/language of the script
Public Property | UsesStandardInputScript | Returns true if the script should be fed into the std::in stream of the script process
Top

Public Methods

 | Name | Description
Public Method | Compile | Preprocessing/Compiler routine
static (Shared in Visual Basic) | GetDefaults | Returns the default execution options for the specified scripting type
Top

See Also

Reference

ScriptEngine Class
CSharpTest.Net.Processes Namespace
ScriptEngine ScriptRunner.ScriptEngine

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ScriptEngine Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptEngine Class

Glossary Item Box

For a list of all members of this type, see ScriptEngine members.

Public Methods

 | Name | Description
Public Method | Compile | Preprocessing/Compiler routine
static (Shared in Visual Basic) | GetDefaults | Returns the default execution options for the specified scripting type
Top

See Also

Reference

ScriptEngine Class
CSharpTest.Net.Processes Namespace
ScriptEngine ScriptRunner.ScriptEngine

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Compile Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptEngine Class : Compile Method

script

Glossary Item Box

Preprocessing/Compiler routine

Syntax

Visual Basic (Declaration)
Public Function Compile( _
   ByVal script As String _
) As TempFile
C#
public TempFile Compile(
   string script
)

Parameters

script

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Class
ScriptEngine Members
TempFile

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetDefaults Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptEngine Class : GetDefaults Method

type

Glossary Item Box

Returns the default execution options for the specified scripting type

Syntax

Visual Basic (Declaration)
Public Shared Function GetDefaults( _
   ByVal type As ScriptEngine.Language _
) As ScriptEngine
C#
public static ScriptEngine GetDefaults(
   ScriptEngine.Language type
)

Parameters

type

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Class
ScriptEngine Members
ScriptEngine.Language

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ScriptEngine Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptEngine Class

Glossary Item Box

For a list of all members of this type, see ScriptEngine members.

Public Properties

 | Name | Description
Public Property | ArgumentFormat | The arguments to run the script
Public Property | Executable | The script engine executable
Public Property | FileExtension | The file extension of the script
Public Property | RunOptions | The run options
Public Property | ScriptType | Returns the type/language of the script
Public Property | UsesStandardInputScript | Returns true if the script should be fed into the std::in stream of the script process
Top

See Also

Reference

ScriptEngine Class
CSharpTest.Net.Processes Namespace
ScriptEngine ScriptRunner.ScriptEngine

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentFormat Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptEngine Class : ArgumentFormat Property

Glossary Item Box

The arguments to run the script

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ArgumentFormat As String
C#
public string ArgumentFormat {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Class
ScriptEngine Members

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Executable Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptEngine Class : Executable Property

Glossary Item Box

The script engine executable

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Executable As String
C#
public string Executable {get;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (TempFile file = TempFile.FromExtension(".exe"))
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Exe, file.TempPath))
{
    Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType);
    Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable);
    Assert.IsFalse(File.Exists(runner.ScriptFile));
}
VB.NET Copy Code
Using file As TempFile = TempFile.FromExtension(".exe")
    Using runner As New ScriptRunner(ScriptEngine.Language.Exe, file.TempPath)
        Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType)
        Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable)
        Assert.IsFalse(File.Exists(runner.ScriptFile))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Class
ScriptEngine Members

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileExtension Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptEngine Class : FileExtension Property

Glossary Item Box

The file extension of the script

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileExtension As String
C#
public string FileExtension {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Class
ScriptEngine Members

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RunOptions Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptEngine Class : RunOptions Property

Glossary Item Box

The run options

Syntax

Visual Basic (Declaration)
Public ReadOnly Property RunOptions As ScriptEngine.Options
C#
public ScriptEngine.Options RunOptions {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Class
ScriptEngine Members
ScriptEngine.Options

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptType Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptEngine Class : ScriptType Property

Glossary Item Box

Returns the type/language of the script

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ScriptType As ScriptEngine.Language
C#
public ScriptEngine.Language ScriptType {get;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (TempFile file = TempFile.FromExtension(".exe"))
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Exe, file.TempPath))
{
    Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType);
    Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable);
    Assert.IsFalse(File.Exists(runner.ScriptFile));
}
VB.NET Copy Code
Using file As TempFile = TempFile.FromExtension(".exe")
    Using runner As New ScriptRunner(ScriptEngine.Language.Exe, file.TempPath)
        Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType)
        Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable)
        Assert.IsFalse(File.Exists(runner.ScriptFile))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Class
ScriptEngine Members
ScriptEngine.Language

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UsesStandardInputScript Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptEngine Class : UsesStandardInputScript Property

Glossary Item Box

Returns true if the script should be fed into the std::in stream of the script process

Syntax

Visual Basic (Declaration)
Public ReadOnly Property UsesStandardInputScript As Boolean
C#
public bool UsesStandardInputScript {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptEngine Class
ScriptEngine Members

Source Code

Library/Processes/ScriptEngine.cs

Used By

Int32 ScriptRunner.Run(TextReader,String[])
ScriptRunner.Start(String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptRunner Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptRunner Class

Glossary Item Box

Defines a way to run scripts as an external process and capture their output.

Object Model

ScriptRunner ClassScriptEngine Class

Syntax

Visual Basic (Declaration)
Public Class ScriptRunner
   Implements IRunner
C#
public class ScriptRunner : IRunner

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Processes.ScriptRunner

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Members
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ScriptRunner Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptRunner Class

Glossary Item Box

The following tables list the members exposed by ScriptRunner.

Public Constructors

 | Name | Description
Public Constructor | ScriptRunner Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | ExitCode | Waits for the process to exit and returns the exit code
Public Property | IsRunning | Returns true if this instance is running a process
Public Property | ScriptArguments | Return teh arguments to pass to script engine exe
Public Property | ScriptEngine | Return teh script engine being used
Public Property | ScriptFile | Returns the temp file of the script
Public Property | StandardInput | Allows writes to the std::in for the process
Public Property | WorkingDirectory | Gets or sets the initial working directory for the process.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Kill | Kills the process if it is still running
Public Method | Run | Overloaded. Runs the process and returns the exit code.
Public Method | Start | Overloaded. Runs the process and returns the exit code.
Public Method | ToString | Returns a System.String that represents the current System.Object.
Public Method | WaitForExit | Overloaded. Closes std::in and waits for the process to exit
Top

Public Events

 | Name | Description
Public Event | OutputReceived | Notifies caller of writes to the std::err or std::out
Public Event | ProcessExited | Notifies caller when the process exits
Top

See Also

Reference

ScriptRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptRunner Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : ScriptRunner Constructor

Glossary Item Box

Overload List

Overload | Description
ScriptRunner Constructor(Language,String) | Creates a runnable script with the specified language
ScriptRunner Constructor(ScriptEngine,String) | Creates a runnable script with the specified engine parameters

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptRunner Constructor(Language,String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > ScriptRunner Constructor : ScriptRunner Constructor(Language,String)

language
script

Glossary Item Box

Creates a runnable script with the specified language

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal language As ScriptEngine.Language, _
   ByVal script As String _
)
C#
public ScriptRunner(
   ScriptEngine.Language language,
   string script
)

Parameters

language
script

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptRunner Constructor(ScriptEngine,String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > ScriptRunner Constructor : ScriptRunner Constructor(ScriptEngine,String)

engine
script

Glossary Item Box

Creates a runnable script with the specified engine parameters

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal engine As ScriptEngine, _
   ByVal script As String _
)
C#
public ScriptRunner(
   ScriptEngine engine,
   string script
)

Parameters

engine
script

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ScriptRunner Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptRunner Class

Glossary Item Box

For a list of all members of this type, see ScriptRunner members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Kill | Kills the process if it is still running
Public Method | Run | Overloaded. Runs the process and returns the exit code.
Public Method | Start | Overloaded. Runs the process and returns the exit code.
Public Method | ToString | Returns a System.String that represents the current System.Object.
Public Method | WaitForExit | Overloaded. Closes std::in and waits for the process to exit
Top

See Also

Reference

ScriptRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Kill Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : Kill Method

Glossary Item Box

Kills the process if it is still running

Syntax

Visual Basic (Declaration)
Public Sub Kill()
C#
public void Kill()

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : Run Method

Glossary Item Box

Runs the process and returns the exit code.

Overload List

Overload | Description
Run() | Runs the process and returns the exit code.
Run(String[]) | Runs the process and returns the exit code.
Run(TextReader,String[]) | Runs the process and returns the exit code.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Run() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > Run Method : Run() Method

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run() As Integer
C#
public int Run()

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO From CMD.exe"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    ProcessExitedEventHandler h = delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };
    runner.ProcessExited += h;
    runner.ProcessExited -= h;
    Assert.AreEqual(0, runner.Run());
    Assert.IsFalse(mre.WaitOne(250, false));
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO From CMD.exe")
    Dim mre As New ManualResetEvent(False)
    Dim h As ProcessExitedEventHandler = Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function
    runner.ProcessExited += h
    runner.ProcessExited -= h
    Assert.AreEqual(0, runner.Run())
    Assert.IsFalse(mre.WaitOne(250, False))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > Run Method : Run(String[]) Method

args

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run( _
   ByVal ParamArray args() As String _
) As Integer
C#
public int Run(
   params string[] args
)

Parameters

args

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Exe, @"cmd.exe"))
{
    StringWriter sw = new StringWriter();
    runner.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { sw.WriteLine(e.Data); };
    Assert.AreEqual(0, runner.Run("/c", "@echo From EXE"));
    Assert.AreEqual("From EXE", sw.ToString().Trim());
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.Exe, "cmd.exe")
    Dim sw As New StringWriter()
    runner.OutputReceived += Function(o As Object, e As ProcessOutputEventArgs) Do
        sw.WriteLine(e.Data)
    End Function
    Assert.AreEqual(0, runner.Run("/c", "@echo From EXE"))
    Assert.AreEqual("From EXE", sw.ToString().Trim())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Used By

Int32 ScriptRunner.Run()

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(TextReader,String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > Run Method : Run(TextReader,String[]) Method

input
arguments

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Function Run( _
   ByVal input As TextReader, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
public int Run(
   TextReader input,
   params string[] arguments
)

Parameters

input
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Used By

Int32 ScriptRunner.Run(String[])

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : Start Method

Glossary Item Box

Runs the process and returns the exit code.

Overload List

Overload | Description
Start() | Runs the process and returns the exit code.
Start(String[]) | Starts the process and returns.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Start() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > Start Method : Start() Method

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Start()
C#
public void Start()

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start(String[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > Start Method : Start(String[]) Method

args

Glossary Item Box

Starts the process and returns.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Start( _
   ByVal ParamArray args() As String _
)
C#
public void Start(
   params string[] args
)

Parameters

args

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.JScript, @"WScript.StdOut.WriteLine(WScript.Arguments(0));"))
{
    StringWriter sw = new StringWriter();
    runner.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { sw.WriteLine(e.Data); };
    runner.Start("From JScript");
    runner.WaitForExit();
    Assert.AreEqual(0, runner.ExitCode);
    Assert.AreEqual("From JScript", sw.ToString().Trim());
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.JScript, "WScript.StdOut.WriteLine(WScript.Arguments(0));")
    Dim sw As New StringWriter()
    runner.OutputReceived += Function(o As Object, e As ProcessOutputEventArgs) Do
        sw.WriteLine(e.Data)
    End Function
    runner.Start("From JScript")
    runner.WaitForExit()
    Assert.AreEqual(0, runner.ExitCode)
    Assert.AreEqual("From JScript", sw.ToString().Trim())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Used By

ScriptRunner.Start()

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : ToString Method

Glossary Item Box

Returns a System.String that represents the current System.Object.

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Base Implementation in ToString

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : WaitForExit Method

Glossary Item Box

Closes std::in and waits for the process to exit

Overload List

Overload | Description
WaitForExit() | Closes std::in and waits for the process to exit
WaitForExit(TimeSpan) | Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > WaitForExit Method : WaitForExit() Method

Glossary Item Box

Closes std::in and waits for the process to exit

Syntax

Visual Basic (Declaration)
Public Overloads Sub WaitForExit()
C#
public void WaitForExit()

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.JScript, @"WScript.StdOut.Write(WScript.StdIn.ReadAll());"))
{
    StringWriter sw = new StringWriter();
    runner.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { sw.WriteLine(e.Data); };
    runner.Start();
    runner.StandardInput.WriteLine("From JScript");
    runner.WaitForExit();
    Assert.AreEqual(0, runner.ExitCode);
    Assert.AreEqual("From JScript", sw.ToString().Trim());
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.JScript, "WScript.StdOut.Write(WScript.StdIn.ReadAll());")
    Dim sw As New StringWriter()
    runner.OutputReceived += Function(o As Object, e As ProcessOutputEventArgs) Do
        sw.WriteLine(e.Data)
    End Function
    runner.Start()
    runner.StandardInput.WriteLine("From JScript")
    runner.WaitForExit()
    Assert.AreEqual(0, runner.ExitCode)
    Assert.AreEqual("From JScript", sw.ToString().Trim())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit(TimeSpan) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class > WaitForExit Method : WaitForExit(TimeSpan) Method

timeout

Glossary Item Box

Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given

Syntax

Visual Basic (Declaration)
Public Overloads Function WaitForExit( _
   ByVal timeout As TimeSpan _
) As Boolean
C#
public bool WaitForExit(
   TimeSpan timeout
)

Parameters

timeout

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
Overload List

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ScriptRunner Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptRunner Class

Glossary Item Box

For a list of all members of this type, see ScriptRunner members.

Public Properties

 | Name | Description
Public Property | ExitCode | Waits for the process to exit and returns the exit code
Public Property | IsRunning | Returns true if this instance is running a process
Public Property | ScriptArguments | Return teh arguments to pass to script engine exe
Public Property | ScriptEngine | Return teh script engine being used
Public Property | ScriptFile | Returns the temp file of the script
Public Property | StandardInput | Allows writes to the std::in for the process
Public Property | WorkingDirectory | Gets or sets the initial working directory for the process.
Top

See Also

Reference

ScriptRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExitCode Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : ExitCode Property

Glossary Item Box

Waits for the process to exit and returns the exit code

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ExitCode As Integer
C#
public int ExitCode {get;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsRunning Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : IsRunning Property

Glossary Item Box

Returns true if this instance is running a process

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsRunning As Boolean
C#
public bool IsRunning {get;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptArguments Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : ScriptArguments Property

Glossary Item Box

Return teh arguments to pass to script engine exe

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ScriptArguments As String()
C#
public string[] ScriptArguments {get;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO From CMD.exe"))
{
    Assert.AreEqual(ScriptEngine.Language.Cmd, runner.ScriptEngine.ScriptType);
    Assert.IsTrue(File.Exists(runner.ScriptFile));
    Assert.AreEqual("@ECHO From CMD.exe", File.ReadAllText(runner.ScriptFile));
    Assert.AreEqual("/C " + runner.ScriptFile, String.Join(" ", runner.ScriptArguments));
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO From CMD.exe")
    Assert.AreEqual(ScriptEngine.Language.Cmd, runner.ScriptEngine.ScriptType)
    Assert.IsTrue(File.Exists(runner.ScriptFile))
    Assert.AreEqual("@ECHO From CMD.exe", File.ReadAllText(runner.ScriptFile))
    Assert.AreEqual("/C " + runner.ScriptFile, [String].Join(" ", runner.ScriptArguments))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptEngine Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : ScriptEngine Property

Glossary Item Box

Return teh script engine being used

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ScriptEngine As ScriptEngine
C#
public ScriptEngine ScriptEngine {get;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (TempFile file = TempFile.FromExtension(".exe"))
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Exe, file.TempPath))
{
    Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType);
    Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable);
    Assert.IsFalse(File.Exists(runner.ScriptFile));
}
VB.NET Copy Code
Using file As TempFile = TempFile.FromExtension(".exe")
    Using runner As New ScriptRunner(ScriptEngine.Language.Exe, file.TempPath)
        Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType)
        Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable)
        Assert.IsFalse(File.Exists(runner.ScriptFile))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members
ScriptEngine

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptFile Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : ScriptFile Property

Glossary Item Box

Returns the temp file of the script

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ScriptFile As String
C#
public string ScriptFile {get;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (TempFile file = TempFile.FromExtension(".exe"))
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Exe, file.TempPath))
{
    Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType);
    Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable);
    Assert.IsFalse(File.Exists(runner.ScriptFile));
}
VB.NET Copy Code
Using file As TempFile = TempFile.FromExtension(".exe")
    Using runner As New ScriptRunner(ScriptEngine.Language.Exe, file.TempPath)
        Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType)
        Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable)
        Assert.IsFalse(File.Exists(runner.ScriptFile))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StandardInput Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : StandardInput Property

Glossary Item Box

Allows writes to the std::in for the process

Syntax

Visual Basic (Declaration)
Public ReadOnly Property StandardInput As TextWriter
C#
public TextWriter StandardInput {get;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.JScript, @"WScript.StdOut.Write(WScript.StdIn.ReadAll());"))
{
    StringWriter sw = new StringWriter();
    runner.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { sw.WriteLine(e.Data); };
    runner.Start();
    runner.StandardInput.WriteLine("From JScript");
    runner.WaitForExit();
    Assert.AreEqual(0, runner.ExitCode);
    Assert.AreEqual("From JScript", sw.ToString().Trim());
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.JScript, "WScript.StdOut.Write(WScript.StdIn.ReadAll());")
    Dim sw As New StringWriter()
    runner.OutputReceived += Function(o As Object, e As ProcessOutputEventArgs) Do
        sw.WriteLine(e.Data)
    End Function
    runner.Start()
    runner.StandardInput.WriteLine("From JScript")
    runner.WaitForExit()
    Assert.AreEqual(0, runner.ExitCode)
    Assert.AreEqual("From JScript", sw.ToString().Trim())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WorkingDirectory Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : WorkingDirectory Property

Glossary Item Box

Gets or sets the initial working directory for the process.

Syntax

Visual Basic (Declaration)
Public Property WorkingDirectory As String
C#
public string WorkingDirectory {get; set;}

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (TempDirectory dir = new TempDirectory())
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO cd"))
{
    string output = String.Empty;
    runner.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { output += e.Data; };

    Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory);
    runner.WorkingDirectory = dir.TempPath;
    Assert.AreEqual(dir.TempPath, runner.WorkingDirectory);
    runner.Run();
    Assert.AreEqual(dir.TempPath.TrimEnd('\\', '/'), output.TrimEnd('\\', '/'));
}
VB.NET Copy Code
Using dir As New TempDirectory()
    Using runner As New ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO cd")
        Dim output As String = [String].Empty
        runner.OutputReceived += Function(o As Object, e As ProcessOutputEventArgs) Do
            output += e.Data
        End Function

        Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory)
        runner.WorkingDirectory = dir.TempPath
        Assert.AreEqual(dir.TempPath, runner.WorkingDirectory)
        runner.Run()
        Assert.AreEqual(dir.TempPath.TrimEnd("\"C, "/"C), output.TrimEnd("\"C, "/"C))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
ScriptRunner Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptRunner Class

Glossary Item Box

For a list of all members of this type, see ScriptRunner members.

Public Events

 | Name | Description
Public Event | OutputReceived | Notifies caller of writes to the std::err or std::out
Public Event | ProcessExited | Notifies caller when the process exits
Top

See Also

Reference

ScriptRunner Class
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OutputReceived Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : OutputReceived Event

Glossary Item Box

Notifies caller of writes to the std::err or std::out

Syntax

Visual Basic (Declaration)
Public Event OutputReceived As ProcessOutputEventHandler
C#
public event ProcessOutputEventHandler OutputReceived

Event Data

The event handler receives an argument of type ProcessOutputEventArgs containing data related to this event. The following ProcessOutputEventArgs properties provide information specific to this event.

Property | Description
Data | Returns the line of text written to standard out/error
Error | Returns true if the line of text was written to std::error

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.JScript, @"WScript.StdOut.Write(WScript.StdIn.ReadAll());"))
{
    StringWriter sw = new StringWriter();
    runner.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { sw.WriteLine(e.Data); };
    runner.Start();
    runner.StandardInput.WriteLine("From JScript");
    runner.WaitForExit();
    Assert.AreEqual(0, runner.ExitCode);
    Assert.AreEqual("From JScript", sw.ToString().Trim());
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.JScript, "WScript.StdOut.Write(WScript.StdIn.ReadAll());")
    Dim sw As New StringWriter()
    runner.OutputReceived += Function(o As Object, e As ProcessOutputEventArgs) Do
        sw.WriteLine(e.Data)
    End Function
    runner.Start()
    runner.StandardInput.WriteLine("From JScript")
    runner.WaitForExit()
    Assert.AreEqual(0, runner.ExitCode)
    Assert.AreEqual("From JScript", sw.ToString().Trim())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessExited Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ScriptRunner Class : ProcessExited Event

Glossary Item Box

Notifies caller when the process exits

Syntax

Visual Basic (Declaration)
Public Event ProcessExited As ProcessExitedEventHandler
C#
public event ProcessExitedEventHandler ProcessExited

Event Data

The event handler receives an argument of type ProcessExitedEventArgs containing data related to this event. The following ProcessExitedEventArgs properties provide information specific to this event.

Property | Description
ExitCode | Returns the environment exit code of the process

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ScriptRunner Class
ScriptRunner Members

Source Code

Library/Processes/ScriptRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptEngine.Language Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptEngine.Language Enumeration

Glossary Item Box

Defines the languages we know how to run, or 'Other' when user-defined

Syntax

Visual Basic (Declaration)
Public Enum ScriptEngine.Language
   Inherits System.Enum
C#
public enum ScriptEngine.Language : System.Enum

Members

Member | Description
Cmd | .CMD Shell Script
CSharp | .CS C# Program
Exe | The script is an executable's path
JScript | .JS Javascript file
PowerShell | PowerShell (v2, or v1)
VBNet | Visual Basic .Net Program
VBScript | .VBS VBScript file

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (TempFile file = TempFile.FromExtension(".exe"))
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Exe, file.TempPath))
{
    Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType);
    Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable);
    Assert.IsFalse(File.Exists(runner.ScriptFile));
}
VB.NET Copy Code
Using file As TempFile = TempFile.FromExtension(".exe")
    Using runner As New ScriptRunner(ScriptEngine.Language.Exe, file.TempPath)
        Assert.AreEqual(ScriptEngine.Language.Exe, runner.ScriptEngine.ScriptType)
        Assert.AreEqual(file.TempPath, runner.ScriptEngine.Executable)
        Assert.IsFalse(File.Exists(runner.ScriptFile))
    End Using
End Using

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Processes.ScriptEngine.Language

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Processes Namespace
ScriptEngine ScriptEngine.GetDefaults(ScriptEngine.Language)
ScriptEngine.Language ScriptEngine.ScriptType

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ScriptEngine.Options Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ScriptEngine.Options Enumeration

Glossary Item Box

Options for script execution

Syntax

Visual Basic (Declaration)
Public Enum ScriptEngine.Options
   Inherits System.Enum
C#
public enum ScriptEngine.Options : System.Enum

Members

Member | Description
None |
UsesStandardInputScript | Sends the script to the process via std::in rather than using a temp file

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Processes.ScriptEngine.Options

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Processes Namespace
ScriptEngine.Options ScriptEngine.RunOptions

Source Code

Library/Processes/ScriptEngine.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IRunner Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : IRunner Interface

Glossary Item Box

The common interface between spawning processes, and spawning scripts.

Syntax

Visual Basic (Declaration)
Public Interface IRunner
C#
public interface IRunner

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Members
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IRunner Interface Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : IRunner Interface

Glossary Item Box

The following tables list the members exposed by IRunner.

Public Properties

 | Name | Description
Property | ExitCode | Waits for the process to exit and returns the exit code
Property | IsRunning | Returns true if this instance is running a process
Property | StandardInput | Allows writes to the std::in for the process
Property | WorkingDirectory | Gets or sets the initial working directory for the process.
Top

Public Methods

 | Name | Description
Method | Kill | Kills the process if it is still running
Method | Run | Overloaded. Runs the process and returns the exit code.
Method | Start | Overloaded. Starts the process and returns.
Method | WaitForExit | Overloaded. Closes std::in and waits for the process to exit
Top

Public Events

 | Name | Description
Event | OutputReceived | Notifies caller of writes to the std::err or std::out
Event | ProcessExited | Notifies caller when the process exits
Top

See Also

Reference

IRunner Interface
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IRunner Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : IRunner Interface

Glossary Item Box

For a list of all members of this type, see IRunner members.

Public Methods

 | Name | Description
Method | Kill | Kills the process if it is still running
Method | Run | Overloaded. Runs the process and returns the exit code.
Method | Start | Overloaded. Starts the process and returns.
Method | WaitForExit | Overloaded. Closes std::in and waits for the process to exit
Top

See Also

Reference

IRunner Interface
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Kill Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : Kill Method

Glossary Item Box

Kills the process if it is still running

Syntax

Visual Basic (Declaration)
Sub Kill()
C#
void Kill()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : Run Method

Glossary Item Box

Runs the process and returns the exit code.

Overload List

Overload | Description
Run() | Runs the process and returns the exit code.
Run(String[]) | Runs the process and returns the exit code.
Run(TextReader,String[]) | Runs the process and returns the exit code.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Run() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface > Run Method : Run() Method

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Overloads Function Run() As Integer
C#
int Run()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members
Overload List

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface > Run Method : Run(String[]) Method

args

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Overloads Function Run( _
   ByVal ParamArray args() As String _
) As Integer
C#
int Run(
   params string[] args
)

Parameters

args

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members
Overload List

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Run(TextReader,String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface > Run Method : Run(TextReader,String[]) Method

input
arguments

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration)
Overloads Function Run( _
   ByVal input As TextReader, _
   ByVal ParamArray arguments() As String _
) As Integer
C#
int Run(
   TextReader input,
   params string[] arguments
)

Parameters

input
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members
Overload List

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : Start Method

Glossary Item Box

Starts the process and returns.

Overload List

Overload | Description
Start() | Starts the process and returns.
Start(String[]) | Starts the process and returns.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Start() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface > Start Method : Start() Method

Glossary Item Box

Starts the process and returns.

Syntax

Visual Basic (Declaration)
Overloads Sub Start()
C#
void Start()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members
Overload List

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start(String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface > Start Method : Start(String[]) Method

args

Glossary Item Box

Starts the process and returns.

Syntax

Visual Basic (Declaration)
Overloads Sub Start( _
   ByVal ParamArray args() As String _
)
C#
void Start(
   params string[] args
)

Parameters

args

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members
Overload List

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : WaitForExit Method

Glossary Item Box

Closes std::in and waits for the process to exit

Overload List

Overload | Description
WaitForExit() | Closes std::in and waits for the process to exit
WaitForExit(TimeSpan) | Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface > WaitForExit Method : WaitForExit() Method

Glossary Item Box

Closes std::in and waits for the process to exit

Syntax

Visual Basic (Declaration)
Overloads Sub WaitForExit()
C#
void WaitForExit()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members
Overload List

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExit(TimeSpan) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface > WaitForExit Method : WaitForExit(TimeSpan) Method

timeout

Glossary Item Box

Closes std::in and waits for the process to exit, returns false if the process did not exit in the time given

Syntax

Visual Basic (Declaration)
Overloads Function WaitForExit( _
   ByVal timeout As TimeSpan _
) As Boolean
C#
bool WaitForExit(
   TimeSpan timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members
Overload List

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IRunner Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : IRunner Interface

Glossary Item Box

For a list of all members of this type, see IRunner members.

Public Properties

 | Name | Description
Property | ExitCode | Waits for the process to exit and returns the exit code
Property | IsRunning | Returns true if this instance is running a process
Property | StandardInput | Allows writes to the std::in for the process
Property | WorkingDirectory | Gets or sets the initial working directory for the process.
Top

See Also

Reference

IRunner Interface
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExitCode Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : ExitCode Property

Glossary Item Box

Waits for the process to exit and returns the exit code

Syntax

Visual Basic (Declaration)
ReadOnly Property ExitCode As Integer
C#
int ExitCode {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsRunning Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : IsRunning Property

Glossary Item Box

Returns true if this instance is running a process

Syntax

Visual Basic (Declaration)
ReadOnly Property IsRunning As Boolean
C#
bool IsRunning {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StandardInput Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : StandardInput Property

Glossary Item Box

Allows writes to the std::in for the process

Syntax

Visual Basic (Declaration)
ReadOnly Property StandardInput As TextWriter
C#
TextWriter StandardInput {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WorkingDirectory Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : WorkingDirectory Property

Glossary Item Box

Gets or sets the initial working directory for the process.

Syntax

Visual Basic (Declaration)
Property WorkingDirectory As String
C#
string WorkingDirectory {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
IRunner Interface Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : IRunner Interface

Glossary Item Box

For a list of all members of this type, see IRunner members.

Public Events

 | Name | Description
Event | OutputReceived | Notifies caller of writes to the std::err or std::out
Event | ProcessExited | Notifies caller when the process exits
Top

See Also

Reference

IRunner Interface
CSharpTest.Net.Processes Namespace

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OutputReceived Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : OutputReceived Event

Glossary Item Box

Notifies caller of writes to the std::err or std::out

Syntax

Visual Basic (Declaration)
Event OutputReceived As ProcessOutputEventHandler
C#
event ProcessOutputEventHandler OutputReceived

Event Data

The event handler receives an argument of type ProcessOutputEventArgs containing data related to this event. The following ProcessOutputEventArgs properties provide information specific to this event.

Property | Description
Data | Returns the line of text written to standard out/error
Error | Returns true if the line of text was written to std::error

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessExited Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > IRunner Interface : ProcessExited Event

Glossary Item Box

Notifies caller when the process exits

Syntax

Visual Basic (Declaration)
Event ProcessExited As ProcessExitedEventHandler
C#
event ProcessExitedEventHandler ProcessExited

Event Data

The event handler receives an argument of type ProcessExitedEventArgs containing data related to this event. The following ProcessExitedEventArgs properties provide information specific to this event.

Property | Description
ExitCode | Returns the environment exit code of the process

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRunner Interface
IRunner Members

Source Code

Library/Processes/IRunner.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessExitedEventHandler Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessExitedEventHandler Delegate

sender
args

Glossary Item Box

Raised when a process started with the ProcessRunner exits

Syntax

Visual Basic (Declaration)
Public Delegate Sub ProcessExitedEventHandler( _
   ByVal sender As Object, _
   ByVal args As ProcessExitedEventArgs _
)
C#
public delegate void ProcessExitedEventHandler(
   object sender,
   ProcessExitedEventArgs args
)

Parameters

sender
args

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }"))
{
    ManualResetEvent mre = new ManualResetEvent(false);
    runner.ProcessExited += delegate(object o, ProcessExitedEventArgs e) { mre.Set(); };

    runner.Start();
    Assert.IsTrue(runner.IsRunning);

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero));
    runner.Kill();

    Assert.IsTrue(mre.WaitOne(0, false));
    Assert.IsFalse(runner.IsRunning);
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero));
    Assert.AreNotEqual(0, runner.ExitCode);
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.CSharp, "class Program { static void Main() { System.Threading.Thread.Sleep(System.TimeSpan.FromHours(1)); } }")
    Dim mre As New ManualResetEvent(False)
    runner.ProcessExited += Function(o As Object, e As ProcessExitedEventArgs) Do
        mre.[Set]()
    End Function

    runner.Start()
    Assert.IsTrue(runner.IsRunning)

    Assert.IsFalse(runner.WaitForExit(TimeSpan.Zero))
    runner.Kill()

    Assert.IsTrue(mre.WaitOne(0, False))
    Assert.IsFalse(runner.IsRunning)
    Assert.IsTrue(runner.WaitForExit(TimeSpan.Zero))
    Assert.AreNotEqual(0, runner.ExitCode)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessExitedEventHandler Members
CSharpTest.Net.Processes Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessOutputEventHandler Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace : ProcessOutputEventHandler Delegate

sender
args

Glossary Item Box

A delegate that handles the write to either std::out or std::in for a process

Syntax

Visual Basic (Declaration)
Public Delegate Sub ProcessOutputEventHandler( _
   ByVal sender As Object, _
   ByVal args As ProcessOutputEventArgs _
)
C#
public delegate void ProcessOutputEventHandler(
   object sender,
   ProcessOutputEventArgs args
)

Parameters

sender
args

Example

Library/Library.Test/TestScriptRunner.cs

C# Copy Code
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.JScript, @"WScript.StdOut.Write(WScript.StdIn.ReadAll());"))
{
    StringWriter sw = new StringWriter();
    runner.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { sw.WriteLine(e.Data); };
    runner.Start();
    runner.StandardInput.WriteLine("From JScript");
    runner.WaitForExit();
    Assert.AreEqual(0, runner.ExitCode);
    Assert.AreEqual("From JScript", sw.ToString().Trim());
}
VB.NET Copy Code
Using runner As New ScriptRunner(ScriptEngine.Language.JScript, "WScript.StdOut.Write(WScript.StdIn.ReadAll());")
    Dim sw As New StringWriter()
    runner.OutputReceived += Function(o As Object, e As ProcessOutputEventArgs) Do
        sw.WriteLine(e.Data)
    End Function
    runner.Start()
    runner.StandardInput.WriteLine("From JScript")
    runner.WaitForExit()
    Assert.AreEqual(0, runner.ExitCode)
    Assert.AreEqual("From JScript", sw.ToString().Trim())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessOutputEventHandler Members
CSharpTest.Net.Processes Namespace


%%ItemTitle%%

CSharpTest.Net.Reflection Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Reflection Namespace

Glossary Item Box

Classes

 | Class | Description
Class | ObjectSerializer | Container for a serializer of object properties
Class | PropertySerializer | Represents a set of properties that can be iterated, read, or written to an IPropertyStorage instance.
Class | PropertySerializer<T> | Represents a set of properties that can be iterated, read, or written to an IPropertyStorage instance.
Class | PropertyType | Allows reflection upon a property or field by name.
Class | PropertyValue | Allows setting or getting a property or field on an object via reflection
Class | PropertyValue<T> | Allows setting or getting a property or field of a known type on an object via reflection

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
ObjectSerializer Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : ObjectSerializer Class

Glossary Item Box

Container for a serializer of object properties

Syntax

Visual Basic (Declaration)
Public Class ObjectSerializer
   Inherits PropertySerializer
C#
public class ObjectSerializer : PropertySerializer

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
HaveReadOnly data = new HaveReadOnly();
data.Value = "a";

ObjectSerializer ser = new ObjectSerializer(data, "Value");
ser.Serialize(Dictionary);

HaveReadOnly test = new HaveReadOnly();
ser = new ObjectSerializer(test, "Value");
ser.Deserialize(Dictionary);

Assert.AreEqual("a", test.Value);
VB.NET Copy Code
Dim data As New HaveReadOnly()
data.Value = "a"

Dim ser As New ObjectSerializer(data, "Value")
ser.Serialize(Dictionary)

Dim test As New HaveReadOnly()
ser = New ObjectSerializer(test, "Value")
ser.Deserialize(Dictionary)

Assert.AreEqual("a", test.Value)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Reflection.PropertySerializer
CSharpTest.Net.Reflection.ObjectSerializer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectSerializer Members
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/ObjectSerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ObjectSerializer Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : ObjectSerializer Class

Glossary Item Box

The following tables list the members exposed by ObjectSerializer.

Public Constructors

 | Name | Description
Public Constructor | ObjectSerializer Constructor | Constructs a 'bag-o-property' serializer for the given object instance.
Top

Public Properties

 | Name | Description
Public Property | ContinueOnError | Gets or sets a value that controls whether exceptions are swallowed and logged durring serialization or deserialization routines. (Inherited from CSharpTest.Net.Reflection.PropertySerializer)
Top

Public Methods

 | Name | Description
Public Method | AddMember | Adds a single item to the named property collection, again can be a nested property by using a path or dotted notation "ClientRectangle.X". (Inherited from CSharpTest.Net.Reflection.PropertySerializer)
Public Method | Deserialize | Overloaded. Reads all properties from the specified proeprty serialization
Public Method | Serialize | Overloaded. Writes all properties to the specified proeprty serialization
Top

See Also

Reference

ObjectSerializer Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/ObjectSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ObjectSerializer Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > ObjectSerializer Class : ObjectSerializer Constructor

instance
The instance whos properties are to be serialized
namePaths
optionally named paths to the properties to seralize

Glossary Item Box

Constructs a 'bag-o-property' serializer for the given object instance.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal instance As Object, _
   ByVal ParamArray namePaths() As String _
)
C#
public ObjectSerializer(
   object instance,
   params string[] namePaths
)

Parameters

instance
The instance whos properties are to be serialized
namePaths
optionally named paths to the properties to seralize

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
HaveReadOnly data = new HaveReadOnly();
data.Value = "a";

ObjectSerializer ser = new ObjectSerializer(data, "Value");
ser.Serialize(Dictionary);

HaveReadOnly test = new HaveReadOnly();
ser = new ObjectSerializer(test, "Value");
ser.Deserialize(Dictionary);

Assert.AreEqual("a", test.Value);
VB.NET Copy Code
Dim data As New HaveReadOnly()
data.Value = "a"

Dim ser As New ObjectSerializer(data, "Value")
ser.Serialize(Dictionary)

Dim test As New HaveReadOnly()
ser = New ObjectSerializer(test, "Value")
ser.Deserialize(Dictionary)

Assert.AreEqual("a", test.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectSerializer Class
ObjectSerializer Members

Source Code

Library/Reflection/ObjectSerializer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ObjectSerializer Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : ObjectSerializer Class

Glossary Item Box

For a list of all members of this type, see ObjectSerializer members.

Public Methods

 | Name | Description
Public Method | AddMember | Adds a single item to the named property collection, again can be a nested property by using a path or dotted notation "ClientRectangle.X". (Inherited from CSharpTest.Net.Reflection.PropertySerializer)
Public Method | Deserialize | Overloaded. Reads all properties from the specified proeprty serialization
Public Method | Serialize | Overloaded. Writes all properties to the specified proeprty serialization
Top

See Also

Reference

ObjectSerializer Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/ObjectSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Deserialize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > ObjectSerializer Class : Deserialize Method

Glossary Item Box

Reads all properties from the specified proeprty serialization

Overload List

Overload | Description
Deserialize(INameValueStore) | Reads all properties from the specified proeprty serialization
Deserialize | Reads all properties from the specified proeprty serialization (Inherited from CSharpTest.Net.Reflection.PropertySerializer)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectSerializer Class
ObjectSerializer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Deserialize(INameValueStore) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > ObjectSerializer Class > Deserialize Method : Deserialize(INameValueStore) Method

storage

Glossary Item Box

Reads all properties from the specified proeprty serialization

Syntax

Visual Basic (Declaration)
Public Overloads Sub Deserialize( _
   ByVal storage As INameValueStore _
)
C#
public void Deserialize(
   INameValueStore storage
)

Parameters

storage

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
HaveReadOnly data = new HaveReadOnly();
data.Value = "a";

ObjectSerializer ser = new ObjectSerializer(data, "Value");
ser.Serialize(Dictionary);

HaveReadOnly test = new HaveReadOnly();
ser = new ObjectSerializer(test, "Value");
ser.Deserialize(Dictionary);

Assert.AreEqual("a", test.Value);
VB.NET Copy Code
Dim data As New HaveReadOnly()
data.Value = "a"

Dim ser As New ObjectSerializer(data, "Value")
ser.Serialize(Dictionary)

Dim test As New HaveReadOnly()
ser = New ObjectSerializer(test, "Value")
ser.Deserialize(Dictionary)

Assert.AreEqual("a", test.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectSerializer Class
ObjectSerializer Members
Overload List
INameValueStore

Source Code

Library/Reflection/ObjectSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Serialize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > ObjectSerializer Class : Serialize Method

Glossary Item Box

Writes all properties to the specified proeprty serialization

Overload List

Overload | Description
Serialize(INameValueStore) | Writes all properties to the specified proeprty serialization
Serialize | Writes all properties to the specified proeprty serialization (Inherited from CSharpTest.Net.Reflection.PropertySerializer)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectSerializer Class
ObjectSerializer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Serialize(INameValueStore) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > ObjectSerializer Class > Serialize Method : Serialize(INameValueStore) Method

storage

Glossary Item Box

Writes all properties to the specified proeprty serialization

Syntax

Visual Basic (Declaration)
Public Overloads Sub Serialize( _
   ByVal storage As INameValueStore _
)
C#
public void Serialize(
   INameValueStore storage
)

Parameters

storage

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
HaveReadOnly data = new HaveReadOnly();
data.Value = "a";

ObjectSerializer ser = new ObjectSerializer(data, "Value");
ser.Serialize(Dictionary);

HaveReadOnly test = new HaveReadOnly();
ser = new ObjectSerializer(test, "Value");
ser.Deserialize(Dictionary);

Assert.AreEqual("a", test.Value);
VB.NET Copy Code
Dim data As New HaveReadOnly()
data.Value = "a"

Dim ser As New ObjectSerializer(data, "Value")
ser.Serialize(Dictionary)

Dim test As New HaveReadOnly()
ser = New ObjectSerializer(test, "Value")
ser.Deserialize(Dictionary)

Assert.AreEqual("a", test.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectSerializer Class
ObjectSerializer Members
Overload List
INameValueStore

Source Code

Library/Reflection/ObjectSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PropertySerializer Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertySerializer Class

Glossary Item Box

Represents a set of properties that can be iterated, read, or written to an IPropertyStorage instance.

Syntax

Visual Basic (Declaration)
Public Class PropertySerializer
C#
public class PropertySerializer

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
PropertySerializer ser = new PropertySerializer(typeof(TestValues1), ValueNames);
ser.ContinueOnError = false;
Assert.AreEqual(false, ser.ContinueOnError);

ser.Serialize(ValuesA, Dictionary);

TestValues test = new TestValues();
ser.Deserialize(test, Dictionary);

Assert.AreEqual(ValuesA._bool, test._bool);
Assert.AreEqual(ValuesA._byte, test._byte);
Assert.AreEqual(ValuesA._char, test._char);
Assert.AreEqual(ValuesA._DateTime, test._DateTime);
Assert.AreEqual(ValuesA._decimal, test._decimal);
Assert.AreEqual(ValuesA._double, test._double);
Assert.AreEqual(ValuesA._float, test._float);
Assert.AreEqual(ValuesA._Guid, test._Guid);
Assert.AreEqual(ValuesA._int, test._int);
Assert.AreEqual(ValuesA._long, test._long);
Assert.AreEqual(ValuesA._sbyte, test._sbyte);
Assert.AreEqual(ValuesA._short, test._short);
Assert.AreEqual(ValuesA._string, test._string);
Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan);
Assert.AreEqual(ValuesA._uint, test._uint);
Assert.AreEqual(ValuesA._ulong, test._ulong);
Assert.AreEqual(ValuesA._Uri, test._Uri);
Assert.AreEqual(ValuesA._ushort, test._ushort);
Assert.AreEqual(ValuesA._Version, test._Version);

//ROK - note, it can not deserialize this since it does not know the type:
Assert.AreEqual(null, test._object);
VB.NET Copy Code
Dim ser As New PropertySerializer(GetType(TestValues1), ValueNames)
ser.ContinueOnError = False
Assert.AreEqual(False, ser.ContinueOnError)

ser.Serialize(ValuesA, Dictionary)

Dim test As New TestValues()
ser.Deserialize(test, Dictionary)

Assert.AreEqual(ValuesA._bool, test._bool)
Assert.AreEqual(ValuesA._byte, test._byte)
Assert.AreEqual(ValuesA._char, test._char)
Assert.AreEqual(ValuesA._DateTime, test._DateTime)
Assert.AreEqual(ValuesA._decimal, test._decimal)
Assert.AreEqual(ValuesA._double, test._double)
Assert.AreEqual(ValuesA._float, test._float)
Assert.AreEqual(ValuesA._Guid, test._Guid)
Assert.AreEqual(ValuesA._int, test._int)
Assert.AreEqual(ValuesA._long, test._long)
Assert.AreEqual(ValuesA._sbyte, test._sbyte)
Assert.AreEqual(ValuesA._short, test._short)
Assert.AreEqual(ValuesA._string, test._string)
Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan)
Assert.AreEqual(ValuesA._uint, test._uint)
Assert.AreEqual(ValuesA._ulong, test._ulong)
Assert.AreEqual(ValuesA._Uri, test._Uri)
Assert.AreEqual(ValuesA._ushort, test._ushort)
Assert.AreEqual(ValuesA._Version, test._Version)

'ROK - note, it can not deserialize this since it does not know the type:
Assert.AreEqual(Nothing, test._object)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Reflection.PropertySerializer
CSharpTest.Net.Reflection.ObjectSerializer
CSharpTest.Net.Reflection.PropertySerializer<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer Members
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PropertySerializer Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertySerializer Class

Glossary Item Box

The following tables list the members exposed by PropertySerializer.

Public Constructors

 | Name | Description
Public Constructor | PropertySerializer Constructor | Creates a property serializer for the specified type and optionally the properties specified.
Top

Public Properties

 | Name | Description
Public Property | ContinueOnError | Gets or sets a value that controls whether exceptions are swallowed and logged durring serialization or deserialization routines.
Top

Public Methods

 | Name | Description
Public Method | AddMember | Adds a single item to the named property collection, again can be a nested property by using a path or dotted notation "ClientRectangle.X".
Public Method | Deserialize | Reads all properties from the specified proeprty serialization
Public Method | Serialize | Writes all properties to the specified proeprty serialization
Top

See Also

Reference

PropertySerializer Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PropertySerializer Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer Class : PropertySerializer Constructor

typeOfInstance
namePaths

Glossary Item Box

Creates a property serializer for the specified type and optionally the properties specified.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal typeOfInstance As Type, _
   ByVal ParamArray namePaths() As String _
)
C#
public PropertySerializer(
   Type typeOfInstance,
   params string[] namePaths
)

Parameters

typeOfInstance
namePaths

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
PropertySerializer ser = new PropertySerializer(typeof(TestValues1), ValueNames);
ser.ContinueOnError = false;
Assert.AreEqual(false, ser.ContinueOnError);

ser.Serialize(ValuesA, Dictionary);

TestValues test = new TestValues();
ser.Deserialize(test, Dictionary);

Assert.AreEqual(ValuesA._bool, test._bool);
Assert.AreEqual(ValuesA._byte, test._byte);
Assert.AreEqual(ValuesA._char, test._char);
Assert.AreEqual(ValuesA._DateTime, test._DateTime);
Assert.AreEqual(ValuesA._decimal, test._decimal);
Assert.AreEqual(ValuesA._double, test._double);
Assert.AreEqual(ValuesA._float, test._float);
Assert.AreEqual(ValuesA._Guid, test._Guid);
Assert.AreEqual(ValuesA._int, test._int);
Assert.AreEqual(ValuesA._long, test._long);
Assert.AreEqual(ValuesA._sbyte, test._sbyte);
Assert.AreEqual(ValuesA._short, test._short);
Assert.AreEqual(ValuesA._string, test._string);
Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan);
Assert.AreEqual(ValuesA._uint, test._uint);
Assert.AreEqual(ValuesA._ulong, test._ulong);
Assert.AreEqual(ValuesA._Uri, test._Uri);
Assert.AreEqual(ValuesA._ushort, test._ushort);
Assert.AreEqual(ValuesA._Version, test._Version);

//ROK - note, it can not deserialize this since it does not know the type:
Assert.AreEqual(null, test._object);
VB.NET Copy Code
Dim ser As New PropertySerializer(GetType(TestValues1), ValueNames)
ser.ContinueOnError = False
Assert.AreEqual(False, ser.ContinueOnError)

ser.Serialize(ValuesA, Dictionary)

Dim test As New TestValues()
ser.Deserialize(test, Dictionary)

Assert.AreEqual(ValuesA._bool, test._bool)
Assert.AreEqual(ValuesA._byte, test._byte)
Assert.AreEqual(ValuesA._char, test._char)
Assert.AreEqual(ValuesA._DateTime, test._DateTime)
Assert.AreEqual(ValuesA._decimal, test._decimal)
Assert.AreEqual(ValuesA._double, test._double)
Assert.AreEqual(ValuesA._float, test._float)
Assert.AreEqual(ValuesA._Guid, test._Guid)
Assert.AreEqual(ValuesA._int, test._int)
Assert.AreEqual(ValuesA._long, test._long)
Assert.AreEqual(ValuesA._sbyte, test._sbyte)
Assert.AreEqual(ValuesA._short, test._short)
Assert.AreEqual(ValuesA._string, test._string)
Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan)
Assert.AreEqual(ValuesA._uint, test._uint)
Assert.AreEqual(ValuesA._ulong, test._ulong)
Assert.AreEqual(ValuesA._Uri, test._Uri)
Assert.AreEqual(ValuesA._ushort, test._ushort)
Assert.AreEqual(ValuesA._Version, test._Version)

'ROK - note, it can not deserialize this since it does not know the type:
Assert.AreEqual(Nothing, test._object)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer Class
PropertySerializer Members

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
PropertySerializer Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertySerializer Class

Glossary Item Box

For a list of all members of this type, see PropertySerializer members.

Public Methods

 | Name | Description
Public Method | AddMember | Adds a single item to the named property collection, again can be a nested property by using a path or dotted notation "ClientRectangle.X".
Public Method | Deserialize | Reads all properties from the specified proeprty serialization
Public Method | Serialize | Writes all properties to the specified proeprty serialization
Top

See Also

Reference

PropertySerializer Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddMember Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer Class : AddMember Method

sdatapath

Glossary Item Box

Adds a single item to the named property collection, again can be a nested property by using a path or dotted notation "ClientRectangle.X".

Syntax

Visual Basic (Declaration)
Public Sub AddMember( _
   ByVal sdatapath As String _
)
C#
public void AddMember(
   string sdatapath
)

Parameters

sdatapath

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer Class
PropertySerializer Members

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Deserialize Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer Class : Deserialize Method

instance
rawstorage

Glossary Item Box

Reads all properties from the specified proeprty serialization

Syntax

Visual Basic (Declaration)
Public Overridable Sub Deserialize( _
   ByVal instance As Object, _
   ByVal rawstorage As INameValueStore _
)
C#
public virtual void Deserialize(
   object instance,
   INameValueStore rawstorage
)

Parameters

instance
rawstorage

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
PropertySerializer ser = new PropertySerializer(typeof(TestValues1), ValueNames);
ser.ContinueOnError = false;
Assert.AreEqual(false, ser.ContinueOnError);

ser.Serialize(ValuesA, Dictionary);

TestValues test = new TestValues();
ser.Deserialize(test, Dictionary);

Assert.AreEqual(ValuesA._bool, test._bool);
Assert.AreEqual(ValuesA._byte, test._byte);
Assert.AreEqual(ValuesA._char, test._char);
Assert.AreEqual(ValuesA._DateTime, test._DateTime);
Assert.AreEqual(ValuesA._decimal, test._decimal);
Assert.AreEqual(ValuesA._double, test._double);
Assert.AreEqual(ValuesA._float, test._float);
Assert.AreEqual(ValuesA._Guid, test._Guid);
Assert.AreEqual(ValuesA._int, test._int);
Assert.AreEqual(ValuesA._long, test._long);
Assert.AreEqual(ValuesA._sbyte, test._sbyte);
Assert.AreEqual(ValuesA._short, test._short);
Assert.AreEqual(ValuesA._string, test._string);
Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan);
Assert.AreEqual(ValuesA._uint, test._uint);
Assert.AreEqual(ValuesA._ulong, test._ulong);
Assert.AreEqual(ValuesA._Uri, test._Uri);
Assert.AreEqual(ValuesA._ushort, test._ushort);
Assert.AreEqual(ValuesA._Version, test._Version);

//ROK - note, it can not deserialize this since it does not know the type:
Assert.AreEqual(null, test._object);
VB.NET Copy Code
Dim ser As New PropertySerializer(GetType(TestValues1), ValueNames)
ser.ContinueOnError = False
Assert.AreEqual(False, ser.ContinueOnError)

ser.Serialize(ValuesA, Dictionary)

Dim test As New TestValues()
ser.Deserialize(test, Dictionary)

Assert.AreEqual(ValuesA._bool, test._bool)
Assert.AreEqual(ValuesA._byte, test._byte)
Assert.AreEqual(ValuesA._char, test._char)
Assert.AreEqual(ValuesA._DateTime, test._DateTime)
Assert.AreEqual(ValuesA._decimal, test._decimal)
Assert.AreEqual(ValuesA._double, test._double)
Assert.AreEqual(ValuesA._float, test._float)
Assert.AreEqual(ValuesA._Guid, test._Guid)
Assert.AreEqual(ValuesA._int, test._int)
Assert.AreEqual(ValuesA._long, test._long)
Assert.AreEqual(ValuesA._sbyte, test._sbyte)
Assert.AreEqual(ValuesA._short, test._short)
Assert.AreEqual(ValuesA._string, test._string)
Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan)
Assert.AreEqual(ValuesA._uint, test._uint)
Assert.AreEqual(ValuesA._ulong, test._ulong)
Assert.AreEqual(ValuesA._Uri, test._Uri)
Assert.AreEqual(ValuesA._ushort, test._ushort)
Assert.AreEqual(ValuesA._Version, test._Version)

'ROK - note, it can not deserialize this since it does not know the type:
Assert.AreEqual(Nothing, test._object)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer Class
PropertySerializer Members
INameValueStore

Source Code

Library/Reflection/PropertySerializer.cs

Used By

ObjectSerializer.Deserialize(INameValueStore)
PropertySerializer.Deserialize(T,INameValueStore)


%%PageItemTitle%%

[image]
CSharpTest.Net
Serialize Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer Class : Serialize Method

instance
rawstorage

Glossary Item Box

Writes all properties to the specified proeprty serialization

Syntax

Visual Basic (Declaration)
Public Overridable Sub Serialize( _
   ByVal instance As Object, _
   ByVal rawstorage As INameValueStore _
)
C#
public virtual void Serialize(
   object instance,
   INameValueStore rawstorage
)

Parameters

instance
rawstorage

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
PropertySerializer ser = new PropertySerializer(typeof(TestValues1), ValueNames);
ser.ContinueOnError = false;
Assert.AreEqual(false, ser.ContinueOnError);

ser.Serialize(ValuesA, Dictionary);

TestValues test = new TestValues();
ser.Deserialize(test, Dictionary);

Assert.AreEqual(ValuesA._bool, test._bool);
Assert.AreEqual(ValuesA._byte, test._byte);
Assert.AreEqual(ValuesA._char, test._char);
Assert.AreEqual(ValuesA._DateTime, test._DateTime);
Assert.AreEqual(ValuesA._decimal, test._decimal);
Assert.AreEqual(ValuesA._double, test._double);
Assert.AreEqual(ValuesA._float, test._float);
Assert.AreEqual(ValuesA._Guid, test._Guid);
Assert.AreEqual(ValuesA._int, test._int);
Assert.AreEqual(ValuesA._long, test._long);
Assert.AreEqual(ValuesA._sbyte, test._sbyte);
Assert.AreEqual(ValuesA._short, test._short);
Assert.AreEqual(ValuesA._string, test._string);
Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan);
Assert.AreEqual(ValuesA._uint, test._uint);
Assert.AreEqual(ValuesA._ulong, test._ulong);
Assert.AreEqual(ValuesA._Uri, test._Uri);
Assert.AreEqual(ValuesA._ushort, test._ushort);
Assert.AreEqual(ValuesA._Version, test._Version);

//ROK - note, it can not deserialize this since it does not know the type:
Assert.AreEqual(null, test._object);
VB.NET Copy Code
Dim ser As New PropertySerializer(GetType(TestValues1), ValueNames)
ser.ContinueOnError = False
Assert.AreEqual(False, ser.ContinueOnError)

ser.Serialize(ValuesA, Dictionary)

Dim test As New TestValues()
ser.Deserialize(test, Dictionary)

Assert.AreEqual(ValuesA._bool, test._bool)
Assert.AreEqual(ValuesA._byte, test._byte)
Assert.AreEqual(ValuesA._char, test._char)
Assert.AreEqual(ValuesA._DateTime, test._DateTime)
Assert.AreEqual(ValuesA._decimal, test._decimal)
Assert.AreEqual(ValuesA._double, test._double)
Assert.AreEqual(ValuesA._float, test._float)
Assert.AreEqual(ValuesA._Guid, test._Guid)
Assert.AreEqual(ValuesA._int, test._int)
Assert.AreEqual(ValuesA._long, test._long)
Assert.AreEqual(ValuesA._sbyte, test._sbyte)
Assert.AreEqual(ValuesA._short, test._short)
Assert.AreEqual(ValuesA._string, test._string)
Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan)
Assert.AreEqual(ValuesA._uint, test._uint)
Assert.AreEqual(ValuesA._ulong, test._ulong)
Assert.AreEqual(ValuesA._Uri, test._Uri)
Assert.AreEqual(ValuesA._ushort, test._ushort)
Assert.AreEqual(ValuesA._Version, test._Version)

'ROK - note, it can not deserialize this since it does not know the type:
Assert.AreEqual(Nothing, test._object)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer Class
PropertySerializer Members
INameValueStore

Source Code

Library/Reflection/PropertySerializer.cs

Used By

ObjectSerializer.Serialize(INameValueStore)
PropertySerializer.Serialize(T,INameValueStore)


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
PropertySerializer Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertySerializer Class

Glossary Item Box

For a list of all members of this type, see PropertySerializer members.

Public Properties

 | Name | Description
Public Property | ContinueOnError | Gets or sets a value that controls whether exceptions are swallowed and logged durring serialization or deserialization routines.
Top

See Also

Reference

PropertySerializer Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContinueOnError Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer Class : ContinueOnError Property

Glossary Item Box

Gets or sets a value that controls whether exceptions are swallowed and logged durring serialization or deserialization routines.

Syntax

Visual Basic (Declaration)
Public Property ContinueOnError As Boolean
C#
public bool ContinueOnError {get; set;}

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
HaveReadOnly o = new HaveReadOnly();
o.Value = "a";

PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>("Value", "WriteOnly");
ser.ContinueOnError = true;
Assert.AreEqual(true, ser.ContinueOnError);

ser.Serialize(o, Dictionary);
VB.NET Copy Code
Dim o As New HaveReadOnly()
o.Value = "a"

Dim ser As New PropertySerializer(Of HaveReadOnly)("Value", "WriteOnly")
ser.ContinueOnError = True
Assert.AreEqual(True, ser.ContinueOnError)

ser.Serialize(o, Dictionary)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer Class
PropertySerializer Members

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
PropertySerializer<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertySerializer<T> Class

Glossary Item Box

Represents a set of properties that can be iterated, read, or written to an IPropertyStorage instance.

Syntax

Visual Basic (Declaration)
Public Class PropertySerializer(Of T)
   Inherits PropertySerializer
C#
public class PropertySerializer<T> : PropertySerializer

Type Parameters

T

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>();
try
{
    ser.GetType().InvokeMember("Serialize", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null,
        ser, new object[] { new object(), Dictionary });
}
catch (TargetInvocationException e)
{ Assert.AreEqual(typeof(NotSupportedException), e.InnerException.GetType()); }
try
{
    ser.GetType().InvokeMember("Deserialize", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null,
        ser, new object[] { new object(), Dictionary });
}
catch (TargetInvocationException e)
{ Assert.AreEqual(typeof(NotSupportedException), e.InnerException.GetType()); }
VB.NET Copy Code
Dim ser As New PropertySerializer(Of HaveReadOnly)()
Try
    ser.[GetType]().InvokeMember("Serialize", System.Reflection.BindingFlags.[Public] Or System.Reflection.BindingFlags.InvokeMethod Or System.Reflection.BindingFlags.Instance, Nothing, ser, New Object() {New Object(), Dictionary})
Catch e As TargetInvocationException
    Assert.AreEqual(GetType(NotSupportedException), e.InnerException.[GetType]())
End Try
Try
    ser.[GetType]().InvokeMember("Deserialize", System.Reflection.BindingFlags.[Public] Or System.Reflection.BindingFlags.InvokeMethod Or System.Reflection.BindingFlags.Instance, Nothing, ser, New Object() {New Object(), Dictionary})
Catch e As TargetInvocationException
    Assert.AreEqual(GetType(NotSupportedException), e.InnerException.[GetType]())
End Try

Inheritance Hierarchy

System.Object
CSharpTest.Net.Reflection.PropertySerializer
CSharpTest.Net.Reflection.PropertySerializer<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer<T> Members
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PropertySerializer<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertySerializer<T> Class

Glossary Item Box

The following tables list the members exposed by PropertySerializer<T>.

Public Constructors

 | Name | Description
Public Constructor | PropertySerializer<T> Constructor | Creates a property serializer for the specified type T and optionally the properties specified.
Top

Public Properties

 | Name | Description
Public Property | ContinueOnError | Gets or sets a value that controls whether exceptions are swallowed and logged durring serialization or deserialization routines. (Inherited from CSharpTest.Net.Reflection.PropertySerializer)
Top

Public Methods

 | Name | Description
Public Method | AddMember | Adds a single item to the named property collection, again can be a nested property by using a path or dotted notation "ClientRectangle.X". (Inherited from CSharpTest.Net.Reflection.PropertySerializer)
Public Method | Deserialize | Reads all properties from the specified proeprty serialization
Public Method | Serialize | Writes all properties to the specified proeprty serialization
Top

See Also

Reference

PropertySerializer<T> Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PropertySerializer<T> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer<T> Class : PropertySerializer<T> Constructor

namePaths

Glossary Item Box

Creates a property serializer for the specified type T and optionally the properties specified.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray namePaths() As String _
)
C#
public PropertySerializer<T>(
   params string[] namePaths
)

Parameters

namePaths

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>();
try
{
    ser.GetType().InvokeMember("Serialize", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null,
        ser, new object[] { new object(), Dictionary });
}
catch (TargetInvocationException e)
{ Assert.AreEqual(typeof(NotSupportedException), e.InnerException.GetType()); }
try
{
    ser.GetType().InvokeMember("Deserialize", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null,
        ser, new object[] { new object(), Dictionary });
}
catch (TargetInvocationException e)
{ Assert.AreEqual(typeof(NotSupportedException), e.InnerException.GetType()); }
VB.NET Copy Code
Dim ser As New PropertySerializer(Of HaveReadOnly)()
Try
    ser.[GetType]().InvokeMember("Serialize", System.Reflection.BindingFlags.[Public] Or System.Reflection.BindingFlags.InvokeMethod Or System.Reflection.BindingFlags.Instance, Nothing, ser, New Object() {New Object(), Dictionary})
Catch e As TargetInvocationException
    Assert.AreEqual(GetType(NotSupportedException), e.InnerException.[GetType]())
End Try
Try
    ser.[GetType]().InvokeMember("Deserialize", System.Reflection.BindingFlags.[Public] Or System.Reflection.BindingFlags.InvokeMethod Or System.Reflection.BindingFlags.Instance, Nothing, ser, New Object() {New Object(), Dictionary})
Catch e As TargetInvocationException
    Assert.AreEqual(GetType(NotSupportedException), e.InnerException.[GetType]())
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer<T> Class
PropertySerializer<T> Members

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
PropertySerializer<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertySerializer<T> Class

Glossary Item Box

For a list of all members of this type, see PropertySerializer<T> members.

Public Methods

 | Name | Description
Public Method | AddMember | Adds a single item to the named property collection, again can be a nested property by using a path or dotted notation "ClientRectangle.X". (Inherited from CSharpTest.Net.Reflection.PropertySerializer)
Public Method | Deserialize | Reads all properties from the specified proeprty serialization
Public Method | Serialize | Writes all properties to the specified proeprty serialization
Top

See Also

Reference

PropertySerializer<T> Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Deserialize(T,INameValueStore) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer<T> Class > Deserialize Method : Deserialize(T,INameValueStore) Method

instance
rawstorage

Glossary Item Box

Reads all properties from the specified proeprty serialization

Syntax

Visual Basic (Declaration)
Public Overloads Sub Deserialize( _
   ByVal instance As T, _
   ByVal rawstorage As INameValueStore _
)
C#
public void Deserialize(
   T instance,
   INameValueStore rawstorage
)

Parameters

instance
rawstorage

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
HaveReadOnly o = new HaveReadOnly();
o.Value = "a";

PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>("Value", "ReadOnly");
ser.ContinueOnError = true;
Assert.AreEqual(true, ser.ContinueOnError);

ser.Serialize(o, Dictionary);

HaveReadOnly test = new HaveReadOnly();
ser.Deserialize(test, Dictionary);
VB.NET Copy Code
Dim o As New HaveReadOnly()
o.Value = "a"

Dim ser As New PropertySerializer(Of HaveReadOnly)("Value", "ReadOnly")
ser.ContinueOnError = True
Assert.AreEqual(True, ser.ContinueOnError)

ser.Serialize(o, Dictionary)

Dim test As New HaveReadOnly()
ser.Deserialize(test, Dictionary)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer<T> Class
PropertySerializer<T> Members
Overload List
INameValueStore

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Serialize(T,INameValueStore) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer<T> Class > Serialize Method : Serialize(T,INameValueStore) Method

instance
rawstorage

Glossary Item Box

Writes all properties to the specified proeprty serialization

Syntax

Visual Basic (Declaration)
Public Overloads Sub Serialize( _
   ByVal instance As T, _
   ByVal rawstorage As INameValueStore _
)
C#
public void Serialize(
   T instance,
   INameValueStore rawstorage
)

Parameters

instance
rawstorage

Example

Library/Library.Test/TestPropertySerializer.cs

C# Copy Code
HaveReadOnly o = new HaveReadOnly();
o.Value = "a";

PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>("Value", "WriteOnly");
ser.ContinueOnError = true;
Assert.AreEqual(true, ser.ContinueOnError);

ser.Serialize(o, Dictionary);
VB.NET Copy Code
Dim o As New HaveReadOnly()
o.Value = "a"

Dim ser As New PropertySerializer(Of HaveReadOnly)("Value", "WriteOnly")
ser.ContinueOnError = True
Assert.AreEqual(True, ser.ContinueOnError)

ser.Serialize(o, Dictionary)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer<T> Class
PropertySerializer<T> Members
Overload List
INameValueStore

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PropertyType Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyType Class

Glossary Item Box

Allows reflection upon a property or field by name.

Syntax

Visual Basic (Declaration)
Public Class PropertyType
C#
public class PropertyType

Example

Library/Library.Test/TestPropertyType.cs

C# Copy Code
PropertyType pt = new PropertyType(typeof(a), "PropertyA");
Assert.IsTrue(pt.IsDefined(typeof(System.ComponentModel.DisplayNameAttribute), false));
Assert.AreEqual(1, pt.GetCustomAttributes(false).Length);
Assert.AreEqual(1, pt.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), false).Length);
Assert.AreEqual(0, pt.GetCustomAttributes(typeof(System.ComponentModel.DesignOnlyAttribute), false).Length);
VB.NET Copy Code
Dim pt As New PropertyType(GetType(a), "PropertyA")
Assert.IsTrue(pt.IsDefined(GetType(System.ComponentModel.DisplayNameAttribute), False))
Assert.AreEqual(1, pt.GetCustomAttributes(False).Length)
Assert.AreEqual(1, pt.GetCustomAttributes(GetType(System.ComponentModel.DisplayNameAttribute), False).Length)
Assert.AreEqual(0, pt.GetCustomAttributes(GetType(System.ComponentModel.DesignOnlyAttribute), False).Length)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Reflection.PropertyType
CSharpTest.Net.Reflection.PropertyValue

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Members
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PropertyType Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyType Class

Glossary Item Box

The following tables list the members exposed by PropertyType.

Public Constructors

 | Name | Description
Public Constructor | PropertyType Constructor | Constructs the PropertyType info from a source type and an instance property or field name
Top

Public Properties

 | Name | Description
Public Property | Name | Returns the name of the property/field
Public Property | Type | Returns the type of the property/field
Top

Public Methods

 | Name | Description
Public Method | GetCustomAttributes | Overloaded. Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.
Public Method | GetValue | Returns the value of the property for the specified instance
Public Method | IsDefined | Indicates whether one or more instance of attributeType is defined on this member.
Public Method | SetValue | Sets the specified value for the instance supplied
static (Shared in Visual Basic) | TraverseProperties | Walks a heirarchy of properties from the given type down. You can specify in any of the following ways: "ClientRectangle.X", "ClientRectangle/X"
Top

See Also

Reference

PropertyType Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PropertyType Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : PropertyType Constructor

type
Any System.Type object to find the property or field on
name
The name of the property or field to find

Glossary Item Box

Constructs the PropertyType info from a source type and an instance property or field name

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal type As Type, _
   ByVal name As String _
)
C#
public PropertyType(
   Type type,
   string name
)

Parameters

type
Any System.Type object to find the property or field on
name
The name of the property or field to find

Example

Library/Library.Test/TestPropertyType.cs

C# Copy Code
PropertyType pt = new PropertyType(typeof(a), "PropertyA");
Assert.IsTrue(pt.IsDefined(typeof(System.ComponentModel.DisplayNameAttribute), false));
Assert.AreEqual(1, pt.GetCustomAttributes(false).Length);
Assert.AreEqual(1, pt.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), false).Length);
Assert.AreEqual(0, pt.GetCustomAttributes(typeof(System.ComponentModel.DesignOnlyAttribute), false).Length);
VB.NET Copy Code
Dim pt As New PropertyType(GetType(a), "PropertyA")
Assert.IsTrue(pt.IsDefined(GetType(System.ComponentModel.DisplayNameAttribute), False))
Assert.AreEqual(1, pt.GetCustomAttributes(False).Length)
Assert.AreEqual(1, pt.GetCustomAttributes(GetType(System.ComponentModel.DisplayNameAttribute), False).Length)
Assert.AreEqual(0, pt.GetCustomAttributes(GetType(System.ComponentModel.DesignOnlyAttribute), False).Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members

Used By

PropertyType PropertyType.TraverseProperties(Type,String[])

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
PropertyType Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyType Class

Glossary Item Box

For a list of all members of this type, see PropertyType members.

Public Methods

 | Name | Description
Public Method | GetCustomAttributes | Overloaded. Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.
Public Method | GetValue | Returns the value of the property for the specified instance
Public Method | IsDefined | Indicates whether one or more instance of attributeType is defined on this member.
Public Method | SetValue | Sets the specified value for the instance supplied
static (Shared in Visual Basic) | TraverseProperties | Walks a heirarchy of properties from the given type down. You can specify in any of the following ways: "ClientRectangle.X", "ClientRectangle/X"
Top

See Also

Reference

PropertyType Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetCustomAttributes Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : GetCustomAttributes Method

Glossary Item Box

Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.

Overload List

Overload | Description
GetCustomAttributes(Boolean) | Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.
GetCustomAttributes(Type,Boolean) | Returns an array of custom attributes defined on this member, identified by type, or an empty array if there are no custom attributes of that type.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetCustomAttributes(Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class > GetCustomAttributes Method : GetCustomAttributes(Boolean) Method

inherit

Glossary Item Box

Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetCustomAttributes( _
   ByVal inherit As Boolean _
) As Object()
C#
public object[] GetCustomAttributes(
   bool inherit
)

Parameters

inherit

Example

Library/Library.Test/TestPropertyType.cs

C# Copy Code
PropertyType pt = new PropertyType(typeof(a), "PropertyA");
Assert.IsTrue(pt.IsDefined(typeof(System.ComponentModel.DisplayNameAttribute), false));
Assert.AreEqual(1, pt.GetCustomAttributes(false).Length);
Assert.AreEqual(1, pt.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), false).Length);
Assert.AreEqual(0, pt.GetCustomAttributes(typeof(System.ComponentModel.DesignOnlyAttribute), false).Length);
VB.NET Copy Code
Dim pt As New PropertyType(GetType(a), "PropertyA")
Assert.IsTrue(pt.IsDefined(GetType(System.ComponentModel.DisplayNameAttribute), False))
Assert.AreEqual(1, pt.GetCustomAttributes(False).Length)
Assert.AreEqual(1, pt.GetCustomAttributes(GetType(System.ComponentModel.DisplayNameAttribute), False).Length)
Assert.AreEqual(0, pt.GetCustomAttributes(GetType(System.ComponentModel.DesignOnlyAttribute), False).Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members
Overload List

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetCustomAttributes(Type,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class > GetCustomAttributes Method : GetCustomAttributes(Type,Boolean) Method

attributeType
inherit

Glossary Item Box

Returns an array of custom attributes defined on this member, identified by type, or an empty array if there are no custom attributes of that type.

Syntax

Visual Basic (Declaration)
Public Overloads Function GetCustomAttributes( _
   ByVal attributeType As Type, _
   ByVal inherit As Boolean _
) As Object()
C#
public object[] GetCustomAttributes(
   Type attributeType,
   bool inherit
)

Parameters

attributeType
inherit

Example

Library/Library.Test/TestPropertyType.cs

C# Copy Code
PropertyType pt = new PropertyType(typeof(a), "PropertyA");
Assert.IsTrue(pt.IsDefined(typeof(System.ComponentModel.DisplayNameAttribute), false));
Assert.AreEqual(1, pt.GetCustomAttributes(false).Length);
Assert.AreEqual(1, pt.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), false).Length);
Assert.AreEqual(0, pt.GetCustomAttributes(typeof(System.ComponentModel.DesignOnlyAttribute), false).Length);
VB.NET Copy Code
Dim pt As New PropertyType(GetType(a), "PropertyA")
Assert.IsTrue(pt.IsDefined(GetType(System.ComponentModel.DisplayNameAttribute), False))
Assert.AreEqual(1, pt.GetCustomAttributes(False).Length)
Assert.AreEqual(1, pt.GetCustomAttributes(GetType(System.ComponentModel.DisplayNameAttribute), False).Length)
Assert.AreEqual(0, pt.GetCustomAttributes(GetType(System.ComponentModel.DesignOnlyAttribute), False).Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members
Overload List

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : GetValue Method

instance

Glossary Item Box

Returns the value of the property for the specified instance

Syntax

Visual Basic (Declaration)
Public Function GetValue( _
   ByVal instance As Object _
) As Object
C#
public object GetValue(
   object instance
)

Parameters

instance

Example

Library/Library.Test/TestPropertyType.cs

C# Copy Code
a classa = new a();
classa.PropertyA = "hello";
Assert.AreEqual("hello", classa.PropertyA);

PropertyType pt = new PropertyType(classa.GetType(), "PropertyA");
Assert.AreEqual("hello", pt.GetValue(classa));
pt.SetValue(classa, "world");
Assert.AreEqual("world", pt.GetValue(classa));
Assert.AreEqual("world", classa.PropertyA);

classa.PropertyA = "hello";//set privateField back to "hello"
Assert.AreEqual("hello", classa.PropertyA);

pt = new PropertyType(classa.GetType(), "privateField");
Assert.AreEqual("hello", pt.GetValue(classa));
pt.SetValue(classa, "world");
Assert.AreEqual("world", pt.GetValue(classa));
Assert.AreEqual("world", classa.PropertyA);
VB.NET Copy Code
Dim classa As New a()
classa.PropertyA = "hello"
Assert.AreEqual("hello", classa.PropertyA)

Dim pt As New PropertyType(classa.[GetType](), "PropertyA")
Assert.AreEqual("hello", pt.GetValue(classa))
pt.SetValue(classa, "world")
Assert.AreEqual("world", pt.GetValue(classa))
Assert.AreEqual("world", classa.PropertyA)

classa.PropertyA = "hello"
'set privateField back to "hello"
Assert.AreEqual("hello", classa.PropertyA)

pt = New PropertyType(classa.[GetType](), "privateField")
Assert.AreEqual("hello", pt.GetValue(classa))
pt.SetValue(classa, "world")
Assert.AreEqual("world", pt.GetValue(classa))
Assert.AreEqual("world", classa.PropertyA)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsDefined Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : IsDefined Method

attributeType
inherit

Glossary Item Box

Indicates whether one or more instance of attributeType is defined on this member.

Syntax

Visual Basic (Declaration)
Public Function IsDefined( _
   ByVal attributeType As Type, _
   ByVal inherit As Boolean _
) As Boolean
C#
public bool IsDefined(
   Type attributeType,
   bool inherit
)

Parameters

attributeType
inherit

Example

Library/Library.Test/TestPropertyType.cs

C# Copy Code
PropertyType pt = new PropertyType(typeof(a), "PropertyA");
Assert.IsTrue(pt.IsDefined(typeof(System.ComponentModel.DisplayNameAttribute), false));
Assert.AreEqual(1, pt.GetCustomAttributes(false).Length);
Assert.AreEqual(1, pt.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), false).Length);
Assert.AreEqual(0, pt.GetCustomAttributes(typeof(System.ComponentModel.DesignOnlyAttribute), false).Length);
VB.NET Copy Code
Dim pt As New PropertyType(GetType(a), "PropertyA")
Assert.IsTrue(pt.IsDefined(GetType(System.ComponentModel.DisplayNameAttribute), False))
Assert.AreEqual(1, pt.GetCustomAttributes(False).Length)
Assert.AreEqual(1, pt.GetCustomAttributes(GetType(System.ComponentModel.DisplayNameAttribute), False).Length)
Assert.AreEqual(0, pt.GetCustomAttributes(GetType(System.ComponentModel.DesignOnlyAttribute), False).Length)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : SetValue Method

instance
value

Glossary Item Box

Sets the specified value for the instance supplied

Syntax

Visual Basic (Declaration)
Public Sub SetValue( _
   ByVal instance As Object, _
   ByVal value As Object _
)
C#
public void SetValue(
   object instance,
   object value
)

Parameters

instance
value

Example

Library/Library.Test/TestPropertyType.cs

C# Copy Code
a classa = new a();
classa.PropertyA = "hello";
Assert.AreEqual("hello", classa.PropertyA);

PropertyType pt = new PropertyType(classa.GetType(), "PropertyA");
Assert.AreEqual("hello", pt.GetValue(classa));
pt.SetValue(classa, "world");
Assert.AreEqual("world", pt.GetValue(classa));
Assert.AreEqual("world", classa.PropertyA);

classa.PropertyA = "hello";//set privateField back to "hello"
Assert.AreEqual("hello", classa.PropertyA);

pt = new PropertyType(classa.GetType(), "privateField");
Assert.AreEqual("hello", pt.GetValue(classa));
pt.SetValue(classa, "world");
Assert.AreEqual("world", pt.GetValue(classa));
Assert.AreEqual("world", classa.PropertyA);
VB.NET Copy Code
Dim classa As New a()
classa.PropertyA = "hello"
Assert.AreEqual("hello", classa.PropertyA)

Dim pt As New PropertyType(classa.[GetType](), "PropertyA")
Assert.AreEqual("hello", pt.GetValue(classa))
pt.SetValue(classa, "world")
Assert.AreEqual("world", pt.GetValue(classa))
Assert.AreEqual("world", classa.PropertyA)

classa.PropertyA = "hello"
'set privateField back to "hello"
Assert.AreEqual("hello", classa.PropertyA)

pt = New PropertyType(classa.[GetType](), "privateField")
Assert.AreEqual("hello", pt.GetValue(classa))
pt.SetValue(classa, "world")
Assert.AreEqual("world", pt.GetValue(classa))
Assert.AreEqual("world", classa.PropertyA)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TraverseProperties Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : TraverseProperties Method

fromType
Any System.Type object to traverse from
propertyNames
The name of the properties or fields usually '.' delimited

Glossary Item Box

Walks a heirarchy of properties from the given type down. You can specify in any of the following ways: "ClientRectangle.X", "ClientRectangle/X"

Syntax

Visual Basic (Declaration)
Public Shared Function TraverseProperties( _
   ByVal fromType As Type, _
   ByVal ParamArray propertyNames() As String _
) As PropertyType
C#
public static PropertyType TraverseProperties(
   Type fromType,
   params string[] propertyNames
)

Parameters

fromType
Any System.Type object to traverse from
propertyNames
The name of the properties or fields usually '.' delimited

Example

Library/Library.Test/TestPropertyType.cs

C# Copy Code
PropertyType pt;
//Any of the following formats can be used
pt = PropertyType.TraverseProperties(typeof(b), "publicField.PropertyA.Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyType.TraverseProperties(typeof(b), "publicField", "PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyType.TraverseProperties(typeof(b), "publicField.PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyType.TraverseProperties(typeof(b), "publicField/PropertyA\\Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyType.TraverseProperties(typeof(b), "publicField\\PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyType.TraverseProperties(typeof(b), "publicField/PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
VB.NET Copy Code
Dim pt As PropertyType
'Any of the following formats can be used
pt = PropertyType.TraverseProperties(GetType(b), "publicField.PropertyA.Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyType.TraverseProperties(GetType(b), "publicField", "PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyType.TraverseProperties(GetType(b), "publicField.PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyType.TraverseProperties(GetType(b), "publicField/PropertyA\Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyType.TraverseProperties(GetType(b), "publicField\PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyType.TraverseProperties(GetType(b), "publicField/PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members

Used By

PropertySerializer.AddMember(String)

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
PropertyType Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyType Class

Glossary Item Box

For a list of all members of this type, see PropertyType members.

Public Properties

 | Name | Description
Public Property | Name | Returns the name of the property/field
Public Property | Type | Returns the type of the property/field
Top

See Also

Reference

PropertyType Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : Name Property

Glossary Item Box

Returns the name of the property/field

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Name As String
C#
public string Name {get;}

Example

Library/Library.Test/TestPropertyValue.cs

C# Copy Code
b obj = new b();
a obja = new a();
obj.publicField = obja;
obja.PropertyA = "test";

PropertyValue pt;
//Any of the following formats can be used
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA.Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField", "PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA\\Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField\\PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);

pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA");
Assert.AreEqual("PropertyA", pt.Name);
Assert.AreEqual(typeof(string), pt.Type);

Assert.AreEqual("test", pt.Value);
pt.Value = "b";
Assert.AreEqual("b", pt.Value);
VB.NET Copy Code
Dim obj As New b()
Dim obja As New a()
obj.publicField = obja
obja.PropertyA = "test"

Dim pt As PropertyValue
'Any of the following formats can be used
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA.Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField", "PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA\Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField\PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)

pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA")
Assert.AreEqual("PropertyA", pt.Name)
Assert.AreEqual(GetType(String), pt.Type)

Assert.AreEqual("test", pt.Value)
pt.Value = "b"
Assert.AreEqual("b", pt.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Type Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyType Class : Type Property

Glossary Item Box

Returns the type of the property/field

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Type As Type
C#
public Type Type {get;}

Example

Library/Library.Test/TestPropertyValue.cs

C# Copy Code
b obj = new b();
a obja = new a();
obj.publicField = obja;
obja.PropertyA = "test";

PropertyValue pt;
//Any of the following formats can be used
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA.Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField", "PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA\\Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField\\PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);

pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA");
Assert.AreEqual("PropertyA", pt.Name);
Assert.AreEqual(typeof(string), pt.Type);

Assert.AreEqual("test", pt.Value);
pt.Value = "b";
Assert.AreEqual("b", pt.Value);
VB.NET Copy Code
Dim obj As New b()
Dim obja As New a()
obj.publicField = obja
obja.PropertyA = "test"

Dim pt As PropertyValue
'Any of the following formats can be used
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA.Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField", "PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA\Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField\PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)

pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA")
Assert.AreEqual("PropertyA", pt.Name)
Assert.AreEqual(GetType(String), pt.Type)

Assert.AreEqual("test", pt.Value)
pt.Value = "b"
Assert.AreEqual("b", pt.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyType Class
PropertyType Members

Used By

PropertySerializer.Serialize(Object,INameValueStore)
PropertySerializer.Deserialize(Object,INameValueStore)
PropertyType PropertyType.TraverseProperties(Type,String[])

Source Code

Library/Reflection/PropertyType.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PropertyValue Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyValue Class

Glossary Item Box

Allows setting or getting a property or field on an object via reflection

Syntax

Visual Basic (Declaration)
Public Class PropertyValue
   Inherits PropertyType
C#
public class PropertyValue : PropertyType

Example

Library/Library.Test/TestPropertyValue.cs

C# Copy Code
a obj = new a();
obj.PropertyA = "a";
PropertyValue pt = new PropertyValue(obj, "privateField");

Assert.AreEqual("privateField", pt.Name);
Assert.AreEqual(typeof(string), pt.Type);
Assert.AreEqual("a", pt.Value);
pt.Value = "b";
Assert.AreEqual("b", pt.Value);
VB.NET Copy Code
Dim obj As New a()
obj.PropertyA = "a"
Dim pt As New PropertyValue(obj, "privateField")

Assert.AreEqual("privateField", pt.Name)
Assert.AreEqual(GetType(String), pt.Type)
Assert.AreEqual("a", pt.Value)
pt.Value = "b"
Assert.AreEqual("b", pt.Value)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Reflection.PropertyType
CSharpTest.Net.Reflection.PropertyValue
CSharpTest.Net.Reflection.PropertyValue<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyValue Members
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PropertyValue Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyValue Class

Glossary Item Box

The following tables list the members exposed by PropertyValue.

Public Constructors

 | Name | Description
Public Constructor | PropertyValue Constructor | Provided an instance of an object and the name of a property/field this object allows you to set/get the value in that property/field
Top

Public Properties

 | Name | Description
Public Property | Name | Returns the name of the property/field (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Property | Type | Returns the type of the property/field (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Property | Value | Gets or sets the value of the property
Top

Public Methods

 | Name | Description
Public Method | GetCustomAttributes | Overloaded. Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes. (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | GetValue | Returns the value of the property for the specified instance (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | IsDefined | Indicates whether one or more instance of attributeType is defined on this member. (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | SetValue | Sets the specified value for the instance supplied (Inherited from CSharpTest.Net.Reflection.PropertyType)
static (Shared in Visual Basic) | TraverseProperties | Walks a heirarchy of properties from the given type down. You can specify in any of the following ways: "ClientRectangle.X", "ClientRectangle/X"
Top

See Also

Reference

PropertyValue Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PropertyValue Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyValue Class : PropertyValue Constructor

instance
An instance of an object to retrieve the property/field from
name
The name of the property or field

Glossary Item Box

Provided an instance of an object and the name of a property/field this object allows you to set/get the value in that property/field

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal instance As Object, _
   ByVal name As String _
)
C#
public PropertyValue(
   object instance,
   string name
)

Parameters

instance
An instance of an object to retrieve the property/field from
name
The name of the property or field

Example

Library/Library.Test/TestPropertyValue.cs

C# Copy Code
a obj = new a();
obj.PropertyA = "a";
PropertyValue pt = new PropertyValue(obj, "privateField");

Assert.AreEqual("privateField", pt.Name);
Assert.AreEqual(typeof(string), pt.Type);
Assert.AreEqual("a", pt.Value);
pt.Value = "b";
Assert.AreEqual("b", pt.Value);
VB.NET Copy Code
Dim obj As New a()
obj.PropertyA = "a"
Dim pt As New PropertyValue(obj, "privateField")

Assert.AreEqual("privateField", pt.Name)
Assert.AreEqual(GetType(String), pt.Type)
Assert.AreEqual("a", pt.Value)
pt.Value = "b"
Assert.AreEqual("b", pt.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyValue Class
PropertyValue Members

Used By

PropertyValue PropertyValue.TraverseProperties(Object,String[])

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
PropertyValue Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyValue Class

Glossary Item Box

For a list of all members of this type, see PropertyValue members.

Public Methods

 | Name | Description
Public Method | GetCustomAttributes | Overloaded. Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes. (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | GetValue | Returns the value of the property for the specified instance (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | IsDefined | Indicates whether one or more instance of attributeType is defined on this member. (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | SetValue | Sets the specified value for the instance supplied (Inherited from CSharpTest.Net.Reflection.PropertyType)
static (Shared in Visual Basic) | TraverseProperties | Walks a heirarchy of properties from the given type down. You can specify in any of the following ways: "ClientRectangle.X", "ClientRectangle/X"
Top

See Also

Reference

PropertyValue Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TraverseProperties Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyValue Class : TraverseProperties Method

instance
Any object to begin the traverse from
propertyNames
The name of the properties or fields usually '.' delimited

Glossary Item Box

Walks a heirarchy of properties from the given type down. You can specify in any of the following ways: "ClientRectangle.X", "ClientRectangle/X"

Syntax

Visual Basic (Declaration)
Public Shared Function TraverseProperties( _
   ByVal instance As Object, _
   ByVal ParamArray propertyNames() As String _
) As PropertyValue
C#
public static PropertyValue TraverseProperties(
   object instance,
   params string[] propertyNames
)

Parameters

instance
Any object to begin the traverse from
propertyNames
The name of the properties or fields usually '.' delimited

Example

Library/Library.Test/TestPropertyValue.cs

C# Copy Code
b obj = new b();
a obja = new a();
obj.publicField = obja;
obja.PropertyA = "test";

PropertyValue pt;
//Any of the following formats can be used
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA.Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField", "PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA\\Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField\\PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);

pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA");
Assert.AreEqual("PropertyA", pt.Name);
Assert.AreEqual(typeof(string), pt.Type);

Assert.AreEqual("test", pt.Value);
pt.Value = "b";
Assert.AreEqual("b", pt.Value);
VB.NET Copy Code
Dim obj As New b()
Dim obja As New a()
obj.publicField = obja
obja.PropertyA = "test"

Dim pt As PropertyValue
'Any of the following formats can be used
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA.Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField", "PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA\Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField\PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)

pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA")
Assert.AreEqual("PropertyA", pt.Name)
Assert.AreEqual(GetType(String), pt.Type)

Assert.AreEqual("test", pt.Value)
pt.Value = "b"
Assert.AreEqual("b", pt.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyValue Class
PropertyValue Members

Used By

PropertySerializer.Serialize(Object,INameValueStore)
PropertySerializer.Deserialize(Object,INameValueStore)

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
PropertyValue Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyValue Class

Glossary Item Box

For a list of all members of this type, see PropertyValue members.

Public Properties

 | Name | Description
Public Property | Name | Returns the name of the property/field (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Property | Type | Returns the type of the property/field (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Property | Value | Gets or sets the value of the property
Top

See Also

Reference

PropertyValue Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyValue Class : Value Property

Glossary Item Box

Gets or sets the value of the property

Syntax

Visual Basic (Declaration)
Public Property Value As Object
C#
public object Value {get; set;}

Example

Library/Library.Test/TestPropertyValue.cs

C# Copy Code
b obj = new b();
a obja = new a();
obj.publicField = obja;
obja.PropertyA = "test";

PropertyValue pt;
//Any of the following formats can be used
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA.Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField", "PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA\\Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);
pt = PropertyValue.TraverseProperties(obj, "publicField\\PropertyA", "Length");
Assert.AreEqual("Length", pt.Name);
Assert.AreEqual(typeof(int), pt.Type);

pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA");
Assert.AreEqual("PropertyA", pt.Name);
Assert.AreEqual(typeof(string), pt.Type);

Assert.AreEqual("test", pt.Value);
pt.Value = "b";
Assert.AreEqual("b", pt.Value);
VB.NET Copy Code
Dim obj As New b()
Dim obja As New a()
obj.publicField = obja
obja.PropertyA = "test"

Dim pt As PropertyValue
'Any of the following formats can be used
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA.Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField", "PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField.PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA\Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)
pt = PropertyValue.TraverseProperties(obj, "publicField\PropertyA", "Length")
Assert.AreEqual("Length", pt.Name)
Assert.AreEqual(GetType(Integer), pt.Type)

pt = PropertyValue.TraverseProperties(obj, "publicField/PropertyA")
Assert.AreEqual("PropertyA", pt.Name)
Assert.AreEqual(GetType(String), pt.Type)

Assert.AreEqual("test", pt.Value)
pt.Value = "b"
Assert.AreEqual("b", pt.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyValue Class
PropertyValue Members

Used By

PropertySerializer.Serialize(Object,INameValueStore)
PropertySerializer.Deserialize(Object,INameValueStore)
PropertyValue PropertyValue.TraverseProperties(Object,String[])

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
PropertyValue<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyValue<T> Class

Glossary Item Box

Allows setting or getting a property or field of a known type on an object via reflection

Syntax

Visual Basic (Declaration)
Public Class PropertyValue(Of T)
   Inherits PropertyValue
C#
public class PropertyValue<T> : PropertyValue

Type Parameters

T

Example

Library/Library.Test/TestPropertyValue.cs

C# Copy Code
a obj = new a();
obj.PropertyA = "a";
PropertyValue<string> pt = new PropertyValue<string>(obj, "privateField");
Assert.AreEqual("a", pt.Value);
pt.Value = "b";
Assert.AreEqual("b", pt.Value);
VB.NET Copy Code
Dim obj As New a()
obj.PropertyA = "a"
Dim pt As New PropertyValue(Of String)(obj, "privateField")
Assert.AreEqual("a", pt.Value)
pt.Value = "b"
Assert.AreEqual("b", pt.Value)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Reflection.PropertyType
CSharpTest.Net.Reflection.PropertyValue
CSharpTest.Net.Reflection.PropertyValue<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyValue<T> Members
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PropertyValue<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyValue<T> Class

Glossary Item Box

The following tables list the members exposed by PropertyValue<T>.

Public Constructors

 | Name | Description
Public Constructor | PropertyValue<T> Constructor | Provided an instance of an object and the name of a property/field this object allows you to set/get the value in that property/field
Top

Public Properties

 | Name | Description
Public Property | Name | Returns the name of the property/field (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Property | Type | Returns the type of the property/field (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Property | Value | Gets or sets the value of the property
Top

Public Methods

 | Name | Description
Public Method | GetCustomAttributes | Overloaded. Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes. (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | GetValue | Returns the value of the property for the specified instance (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | IsDefined | Indicates whether one or more instance of attributeType is defined on this member. (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | SetValue | Sets the specified value for the instance supplied (Inherited from CSharpTest.Net.Reflection.PropertyType)
Top

See Also

Reference

PropertyValue<T> Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PropertyValue<T> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyValue<T> Class : PropertyValue<T> Constructor

instance
An instance of an object to retrieve the property/field from
name
The name of the property or field

Glossary Item Box

Provided an instance of an object and the name of a property/field this object allows you to set/get the value in that property/field

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal instance As Object, _
   ByVal name As String _
)
C#
public PropertyValue<T>(
   object instance,
   string name
)

Parameters

instance
An instance of an object to retrieve the property/field from
name
The name of the property or field

Example

Library/Library.Test/TestPropertyValue.cs

C# Copy Code
a obj = new a();
obj.PropertyA = "a";
PropertyValue<string> pt = new PropertyValue<string>(obj, "privateField");
Assert.AreEqual("a", pt.Value);
pt.Value = "b";
Assert.AreEqual("b", pt.Value);
VB.NET Copy Code
Dim obj As New a()
obj.PropertyA = "a"
Dim pt As New PropertyValue(Of String)(obj, "privateField")
Assert.AreEqual("a", pt.Value)
pt.Value = "b"
Assert.AreEqual("b", pt.Value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyValue<T> Class
PropertyValue<T> Members

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
PropertyValue<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyValue<T> Class

Glossary Item Box

For a list of all members of this type, see PropertyValue<T> members.

Public Properties

 | Name | Description
Public Property | Name | Returns the name of the property/field (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Property | Type | Returns the type of the property/field (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Property | Value | Gets or sets the value of the property
Top

See Also

Reference

PropertyValue<T> Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyValue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertyValue<T> Class : Value Property

Glossary Item Box

Gets or sets the value of the property

Syntax

Visual Basic (Declaration)
Public Shadows Property Value As T
C#
public new T Value {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertyValue<T> Class
PropertyValue<T> Members

Source Code

Library/Reflection/PropertyValue.cs


%%ItemTitle%%

CSharpTest.Net.Serialization Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Serialization Namespace

Glossary Item Box

Classes

 | Class | Description
Class | BytesSerializer | Returns all bytes in the stream, or writes all bytes to the stream
Class | KeyValueSerializer<TKey,TValue> | Implements ISerializer of KeyValuePair<TKey, TValue>
Class | LimitedSerializer | Reads the same variant prefixed string and byte[] but with a hard-limit on size
Class | PrimitiveSerializer | Provides simple implementations of ISerializer<T> for the primitive .Net types.
Class | SerializerExtensions | Extension methods used with ISerializer<T> for byte[] transformations
Class | Storage | Used with one of the implementations in the StorageClasses namespace, this class provides rich-type storage on top of the basic INameValueStore string storage container.
Class | VariantNumberSerializer | Provides numeric serializers for packed int/long values.

Interfaces

 | Interface | Description
Interface | INameValueStore | provides a basic inteface for a reader/writer of string name/value pairs
Interface | ISerializer<T> | Provides serialization for a type

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
BytesSerializer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : BytesSerializer Class

Glossary Item Box

Returns all bytes in the stream, or writes all bytes to the stream

Syntax

Visual Basic (Declaration)
Public Class BytesSerializer
   Implements CSharpTest.Net.Serialization.ISerializer(Of Byte())
C#
public class BytesSerializer : CSharpTest.Net.Serialization.ISerializer<byte[]>

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.BytesSerializer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BytesSerializer Members
CSharpTest.Net.Serialization Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
BytesSerializer Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : BytesSerializer Class

Glossary Item Box

The following tables list the members exposed by BytesSerializer.

Public Constructors

 | Name | Description
Public Constructor | BytesSerializer Constructor |
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | RawBytes | Gets a singleton of the BytesSerializer class
Top

See Also

Reference

BytesSerializer Class
CSharpTest.Net.Serialization Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
BytesSerializer Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > BytesSerializer Class : BytesSerializer Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public BytesSerializer()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BytesSerializer Class
BytesSerializer Members


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
BytesSerializer Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : BytesSerializer Class

Glossary Item Box

For a list of all members of this type, see BytesSerializer members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | RawBytes | Gets a singleton of the BytesSerializer class
Top

See Also

Reference

BytesSerializer Class
CSharpTest.Net.Serialization Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
RawBytes Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > BytesSerializer Class : RawBytes Field

Glossary Item Box

Gets a singleton of the BytesSerializer class

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly RawBytes As ISerializer(Of Byte())
C#
public static readonly ISerializer<byte[]> RawBytes

Example

Library/Library.Test/TestPrimitiveSerializer.cs

C# Copy Code
byte[] bytes = new byte[256];
_random.NextBytes(bytes);

using (MemoryStream ms = new MemoryStream())
{
    BytesSerializer.RawBytes.WriteTo(bytes, ms);
    ms.Position = 0;
    Assert.AreEqual(bytes, BytesSerializer.RawBytes.ReadFrom(ms));
}
VB.NET Copy Code
Dim bytes As Byte() = New Byte(256) {}
_random.NextBytes(bytes)

Using ms As New MemoryStream()
    BytesSerializer.RawBytes.WriteTo(bytes, ms)
    ms.Position = 0
    Assert.AreEqual(bytes, BytesSerializer.RawBytes.ReadFrom(ms))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BytesSerializer Class
BytesSerializer Members


%%PageItemTitle%%

TKey
TValue
[image]
CSharpTest.Net
KeyValueSerializer<TKey,TValue> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : KeyValueSerializer<TKey,TValue> Class

Glossary Item Box

Implements ISerializer of KeyValuePair<TKey, TValue>

Syntax

Visual Basic (Declaration)
Public NotInheritable Class KeyValueSerializer
    (Of TKey,TValue)
   Implements CSharpTest.Net.Serialization.ISerializer(Of KeyValuePair(Of TKey,TValue))
C#
public sealed class KeyValueSerializer<TKey,TValue> : CSharpTest.Net.Serialization.ISerializer<KeyValuePair<TKey,TValue>>

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestPrimitiveSerializer.cs

C# Copy Code
ISerializer<KeyValuePair<int, Guid>> ser = new KeyValueSerializer<int, Guid>(PrimitiveSerializer.Int32, PrimitiveSerializer.Guid);
Dictionary<int, Guid> values = new Dictionary<int, Guid>
{
    { -1, Guid.NewGuid() },
    { 0, Guid.NewGuid() },
    { 1, Guid.NewGuid() },
    { int.MaxValue, Guid.NewGuid() },
};

foreach (KeyValuePair<int, Guid> value in values)
{
    using (MemoryStream ms = new MemoryStream())
    {
        ser.WriteTo(value, ms);
        // add random bytes, every value should know it's length and not rely on EOF.
        byte[] bytes = new byte[256 - ms.Position];
        _random.NextBytes(bytes);
        ms.Write(bytes, 0, bytes.Length);
        // seek begin and read.
        ms.Position = 0;
        Assert.AreEqual(value, ser.ReadFrom(ms));
    }
}
VB.NET Copy Code
Dim ser As ISerializer(Of KeyValuePair(Of Integer, Guid)) = New KeyValueSerializer(Of Integer, Guid)(PrimitiveSerializer.Int32, PrimitiveSerializer.Guid)
Dim values As New Dictionary(Of Integer, Guid)() From { _
    {-1, Guid.NewGuid()}, _
    {0, Guid.NewGuid()}, _
    {1, Guid.NewGuid()}, _
    {Integer.MaxValue, Guid.NewGuid()} _
}

For Each value As KeyValuePair(Of Integer, Guid) In values
    Using ms As New MemoryStream()
        ser.WriteTo(value, ms)
        ' add random bytes, every value should know it's length and not rely on EOF.
        Dim bytes As Byte() = New Byte(256 - ms.Position) {}
        _random.NextBytes(bytes)
        ms.Write(bytes, 0, bytes.Length)
        ' seek begin and read.
        ms.Position = 0
        Assert.AreEqual(value, ser.ReadFrom(ms))
    End Using
Next

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.KeyValueSerializer<TKey,TValue>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

KeyValueSerializer<TKey,TValue> Members
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/KeyValueSerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
KeyValueSerializer<TKey,TValue> Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : KeyValueSerializer<TKey,TValue> Class

Glossary Item Box

The following tables list the members exposed by KeyValueSerializer<TKey,TValue>.

Public Constructors

 | Name | Description
Public Constructor | KeyValueSerializer<TKey,TValue> Constructor | Provide the key/value serializers to use.
Top

Public Methods

 | Name | Description
Public Method | ReadFrom | Reads the object from a stream
Public Method | WriteTo | Writes the object to the stream
Top

See Also

Reference

KeyValueSerializer<TKey,TValue> Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/KeyValueSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
KeyValueSerializer<TKey,TValue> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > KeyValueSerializer<TKey,TValue> Class : KeyValueSerializer<TKey,TValue> Constructor

keySerializer
valueSerializer

Glossary Item Box

Provide the key/value serializers to use.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal keySerializer As ISerializer(Of TKey), _
   ByVal valueSerializer As ISerializer(Of TValue) _
)
C#
public KeyValueSerializer<TKey,TValue>(
   ISerializer<TKey> keySerializer,
   ISerializer<TValue> valueSerializer
)

Parameters

keySerializer
valueSerializer

Example

Library/Library.Test/TestPrimitiveSerializer.cs

C# Copy Code
ISerializer<KeyValuePair<int, Guid>> ser = new KeyValueSerializer<int, Guid>(PrimitiveSerializer.Int32, PrimitiveSerializer.Guid);
Dictionary<int, Guid> values = new Dictionary<int, Guid>
{
    { -1, Guid.NewGuid() },
    { 0, Guid.NewGuid() },
    { 1, Guid.NewGuid() },
    { int.MaxValue, Guid.NewGuid() },
};

foreach (KeyValuePair<int, Guid> value in values)
{
    using (MemoryStream ms = new MemoryStream())
    {
        ser.WriteTo(value, ms);
        // add random bytes, every value should know it's length and not rely on EOF.
        byte[] bytes = new byte[256 - ms.Position];
        _random.NextBytes(bytes);
        ms.Write(bytes, 0, bytes.Length);
        // seek begin and read.
        ms.Position = 0;
        Assert.AreEqual(value, ser.ReadFrom(ms));
    }
}
VB.NET Copy Code
Dim ser As ISerializer(Of KeyValuePair(Of Integer, Guid)) = New KeyValueSerializer(Of Integer, Guid)(PrimitiveSerializer.Int32, PrimitiveSerializer.Guid)
Dim values As New Dictionary(Of Integer, Guid)() From { _
    {-1, Guid.NewGuid()}, _
    {0, Guid.NewGuid()}, _
    {1, Guid.NewGuid()}, _
    {Integer.MaxValue, Guid.NewGuid()} _
}

For Each value As KeyValuePair(Of Integer, Guid) In values
    Using ms As New MemoryStream()
        ser.WriteTo(value, ms)
        ' add random bytes, every value should know it's length and not rely on EOF.
        Dim bytes As Byte() = New Byte(256 - ms.Position) {}
        _random.NextBytes(bytes)
        ms.Write(bytes, 0, bytes.Length)
        ' seek begin and read.
        ms.Position = 0
        Assert.AreEqual(value, ser.ReadFrom(ms))
    End Using
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

KeyValueSerializer<TKey,TValue> Class
KeyValueSerializer<TKey,TValue> Members

Used By

Int32 BPlusTree.BulkInsert(IEnumerable>,BulkInsertOptions)

Source Code

Library/Serialization/KeyValueSerializer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
KeyValueSerializer<TKey,TValue> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : KeyValueSerializer<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see KeyValueSerializer<TKey,TValue> members.

Public Methods

 | Name | Description
Public Method | ReadFrom | Reads the object from a stream
Public Method | WriteTo | Writes the object to the stream
Top

See Also

Reference

KeyValueSerializer<TKey,TValue> Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/KeyValueSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadFrom Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > KeyValueSerializer<TKey,TValue> Class : ReadFrom Method

stream

Glossary Item Box

Reads the object from a stream

Syntax

Visual Basic (Declaration)
Public Function ReadFrom( _
   ByVal stream As Stream _
) As KeyValuePair(Of TKey,TValue)
C#
public KeyValuePair<TKey,TValue> ReadFrom(
   Stream stream
)

Parameters

stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

KeyValueSerializer<TKey,TValue> Class
KeyValueSerializer<TKey,TValue> Members

Source Code

Library/Serialization/KeyValueSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteTo Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > KeyValueSerializer<TKey,TValue> Class : WriteTo Method

value
stream

Glossary Item Box

Writes the object to the stream

Syntax

Visual Basic (Declaration)
Public Sub WriteTo( _
   ByVal value As KeyValuePair(Of TKey,TValue), _
   ByVal stream As Stream _
)
C#
public void WriteTo(
   KeyValuePair<TKey,TValue> value,
   Stream stream
)

Parameters

value
stream

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

KeyValueSerializer<TKey,TValue> Class
KeyValueSerializer<TKey,TValue> Members

Source Code

Library/Serialization/KeyValueSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LimitedSerializer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : LimitedSerializer Class

Glossary Item Box

Reads the same variant prefixed string and byte[] but with a hard-limit on size

Syntax

Visual Basic (Declaration)
Public Class LimitedSerializer
   Implements CSharpTest.Net.Serialization.ISerializer(Of Byte()), CSharpTest.Net.Serialization.ISerializer(Of String)
C#
public class LimitedSerializer : CSharpTest.Net.Serialization.ISerializer<byte[]>, CSharpTest.Net.Serialization.ISerializer<string>

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.LimitedSerializer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Members
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LimitedSerializer Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : LimitedSerializer Class

Glossary Item Box

The following tables list the members exposed by LimitedSerializer.

Public Constructors

 | Name | Description
Public Constructor | LimitedSerializer Constructor | Constructs a limited length-prefix data reader/writer
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Bytes1024 | Reads up to 1024 length-prefixed byte array
static (Shared in Visual Basic) | Bytes2048 | Reads up to 2048 length-prefixed byte array
static (Shared in Visual Basic) | Bytes4092 | Reads up to 4092 length-prefixed byte array
static (Shared in Visual Basic) | Bytes8196 | Reads up to 8196 length-prefixed byte array
static (Shared in Visual Basic) | String1024 | Reads up to 1024 length-prefixed string
static (Shared in Visual Basic) | String256 | Reads up to 256 length-prefixed string
static (Shared in Visual Basic) | String512 | Reads up to 512 length-prefixed string
Top

See Also

Reference

LimitedSerializer Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LimitedSerializer Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > LimitedSerializer Class : LimitedSerializer Constructor

maxLength

Glossary Item Box

Constructs a limited length-prefix data reader/writer

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal maxLength As Integer _
)
C#
public LimitedSerializer(
   int maxLength
)

Parameters

maxLength

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Class
LimitedSerializer Members

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
LimitedSerializer Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : LimitedSerializer Class

Glossary Item Box

For a list of all members of this type, see LimitedSerializer members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Bytes1024 | Reads up to 1024 length-prefixed byte array
static (Shared in Visual Basic) | Bytes2048 | Reads up to 2048 length-prefixed byte array
static (Shared in Visual Basic) | Bytes4092 | Reads up to 4092 length-prefixed byte array
static (Shared in Visual Basic) | Bytes8196 | Reads up to 8196 length-prefixed byte array
static (Shared in Visual Basic) | String1024 | Reads up to 1024 length-prefixed string
static (Shared in Visual Basic) | String256 | Reads up to 256 length-prefixed string
static (Shared in Visual Basic) | String512 | Reads up to 512 length-prefixed string
Top

See Also

Reference

LimitedSerializer Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Bytes1024 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > LimitedSerializer Class : Bytes1024 Field

Glossary Item Box

Reads up to 1024 length-prefixed byte array

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Bytes1024 As ISerializer(Of Byte())
C#
public static readonly ISerializer<byte[]> Bytes1024

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Class
LimitedSerializer Members

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Bytes2048 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > LimitedSerializer Class : Bytes2048 Field

Glossary Item Box

Reads up to 2048 length-prefixed byte array

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Bytes2048 As ISerializer(Of Byte())
C#
public static readonly ISerializer<byte[]> Bytes2048

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Class
LimitedSerializer Members

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Bytes4092 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > LimitedSerializer Class : Bytes4092 Field

Glossary Item Box

Reads up to 4092 length-prefixed byte array

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Bytes4092 As ISerializer(Of Byte())
C#
public static readonly ISerializer<byte[]> Bytes4092

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Class
LimitedSerializer Members

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Bytes8196 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > LimitedSerializer Class : Bytes8196 Field

Glossary Item Box

Reads up to 8196 length-prefixed byte array

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Bytes8196 As ISerializer(Of Byte())
C#
public static readonly ISerializer<byte[]> Bytes8196

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Class
LimitedSerializer Members

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
String1024 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > LimitedSerializer Class : String1024 Field

Glossary Item Box

Reads up to 1024 length-prefixed string

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly String1024 As ISerializer(Of String)
C#
public static readonly ISerializer<string> String1024

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Class
LimitedSerializer Members

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
String256 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > LimitedSerializer Class : String256 Field

Glossary Item Box

Reads up to 256 length-prefixed string

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly String256 As ISerializer(Of String)
C#
public static readonly ISerializer<string> String256

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Class
LimitedSerializer Members

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
String512 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > LimitedSerializer Class : String512 Field

Glossary Item Box

Reads up to 512 length-prefixed string

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly String512 As ISerializer(Of String)
C#
public static readonly ISerializer<string> String512

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LimitedSerializer Class
LimitedSerializer Members

Source Code

Library/Serialization/LimitedSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PrimitiveSerializer Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : PrimitiveSerializer Class

Glossary Item Box

Provides simple implementations of ISerializer<T> for the primitive .Net types.

Syntax

Visual Basic (Declaration)
Public Class PrimitiveSerializer
   Implements CSharpTest.Net.Serialization.ISerializer(Of Boolean), CSharpTest.Net.Serialization.ISerializer(Of Byte()), CSharpTest.Net.Serialization.ISerializer(Of Byte), CSharpTest.Net.Serialization.ISerializer(Of Char), CSharpTest.Net.Serialization.ISerializer(Of Date), CSharpTest.Net.Serialization.ISerializer(Of Double), CSharpTest.Net.Serialization.ISerializer(Of Guid), CSharpTest.Net.Serialization.ISerializer(Of Short), CSharpTest.Net.Serialization.ISerializer(Of Integer), CSharpTest.Net.Serialization.ISerializer(Of Long), CSharpTest.Net.Serialization.ISerializer(Of IntPtr), CSharpTest.Net.Serialization.ISerializer(Of SByte), CSharpTest.Net.Serialization.ISerializer(Of Single), CSharpTest.Net.Serialization.ISerializer(Of String), CSharpTest.Net.Serialization.ISerializer(Of TimeSpan), CSharpTest.Net.Serialization.ISerializer(Of UShort), CSharpTest.Net.Serialization.ISerializer(Of UInteger), CSharpTest.Net.Serialization.ISerializer(Of ULong), CSharpTest.Net.Serialization.ISerializer(Of UIntPtr)
C#
public class PrimitiveSerializer : CSharpTest.Net.Serialization.ISerializer<bool>, CSharpTest.Net.Serialization.ISerializer<byte[]>, CSharpTest.Net.Serialization.ISerializer<byte>, CSharpTest.Net.Serialization.ISerializer<char>, CSharpTest.Net.Serialization.ISerializer<DateTime>, CSharpTest.Net.Serialization.ISerializer<double>, CSharpTest.Net.Serialization.ISerializer<Guid>, CSharpTest.Net.Serialization.ISerializer<short>, CSharpTest.Net.Serialization.ISerializer<int>, CSharpTest.Net.Serialization.ISerializer<long>, CSharpTest.Net.Serialization.ISerializer<IntPtr>, CSharpTest.Net.Serialization.ISerializer<sbyte>, CSharpTest.Net.Serialization.ISerializer<float>, CSharpTest.Net.Serialization.ISerializer<string>, CSharpTest.Net.Serialization.ISerializer<TimeSpan>, CSharpTest.Net.Serialization.ISerializer<ushort>, CSharpTest.Net.Serialization.ISerializer<uint>, CSharpTest.Net.Serialization.ISerializer<ulong>, CSharpTest.Net.Serialization.ISerializer<UIntPtr>

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<int, int>.OptionsV2 options = new BPlusTree<int, int>.OptionsV2(
    new PrimitiveSerializer(), new PrimitiveSerializer());
options.LockTimeout = 100;
options.CallLevelLock = new ReaderWriterLocking();

using (BPlusTree<int, int> dictionary = new BPlusTree<int, int>(options))
{
    bool canwrite = false, canread = false;
    ThreadStart proc = delegate()
    {
        try { dictionary[1] = 1; canwrite = true; } catch { canwrite = false; }
        try { int i; dictionary.TryGetValue(1, out i); canread = true; } catch { canread = false; }
    };

    Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
    Assert.IsTrue(canwrite);
    Assert.IsTrue(canread);

    //now we lock the entire btree:
    using (dictionary.CallLevelLock.Write())
    {
        //they can't read or write
        Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
        Assert.IsFalse(canwrite);
        Assert.IsFalse(canread);
        //but we can
        proc();
        Assert.IsTrue(canwrite);
        Assert.IsTrue(canread);
    }
    //lock release all is well
    Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
    Assert.IsTrue(canwrite);
    Assert.IsTrue(canread);

    //We can also make sure noone else gains exclusive access with a read lock
    using (dictionary.CallLevelLock.Read())
    {
        Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
        Assert.IsTrue(canwrite);
        Assert.IsTrue(canread);
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of Integer, Integer).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer())
options.LockTimeout = 100
options.CallLevelLock = New ReaderWriterLocking()

Using dictionary As New BPlusTree(Of Integer, Integer)(options)
    Dim canwrite As Boolean = False, canread As Boolean = False
    Dim proc As ThreadStart = Function() Do
        Try
            dictionary(1) = 1
            canwrite = True
        Catch
            canwrite = False
        End Try
        Try
            Dim i As Integer
            dictionary.TryGetValue(1, i)
            canread = True
        Catch
            canread = False
        End Try
    End Function

    Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
    Assert.IsTrue(canwrite)
    Assert.IsTrue(canread)

    'now we lock the entire btree:
    Using dictionary.CallLevelLock.Write()
        'they can't read or write
        Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
        Assert.IsFalse(canwrite)
        Assert.IsFalse(canread)
        'but we can
        proc()
        Assert.IsTrue(canwrite)
        Assert.IsTrue(canread)
    End Using
    'lock release all is well
    Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
    Assert.IsTrue(canwrite)
    Assert.IsTrue(canread)

    'We can also make sure noone else gains exclusive access with a read lock
    Using dictionary.CallLevelLock.Read()
        Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
        Assert.IsTrue(canwrite)
        Assert.IsTrue(canread)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.PrimitiveSerializer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Members
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
PrimitiveSerializer Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : PrimitiveSerializer Class

Glossary Item Box

The following tables list the members exposed by PrimitiveSerializer.

Public Constructors

 | Name | Description
Public Constructor | PrimitiveSerializer Constructor |
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Boolean | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Byte | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Bytes | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Char | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | DateTime | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Double | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Float | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Guid | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Instance | Gets a singleton of the PrimitiveSerializer
static (Shared in Visual Basic) | Int16 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Int32 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Int64 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | IntPtr | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | SByte | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | String | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | TimeSpan | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | UInt16 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | UInt32 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | UInt64 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | UIntPtr | Gets a typed version of the PrimitiveSerializer
Top

See Also

Reference

PrimitiveSerializer Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PrimitiveSerializer Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : PrimitiveSerializer Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public PrimitiveSerializer()

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<int, int>.OptionsV2 options = new BPlusTree<int, int>.OptionsV2(
    new PrimitiveSerializer(), new PrimitiveSerializer());
options.LockTimeout = 100;
options.CallLevelLock = new ReaderWriterLocking();

using (BPlusTree<int, int> dictionary = new BPlusTree<int, int>(options))
{
    bool canwrite = false, canread = false;
    ThreadStart proc = delegate()
    {
        try { dictionary[1] = 1; canwrite = true; } catch { canwrite = false; }
        try { int i; dictionary.TryGetValue(1, out i); canread = true; } catch { canread = false; }
    };

    Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
    Assert.IsTrue(canwrite);
    Assert.IsTrue(canread);

    //now we lock the entire btree:
    using (dictionary.CallLevelLock.Write())
    {
        //they can't read or write
        Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
        Assert.IsFalse(canwrite);
        Assert.IsFalse(canread);
        //but we can
        proc();
        Assert.IsTrue(canwrite);
        Assert.IsTrue(canread);
    }
    //lock release all is well
    Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
    Assert.IsTrue(canwrite);
    Assert.IsTrue(canread);

    //We can also make sure noone else gains exclusive access with a read lock
    using (dictionary.CallLevelLock.Read())
    {
        Assert.IsTrue(proc.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(1000, false));
        Assert.IsTrue(canwrite);
        Assert.IsTrue(canread);
    }
}
VB.NET Copy Code
Dim options As New BPlusTree(Of Integer, Integer).OptionsV2(New PrimitiveSerializer(), New PrimitiveSerializer())
options.LockTimeout = 100
options.CallLevelLock = New ReaderWriterLocking()

Using dictionary As New BPlusTree(Of Integer, Integer)(options)
    Dim canwrite As Boolean = False, canread As Boolean = False
    Dim proc As ThreadStart = Function() Do
        Try
            dictionary(1) = 1
            canwrite = True
        Catch
            canwrite = False
        End Try
        Try
            Dim i As Integer
            dictionary.TryGetValue(1, i)
            canread = True
        Catch
            canread = False
        End Try
    End Function

    Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
    Assert.IsTrue(canwrite)
    Assert.IsTrue(canread)

    'now we lock the entire btree:
    Using dictionary.CallLevelLock.Write()
        'they can't read or write
        Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
        Assert.IsFalse(canwrite)
        Assert.IsFalse(canread)
        'but we can
        proc()
        Assert.IsTrue(canwrite)
        Assert.IsTrue(canread)
    End Using
    'lock release all is well
    Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
    Assert.IsTrue(canwrite)
    Assert.IsTrue(canread)

    'We can also make sure noone else gains exclusive access with a read lock
    Using dictionary.CallLevelLock.Read()
        Assert.IsTrue(proc.BeginInvoke(Nothing, Nothing).AsyncWaitHandle.WaitOne(1000, False))
        Assert.IsTrue(canwrite)
        Assert.IsTrue(canread)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Used By

TestMultiInstance.TestReadOnlyCopy()
TestMultiInstance.TestSyncFromLogging()
ThreadedBTreeTest.TestCallLevelLocking()

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
PrimitiveSerializer Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : PrimitiveSerializer Class

Glossary Item Box

For a list of all members of this type, see PrimitiveSerializer members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Boolean | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Byte | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Bytes | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Char | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | DateTime | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Double | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Float | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Guid | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Instance | Gets a singleton of the PrimitiveSerializer
static (Shared in Visual Basic) | Int16 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Int32 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | Int64 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | IntPtr | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | SByte | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | String | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | TimeSpan | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | UInt16 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | UInt32 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | UInt64 | Gets a typed version of the PrimitiveSerializer
static (Shared in Visual Basic) | UIntPtr | Gets a typed version of the PrimitiveSerializer
Top

See Also

Reference

PrimitiveSerializer Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Boolean Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Boolean Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Boolean As ISerializer(Of Boolean)
C#
public static readonly ISerializer<bool> Boolean

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Byte Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Byte Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Byte As ISerializer(Of Byte)
C#
public static readonly ISerializer<byte> Byte

Example

Library/Library.Test/TestOrderedEnumeration.cs

C# Copy Code
byte[] input = new byte[512];
new Random().NextBytes(input);
var ordered = new OrderedEnumeration<byte>(input);
ordered.Serializer = PrimitiveSerializer.Byte;
ordered.InMemoryLimit = 10;
ordered.DuplicateHandling = DuplicateHandling.FirstValueWins;

using (var e = ordered.GetEnumerator())
    Assert.IsTrue(e.MoveNext());
VB.NET Copy Code
Dim input As Byte() = New Byte(512) {}
New Random().NextBytes(input)
Dim ordered As var = New OrderedEnumeration(Of Byte)(input)
ordered.Serializer = PrimitiveSerializer.[Byte]
ordered.InMemoryLimit = 10
ordered.DuplicateHandling = DuplicateHandling.FirstValueWins

Using e As var = ordered.GetEnumerator()
    Assert.IsTrue(e.MoveNext())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Bytes Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Bytes Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Bytes As ISerializer(Of Byte())
C#
public static readonly ISerializer<byte[]> Bytes

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
//Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
//Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
//Logged 2,398,000,000 bytes in: 00:00:36.7621027

string newpath = Path.Combine(@"C:\Temp\LogTest\", Guid.NewGuid() + ".tmp");
using (TempFile tmp = TempFile.Attach(newpath))
{
    byte[] bytes;
    DateTime start;
    //bytes = new byte[128];
    //new Random().NextBytes(bytes);

    //start = DateTime.UtcNow;
    //using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    //{
    //    for (int i = 0; i <= 16777216; i++)
    //        io.Write(bytes, 0, 128);
    //}
    //Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    //tmp.Delete();

    var options = new TransactionLogOptions<Guid, byte[]>(
        tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes)
        {
            FileBuffer = ushort.MaxValue,
            FileOptions = FileOptions.None | FileOptions.SequentialScan,
        };

    Guid[] ids = new Guid[1000000];
    for (int i = 0; i < ids.Length; i++)
        ids[i] = Guid.NewGuid();

    bytes = new byte[100];
    new Random().NextBytes(bytes);

    start = DateTime.UtcNow;

    using (var log = new TransactionLog<Guid, byte[]>(options))
    {
        foreach(Guid id in ids)
        {
            var token = log.BeginTransaction();
            for (int i = 0; i < 20; i++)
                log.AddValue(ref token, id, bytes);
            log.CommitTransaction(ref token);
        }
    }

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
}
VB.NET Copy Code
'Write 2,147,483,776 bytes in: 00:02:09.7934237 (in chunks of 128 bytes)
'Write 4,295,032,832 bytes in: 00:00:18.4990581 (in chunks of 65536 bytes)
'Logged 2,398,000,000 bytes in: 00:00:36.7621027

Dim newpath As String = Path.Combine("C:\Temp\LogTest\", Guid.NewGuid() + ".tmp")
Using tmp As TempFile = TempFile.Attach(newpath)
    Dim bytes As Byte()
    Dim start As DateTime
    'bytes = new byte[128];
    'new Random().NextBytes(bytes);

    'start = DateTime.UtcNow;
    'using (var io = new FileStream(tmp.TempPath, FileMode.Append, FileAccess.Write, FileShare.Read, 8))
    '{
    '    for (int i = 0; i <= 16777216; i++)
    '        io.Write(bytes, 0, 128);
    '}
    'Console.WriteLine("Write {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start);
    'tmp.Delete();

    Dim options As var = New TransactionLogOptions(Of Guid, Byte())(tmp.TempPath, PrimitiveSerializer.Guid, PrimitiveSerializer.Bytes) With { _
        Key .FileBuffer = UShort.MaxValue, _
        Key .FileOptions = FileOptions.None Or FileOptions.SequentialScan _
    }

    Dim ids As Guid() = New Guid(1000000) {}
    Dim i As Integer = 0
    While i < ids.Length
        ids(i) = Guid.NewGuid()
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    bytes = New Byte(100) {}
    New Random().NextBytes(bytes)

    start = DateTime.UtcNow

    Using log As var = New TransactionLog(Of Guid, Byte())(options)
        For Each id As Guid In ids
            Dim token As var = log.BeginTransaction()
            Dim i As Integer = 0
            While i < 20
                log.AddValue(token, id, bytes)
                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
            End While
            log.CommitTransaction(token)
        Next
    End Using

    Console.WriteLine("Logged {0:n0} bytes in: {1}", tmp.Length, DateTime.UtcNow - start)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Used By

TestTransactionLog.TestBenchmarkWriteSpeed()

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Char Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Char Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Char As ISerializer(Of Char)
C#
public static readonly ISerializer<char> Char

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DateTime Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : DateTime Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly DateTime As ISerializer(Of Date)
C#
public static readonly ISerializer<DateTime> DateTime

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Double Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Double Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Double As ISerializer(Of Double)
C#
public static readonly ISerializer<double> Double

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Float Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Float Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Float As ISerializer(Of Single)
C#
public static readonly ISerializer<float> Float

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Guid Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Guid Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Guid As ISerializer(Of Guid)
C#
public static readonly ISerializer<Guid> Guid

Example

Library/Library.Test/TestPrimitiveSerializer.cs

C# Copy Code
ISerializer<KeyValuePair<int, Guid>> ser = new KeyValueSerializer<int, Guid>(PrimitiveSerializer.Int32, PrimitiveSerializer.Guid);
Dictionary<int, Guid> values = new Dictionary<int, Guid>
{
    { -1, Guid.NewGuid() },
    { 0, Guid.NewGuid() },
    { 1, Guid.NewGuid() },
    { int.MaxValue, Guid.NewGuid() },
};

foreach (KeyValuePair<int, Guid> value in values)
{
    using (MemoryStream ms = new MemoryStream())
    {
        ser.WriteTo(value, ms);
        // add random bytes, every value should know it's length and not rely on EOF.
        byte[] bytes = new byte[256 - ms.Position];
        _random.NextBytes(bytes);
        ms.Write(bytes, 0, bytes.Length);
        // seek begin and read.
        ms.Position = 0;
        Assert.AreEqual(value, ser.ReadFrom(ms));
    }
}
VB.NET Copy Code
Dim ser As ISerializer(Of KeyValuePair(Of Integer, Guid)) = New KeyValueSerializer(Of Integer, Guid)(PrimitiveSerializer.Int32, PrimitiveSerializer.Guid)
Dim values As New Dictionary(Of Integer, Guid)() From { _
    {-1, Guid.NewGuid()}, _
    {0, Guid.NewGuid()}, _
    {1, Guid.NewGuid()}, _
    {Integer.MaxValue, Guid.NewGuid()} _
}

For Each value As KeyValuePair(Of Integer, Guid) In values
    Using ms As New MemoryStream()
        ser.WriteTo(value, ms)
        ' add random bytes, every value should know it's length and not rely on EOF.
        Dim bytes As Byte() = New Byte(256 - ms.Position) {}
        _random.NextBytes(bytes)
        ms.Write(bytes, 0, bytes.Length)
        ' seek begin and read.
        ms.Position = 0
        Assert.AreEqual(value, ser.ReadFrom(ms))
    End Using
Next

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Used By

TestTransactionLog.TestBenchmarkWriteSpeed()
ThreadedMassInsertTest.TestConcurrency()

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Instance Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Instance Field

Glossary Item Box

Gets a singleton of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Instance As PrimitiveSerializer
C#
public static readonly PrimitiveSerializer Instance

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Used By

BPlusTree TestFileSerialized.BTreeFactory.Create()
BPlusTree DictionaryTestsVersion2.BTreeFactory.Create()
BPlusTree TestSimpleDictionary.BTreeFactory.Create()
ThreadedBTreeTest.TestAtomicUpdate()

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Int16 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Int16 Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Int16 As ISerializer(Of Short)
C#
public static readonly ISerializer<short> Int16

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Int32 Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Int32 Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Int32 As ISerializer(Of Integer)
C#
public static readonly ISerializer<int> Int32

Example

Library/Library.Test/TestSegmentedStream.cs

C# Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
{
    shared.Position = ushort.MaxValue - 25;
    Assert.AreEqual(ushort.MaxValue - 25, shared.Length);
    Assert.AreEqual(ushort.MaxValue - 25, shared.Position);

    using (Stream copy = ((IFactory<Stream>) shared).Create())
    {
        Assert.AreEqual(0L, copy.Position);//does not clone position of original stream...
        Assert.AreEqual(shared.Length, copy.Length);//does clone length of the stream...
        copy.Position = shared.Position;

        for (int i = 0; i < 100; i++)
        {
            PrimitiveSerializer.Int32.WriteTo(i, shared);
            Assert.AreEqual(i, PrimitiveSerializer.Int32.ReadFrom(copy));
        }
    }
}
VB.NET Copy Code
Using [shared] As New SharedMemoryStream()
    [shared].Position = UShort.MaxValue - 25
    Assert.AreEqual(UShort.MaxValue - 25, [shared].Length)
    Assert.AreEqual(UShort.MaxValue - 25, [shared].Position)

    Using copy As Stream = (DirectCast([shared], IFactory(Of Stream))).Create()
        Assert.AreEqual(0L, copy.Position)
        'does not clone position of original stream...
        Assert.AreEqual([shared].Length, copy.Length)
        'does clone length of the stream...
        copy.Position = [shared].Position

        Dim i As Integer = 0
        While i < 100
            PrimitiveSerializer.Int32.WriteTo(i, [shared])
            Assert.AreEqual(i, PrimitiveSerializer.Int32.ReadFrom(copy))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Used By

TransactionLog.CommitTransaction(TransactionToken)
TestBPlusTreeOptions.TestICloneable()
TestBPlusTreeOptions.TestReadOnly()
TestBPlusTreeOptions.TestCloneWithCallLockV1()
TestBPlusTreeOptions.TestCloneWithCallLockV2()
BasicFileTests.TestRecoverCorruptedFile()
TestMultiInstance.TestSyncFromLogging()
TestTransactionLog.TestTransactionLogOptions()

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Int64 Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Int64 Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Int64 As ISerializer(Of Long)
C#
public static readonly ISerializer<long> Int64

Example

Library/Library.Test/TestFragmentedFile.cs

C# Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
using (FragmentedFile ff = FragmentedFile.CreateNew(shared, 512, 100, 2))
{
    long id = ff.Create();
    using (Stream write = ff.Open(id, FileAccess.Write))
    {
        Assert.IsFalse(write.CanRead);
        Assert.IsTrue(write.CanWrite);
        Assert.IsFalse(write.CanSeek);
        PrimitiveSerializer.Int64.WriteTo(id, write);
        write.Flush();//no-op

        AssertThrows<NotSupportedException>(delegate() { write.Position = 0; });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Position); });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Length); });
        AssertThrows<NotSupportedException>(delegate() { write.SetLength(1); });
        AssertThrows<NotSupportedException>(delegate() { write.Seek(1, SeekOrigin.Begin); });
        AssertThrows<NotSupportedException>(delegate() { write.ReadByte(); });
    }
}
VB.NET Copy Code
Using [shared] As New SharedMemoryStream()
    Using ff As FragmentedFile = FragmentedFile.CreateNew([shared], 512, 100, 2)
        Dim id As Long = ff.Create()
        Using write As Stream = ff.Open(id, FileAccess.Write)
            Assert.IsFalse(write.CanRead)
            Assert.IsTrue(write.CanWrite)
            Assert.IsFalse(write.CanSeek)
            PrimitiveSerializer.Int64.WriteTo(id, write)
            write.Flush()
            'no-op
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Position = 0
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Position)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Length)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.SetLength(1)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Seek(1, SeekOrigin.Begin)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.ReadByte()
            End Function)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IntPtr Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : IntPtr Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly IntPtr As ISerializer(Of IntPtr)
C#
public static readonly ISerializer<IntPtr> IntPtr

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SByte Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : SByte Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly SByte As ISerializer(Of SByte)
C#
public static readonly ISerializer<sbyte> SByte

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
String Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : String Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly String As ISerializer(Of String)
C#
public static readonly ISerializer<string> String

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C# Copy Code
using (TempFile temp = new TempFile())
{
    temp.Delete();
    var opt = new TransactionLogOptions<int, string>(temp.TempPath,
                                                  PrimitiveSerializer.Int32,
                                                  PrimitiveSerializer.String);
    //FileName
    Assert.AreEqual(temp.TempPath, opt.FileName);
    //Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32));
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.String));
    //FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough | FileOptions.Asynchronous, opt.FileOptions |= FileOptions.Asynchronous);
    //Read Only
    Assert.AreEqual(false, opt.ReadOnly);
    Assert.AreEqual(true, opt.ReadOnly = true);
    //File Buffer
    Assert.AreEqual(8, opt.FileBuffer);
    Assert.AreEqual(0x40000, opt.FileBuffer = 0x40000);
    //Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()));

    using(TransactionLog<int, string> log = new TransactionLog<int,string>(opt))
        Assert.AreEqual(0, log.Size);
}
VB.NET Copy Code
Using temp As New TempFile()
    temp.Delete()
    Dim opt As var = New TransactionLogOptions(Of Integer, String)(temp.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String])
    'FileName
    Assert.AreEqual(temp.TempPath, opt.FileName)
    'Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32))
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.[String]))
    'FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough Or FileOptions.Asynchronous, opt.FileOptions = opt.FileOptions Or FileOptions.Asynchronous)
    'Read Only
    Assert.AreEqual(False, opt.[ReadOnly])
    Assert.AreEqual(True, opt.[ReadOnly] = True)
    'File Buffer
    Assert.AreEqual(8, opt.FileBuffer)
    Assert.AreEqual(&H40000, opt.FileBuffer = &H40000)
    'Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()))

    Using log As New TransactionLog(Of Integer, String)(opt)
        Assert.AreEqual(0, log.Size)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Used By

TestMultiInstance.TestSyncFromLogging()
TestTransactionLog.TestTransactionLogOptions()

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TimeSpan Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : TimeSpan Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly TimeSpan As ISerializer(Of TimeSpan)
C#
public static readonly ISerializer<TimeSpan> TimeSpan

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UInt16 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : UInt16 Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly UInt16 As ISerializer(Of UShort)
C#
public static readonly ISerializer<ushort> UInt16

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UInt32 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : UInt32 Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly UInt32 As ISerializer(Of UInteger)
C#
public static readonly ISerializer<uint> UInt32

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UInt64 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : UInt64 Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly UInt64 As ISerializer(Of ULong)
C#
public static readonly ISerializer<ulong> UInt64

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UIntPtr Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : UIntPtr Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly UIntPtr As ISerializer(Of UIntPtr)
C#
public static readonly ISerializer<UIntPtr> UIntPtr

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Source Code

Library/Serialization/PrimitiveSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SerializerExtensions Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : SerializerExtensions Class

Glossary Item Box

Extension methods used with ISerializer<T> for byte[] transformations

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class SerializerExtensions
C#
public static class SerializerExtensions

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.SerializerExtensions

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SerializerExtensions Members
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SerializerExtensions Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : SerializerExtensions Class

Glossary Item Box

The following tables list the members exposed by SerializerExtensions.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | FromByteArray<TKey> | Enables creation of the type TKey from an array of bytes
static (Shared in Visual Basic) | ToByteArray<TKey> | Enables creation of an array of bytes from type TKey
Top

See Also

Reference

SerializerExtensions Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SerializerExtensions Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : SerializerExtensions Class

Glossary Item Box

For a list of all members of this type, see SerializerExtensions members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | FromByteArray<TKey> | Enables creation of the type TKey from an array of bytes
static (Shared in Visual Basic) | ToByteArray<TKey> | Enables creation of an array of bytes from type TKey
Top

See Also

Reference

SerializerExtensions Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%%

TKey
[image]
CSharpTest.Net
FromByteArray<TKey> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > SerializerExtensions Class : FromByteArray<TKey> Method

ser
value

Glossary Item Box

Enables creation of the type TKey from an array of bytes

Syntax

Visual Basic (Declaration)
Public Shared Function FromByteArray(Of TKey)( _
   ByVal ser As ISerializer(Of TKey), _
   ByVal value() As Byte _
) As TKey
C#
public static TKey FromByteArray<TKey>(
   ISerializer<TKey> ser,
   byte[] value
)

Parameters

ser
value

Type Parameters

TKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SerializerExtensions Class
SerializerExtensions Members
ISerializer

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%%

TKey
[image]
CSharpTest.Net
ToByteArray<TKey> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > SerializerExtensions Class : ToByteArray<TKey> Method

ser
value

Glossary Item Box

Enables creation of an array of bytes from type TKey

Syntax

Visual Basic (Declaration)
Public Shared Function ToByteArray(Of TKey)( _
   ByVal ser As ISerializer(Of TKey), _
   ByVal value As TKey _
) As Byte()
C#
public static byte[] ToByteArray<TKey>(
   ISerializer<TKey> ser,
   TKey value
)

Parameters

ser
value

Type Parameters

TKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SerializerExtensions Class
SerializerExtensions Members
ISerializer

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Storage Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : Storage Class

Glossary Item Box

Used with one of the implementations in the StorageClasses namespace, this class provides rich-type storage on top of the basic INameValueStore string storage container.

Syntax

Visual Basic (Declaration)
Public Class Storage
C#
public class Storage

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.Storage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Members
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Storage Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : Storage Class

Glossary Item Box

The following tables list the members exposed by Storage.

Public Constructors

 | Name | Description
Public Constructor | Storage Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | ContextPath | Retrieves the current context path of the store
Top

Public Methods

 | Name | Description
Public Method | Delete | Removes the named value from the storage
Public Method | GetValue | Overloaded. Retrieves the named defaultValue from the storage
Public Method | SetContext | Replaces the context path of the storage, dispose of the returned IDisposable to restore the Storage's previous ContextPath.
Public Method | SetValue | Overloaded. Writes/Replaces the named value in the storage
Public Method | TryGetValue | Overloaded. Retrieves the named value from the storage
Top

See Also

Reference

Storage Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Storage Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class : Storage Constructor

Glossary Item Box

Overload List

Overload | Description
Storage Constructor(INameValueStore) | Constructs a storage wrapper for the given name/value store and sets the initial path to the provided value.
Storage Constructor(INameValueStore,String) | Constructs a storage wrapper for the given name/value store and sets the initial path to the provided value.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Storage Constructor(INameValueStore)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > Storage Constructor : Storage Constructor(INameValueStore)

store
The storage container to use

Glossary Item Box

Constructs a storage wrapper for the given name/value store and sets the initial path to the provided value.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal store As INameValueStore _
)
C#
public Storage(
   INameValueStore store
)

Parameters

store
The storage container to use

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Storage Constructor(INameValueStore,String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > Storage Constructor : Storage Constructor(INameValueStore,String)

store
The storage container to use
contextPath
The full context of the storage item, delimit with '/' or '\'

Glossary Item Box

Constructs a storage wrapper for the given name/value store and sets the initial path to the provided value.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal store As INameValueStore, _
   ByVal contextPath As String _
)
C#
public Storage(
   INameValueStore store,
   string contextPath
)

Parameters

store
The storage container to use
contextPath
The full context of the storage item, delimit with '/' or '\'

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Used By

PropertySerializer.Serialize(Object,INameValueStore)
PropertySerializer.Deserialize(Object,INameValueStore)

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Storage Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : Storage Class

Glossary Item Box

For a list of all members of this type, see Storage members.

Public Methods

 | Name | Description
Public Method | Delete | Removes the named value from the storage
Public Method | GetValue | Overloaded. Retrieves the named defaultValue from the storage
Public Method | SetContext | Replaces the context path of the storage, dispose of the returned IDisposable to restore the Storage's previous ContextPath.
Public Method | SetValue | Overloaded. Writes/Replaces the named value in the storage
Public Method | TryGetValue | Overloaded. Retrieves the named value from the storage
Top

See Also

Reference

Storage Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class : Delete Method

name

Glossary Item Box

Removes the named value from the storage

Syntax

Visual Basic (Declaration)
Public Sub Delete( _
   ByVal name As String _
)
C#
public void Delete(
   string name
)

Parameters

name

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
Version data = new Version(1, 2, 3, 4);
Store.SetValue("a", data);
Assert.AreEqual(data, Store.GetValue("a", (Version)null));

Store.Delete("a");
Assert.AreEqual(new Version(1, 0), Store.GetValue("a", new Version(1, 0)));

Store.SetValue("a", data);
Assert.AreEqual(data, Store.GetValue("a", (Version)null));

Store.SetValue("a", (string)null);//set null will delete
Assert.AreEqual(new Version(1, 0), Store.GetValue("a", new Version(1, 0)));
VB.NET Copy Code
Dim data As New Version(1, 2, 3, 4)
Store.SetValue("a", data)
Assert.AreEqual(data, Store.GetValue("a", DirectCast(Nothing, Version)))

Store.Delete("a")
Assert.AreEqual(New Version(1, 0), Store.GetValue("a", New Version(1, 0)))

Store.SetValue("a", data)
Assert.AreEqual(data, Store.GetValue("a", DirectCast(Nothing, Version)))

Store.SetValue("a", DirectCast(Nothing, String))
'set null will delete
Assert.AreEqual(New Version(1, 0), Store.GetValue("a", New Version(1, 0)))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class : GetValue Method

Glossary Item Box

Retrieves the named defaultValue from the storage

Overload List

Overload | Description
GetValue(String,Boolean) | Retrieves the named defaultValue from the storage
GetValue(String,Byte) | Retrieves the named defaultValue from the storage
GetValue(String,SByte) | Retrieves the named defaultValue from the storage
GetValue(String,Char) | Retrieves the named defaultValue from the storage
GetValue(String,DateTime) | Retrieves the named defaultValue from the storage
GetValue(String,TimeSpan) | Retrieves the named defaultValue from the storage
GetValue(String,Decimal) | Retrieves the named defaultValue from the storage
GetValue(String,Double) | Retrieves the named defaultValue from the storage
GetValue(String,Single) | Retrieves the named defaultValue from the storage
GetValue(String,Guid) | Retrieves the named defaultValue from the storage
GetValue(String,Uri) | Retrieves the named defaultValue from the storage
GetValue(String,Int16) | Retrieves the named defaultValue from the storage
GetValue(String,UInt16) | Retrieves the named defaultValue from the storage
GetValue(String,Int32) | Retrieves the named defaultValue from the storage
GetValue(String,UInt32) | Retrieves the named defaultValue from the storage
GetValue(String,Int64) | Retrieves the named defaultValue from the storage
GetValue(String,UInt64) | Retrieves the named defaultValue from the storage
GetValue(String,String) | Retrieves the named defaultValue from the storage
GetValue(String,Version) | Retrieves the named defaultValue from the storage
GetValue(String,Type,Object) | Retrieves the named defaultValue from the storage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Boolean) 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 Boolean _
) As Boolean
C#
public bool GetValue(
   string name,
   bool 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Byte) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Byte) 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 Byte _
) As Byte
C#
public byte GetValue(
   string name,
   byte 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,SByte) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,SByte) 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 SByte _
) As SByte
C#
public sbyte GetValue(
   string name,
   sbyte 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Char) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Char) 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 Char _
) As Char
C#
public char GetValue(
   string name,
   char 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,DateTime) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,DateTime) 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 Date _
) As Date
C#
public DateTime GetValue(
   string name,
   DateTime 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,TimeSpan) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,TimeSpan) 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 TimeSpan _
) As TimeSpan
C#
public TimeSpan GetValue(
   string name,
   TimeSpan 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Decimal) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Decimal) 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 Decimal _
) As Decimal
C#
public decimal GetValue(
   string name,
   decimal 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Double) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Double) 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 Double _
) As Double
C#
public double GetValue(
   string name,
   double 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Single) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Single) 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 Single _
) As Single
C#
public float GetValue(
   string name,
   float 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Uri) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Uri) 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 Uri _
) As Uri
C#
public Uri GetValue(
   string name,
   Uri 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Int16) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Int16) 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 Short _
) As Short
C#
public short GetValue(
   string name,
   short 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,UInt16) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,UInt16) 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 UShort _
) As UShort
C#
public ushort GetValue(
   string name,
   ushort 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Int32) 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 Integer _
) As Integer
C#
public int GetValue(
   string name,
   int 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,UInt32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,UInt32) 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 UInteger _
) As UInteger
C#
public uint GetValue(
   string name,
   uint 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Int64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Int64) 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 Long _
) As Long
C#
public long GetValue(
   string name,
   long 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,UInt64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,UInt64) 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 ULong _
) As ULong
C#
public ulong GetValue(
   string name,
   ulong 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,String) 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 String _
) As String
C#
public string GetValue(
   string name,
   string 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Version) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Version) 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 Version _
) As Version
C#
public Version GetValue(
   string name,
   Version 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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetValue(String,Type,Object) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > GetValue Method : GetValue(String,Type,Object) Method

name
type
defaultValue

Glossary Item Box

Retrieves the named defaultValue from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function GetValue( _
   ByVal name As String, _
   ByVal type As Type, _
   ByVal defaultValue As Object _
) As Object
C#
public object GetValue(
   string name,
   Type type,
   object defaultValue
)

Parameters

name
type
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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetContext Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class : SetContext Method

contextPath
The full context path to change to

Glossary Item Box

Replaces the context path of the storage, dispose of the returned IDisposable to restore the Storage's previous ContextPath.

Syntax

Visual Basic (Declaration)
Public Function SetContext( _
   ByVal contextPath As String _
) As IDisposable
C#
public IDisposable SetContext(
   string contextPath
)

Parameters

contextPath
The full context path to change to

Return Value

Context can be disposed to restore the previous state

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
Assert.IsNull(Store.ContextPath);

using (Store.SetContext("a"))
{
    Assert.AreEqual("a", Store.ContextPath);
    using (Store.SetContext("b"))
        Assert.AreEqual("b", Store.ContextPath);
    Assert.AreEqual("a", Store.ContextPath);
}

Assert.IsNull(Store.ContextPath);

using (Store.SetContext("a"))
{
    Assert.AreEqual("a", Store.ContextPath);
    Store.SetContext("b");
    Assert.AreEqual("b", Store.ContextPath);
}

Assert.IsNull(Store.ContextPath);
VB.NET Copy Code
Assert.IsNull(Store.ContextPath)

Using Store.SetContext("a")
    Assert.AreEqual("a", Store.ContextPath)
    Using Store.SetContext("b")
        Assert.AreEqual("b", Store.ContextPath)
    End Using
    Assert.AreEqual("a", Store.ContextPath)
End Using

Assert.IsNull(Store.ContextPath)

Using Store.SetContext("a")
    Assert.AreEqual("a", Store.ContextPath)
    Store.SetContext("b")
    Assert.AreEqual("b", Store.ContextPath)
End Using

Assert.IsNull(Store.ContextPath)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class : SetValue Method

Glossary Item Box

Writes/Replaces the named value in the storage

Overload List

Overload | Description
SetValue(String,Boolean) | Writes/Replaces the named value in the storage
SetValue(String,Byte) | Writes/Replaces the named value in the storage
SetValue(String,SByte) | Writes/Replaces the named value in the storage
SetValue(String,Char) | Writes/Replaces the named value in the storage
SetValue(String,DateTime) | Writes/Replaces the named value in the storage
SetValue(String,TimeSpan) | Writes/Replaces the named value in the storage
SetValue(String,Decimal) | Writes/Replaces the named value in the storage
SetValue(String,Double) | Writes/Replaces the named value in the storage
SetValue(String,Single) | Writes/Replaces the named value in the storage
SetValue(String,Guid) | Writes/Replaces the named value in the storage
SetValue(String,Uri) | Writes/Replaces the named value in the storage
SetValue(String,Int16) | Writes/Replaces the named value in the storage
SetValue(String,UInt16) | Writes/Replaces the named value in the storage
SetValue(String,Int32) | Writes/Replaces the named value in the storage
SetValue(String,UInt32) | Writes/Replaces the named value in the storage
SetValue(String,Int64) | Writes/Replaces the named value in the storage
SetValue(String,UInt64) | Writes/Replaces the named value in the storage
SetValue(String,String) | Writes/Replaces the named value in the storage
SetValue(String,Version) | Writes/Replaces the named value in the storage
SetValue(String,Type,Object) | Writes/Replaces the named value in the storage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Boolean) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Boolean _
)
C#
public void SetValue(
   string name,
   bool value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Byte) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Byte) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Byte _
)
C#
public void SetValue(
   string name,
   byte value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,SByte) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,SByte) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As SByte _
)
C#
public void SetValue(
   string name,
   sbyte value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Char) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Char) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Char _
)
C#
public void SetValue(
   string name,
   char value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,DateTime) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,DateTime) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Date _
)
C#
public void SetValue(
   string name,
   DateTime value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,TimeSpan) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,TimeSpan) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As TimeSpan _
)
C#
public void SetValue(
   string name,
   TimeSpan value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Decimal) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Decimal) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Decimal _
)
C#
public void SetValue(
   string name,
   decimal value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Double) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Double) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Double _
)
C#
public void SetValue(
   string name,
   double value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Single) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Single) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Single _
)
C#
public void SetValue(
   string name,
   float value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Guid) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Guid) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Guid _
)
C#
public void SetValue(
   string name,
   Guid value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Uri) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Uri) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Uri _
)
C#
public void SetValue(
   string name,
   Uri value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Int16) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Int16) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Short _
)
C#
public void SetValue(
   string name,
   short value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,UInt16) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,UInt16) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As UShort _
)
C#
public void SetValue(
   string name,
   ushort value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Int32) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Integer _
)
C#
public void SetValue(
   string name,
   int value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,UInt32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,UInt32) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As UInteger _
)
C#
public void SetValue(
   string name,
   uint value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Int64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Int64) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Long _
)
C#
public void SetValue(
   string name,
   long value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,UInt64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,UInt64) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As ULong _
)
C#
public void SetValue(
   string name,
   ulong value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,String) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As String _
)
C#
public void SetValue(
   string name,
   string value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Version) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Version) Method

name
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal value As Version _
)
C#
public void SetValue(
   string name,
   Version value
)

Parameters

name
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetValue(String,Type,Object) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > SetValue Method : SetValue(String,Type,Object) Method

name
type
value

Glossary Item Box

Writes/Replaces the named value in the storage

Syntax

Visual Basic (Declaration)
Public Overloads Sub SetValue( _
   ByVal name As String, _
   ByVal type As Type, _
   ByVal value As Object _
)
C#
public void SetValue(
   string name,
   Type type,
   object value
)

Parameters

name
type
value

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.NET 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
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

Reference

Storage Class
Storage Members
Overload List

Used By

PropertySerializer.Serialize(Object,INameValueStore)

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class : TryGetValue Method

Glossary Item Box

Retrieves the named value from the storage

Overload List

Overload | Description
TryGetValue(String,Boolean) | Retrieves the named value from the storage
TryGetValue(String,Byte) | Retrieves the named value from the storage
TryGetValue(String,SByte) | Retrieves the named value from the storage
TryGetValue(String,Char) | Retrieves the named value from the storage
TryGetValue(String,DateTime) | Retrieves the named value from the storage
TryGetValue(String,TimeSpan) | Retrieves the named value from the storage
TryGetValue(String,Decimal) | Retrieves the named value from the storage
TryGetValue(String,Double) | Retrieves the named value from the storage
TryGetValue(String,Single) | Retrieves the named value from the storage
TryGetValue(String,Guid) | Retrieves the named value from the storage
TryGetValue(String,Uri) | Retrieves the named value from the storage
TryGetValue(String,Int16) | Retrieves the named value from the storage
TryGetValue(String,UInt16) | Retrieves the named value from the storage
TryGetValue(String,Int32) | Retrieves the named value from the storage
TryGetValue(String,UInt32) | Retrieves the named value from the storage
TryGetValue(String,Int64) | Retrieves the named value from the storage
TryGetValue(String,UInt64) | Retrieves the named value from the storage
TryGetValue(String,String) | Retrieves the named value from the storage
TryGetValue(String,Version) | Retrieves the named value from the storage
TryGetValue(String,Type,Object) | Retrieves the named value from the storage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Boolean) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Boolean) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Boolean _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out bool value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Byte) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Byte) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Byte _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out byte value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,SByte) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,SByte) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As SByte _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out sbyte value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Char) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Char) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Char _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out char value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,DateTime) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,DateTime) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Date _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out DateTime value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,TimeSpan) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,TimeSpan) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As TimeSpan _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out TimeSpan value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Decimal) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Decimal) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Decimal _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out decimal value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Double) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Double) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Double _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out double value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Single) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Single) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Single _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out float value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Guid) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Guid) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Guid _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out Guid value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Uri) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Uri) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Uri _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out Uri value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Int16) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Int16) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Short _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out short value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,UInt16) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,UInt16) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As UShort _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out ushort value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Int32) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Integer _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out int value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,UInt32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,UInt32) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As UInteger _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out uint value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Int64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Int64) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Long _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out long value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,UInt64) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,UInt64) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As ULong _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out ulong value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,String) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out string value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Version) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Version) Method

name
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As Version _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out Version value
)

Parameters

name
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Type,Object) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class > TryGetValue Method : TryGetValue(String,Type,Object) Method

name
type
value

Glossary Item Box

Retrieves the named value from the storage

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByVal type As Type, _
   ByRef value As Object _
) As Boolean
C#
public bool TryGetValue(
   string name,
   Type type,
   out object value
)

Parameters

name
type
value

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
TestValues values = new TestValues();

//fails all but string
Store.SetValue("name", String.Empty);
Assert.IsTrue(Store.TryGetValue("name", out values._string));
Assert.AreEqual(String.Empty, values._string);

Assert.IsFalse(Store.TryGetValue("name", out values._bool));
Assert.IsFalse(Store.TryGetValue("name", out values._byte));
Assert.IsFalse(Store.TryGetValue("name", out values._char));
Assert.IsFalse(Store.TryGetValue("name", out values._DateTime));
Assert.IsFalse(Store.TryGetValue("name", out values._decimal));
Assert.IsFalse(Store.TryGetValue("name", out values._double));
Assert.IsFalse(Store.TryGetValue("name", out values._float));
Assert.IsFalse(Store.TryGetValue("name", out values._Guid));
Assert.IsFalse(Store.TryGetValue("name", out values._int));
Assert.IsFalse(Store.TryGetValue("name", out values._long));
Assert.IsFalse(Store.TryGetValue("name", out values._sbyte));
Assert.IsFalse(Store.TryGetValue("name", out values._short));
Assert.IsFalse(Store.TryGetValue("name", out values._TimeSpan));
Assert.IsFalse(Store.TryGetValue("name", out values._uint));
Assert.IsFalse(Store.TryGetValue("name", out values._ulong));
Assert.IsFalse(Store.TryGetValue("name", out values._Uri));
Assert.IsFalse(Store.TryGetValue("name", out values._ushort));
Assert.IsFalse(Store.TryGetValue("name", out values._Version));
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.GetType(), out values._object));
VB.NET Copy Code
Dim values As New TestValues()

'fails all but string
Store.SetValue("name", [String].Empty)
Assert.IsTrue(Store.TryGetValue("name", values._string))
Assert.AreEqual([String].Empty, values._string)

Assert.IsFalse(Store.TryGetValue("name", values._bool))
Assert.IsFalse(Store.TryGetValue("name", values._byte))
Assert.IsFalse(Store.TryGetValue("name", values._char))
Assert.IsFalse(Store.TryGetValue("name", values._DateTime))
Assert.IsFalse(Store.TryGetValue("name", values._decimal))
Assert.IsFalse(Store.TryGetValue("name", values._double))
Assert.IsFalse(Store.TryGetValue("name", values._float))
Assert.IsFalse(Store.TryGetValue("name", values._Guid))
Assert.IsFalse(Store.TryGetValue("name", values._int))
Assert.IsFalse(Store.TryGetValue("name", values._long))
Assert.IsFalse(Store.TryGetValue("name", values._sbyte))
Assert.IsFalse(Store.TryGetValue("name", values._short))
Assert.IsFalse(Store.TryGetValue("name", values._TimeSpan))
Assert.IsFalse(Store.TryGetValue("name", values._uint))
Assert.IsFalse(Store.TryGetValue("name", values._ulong))
Assert.IsFalse(Store.TryGetValue("name", values._Uri))
Assert.IsFalse(Store.TryGetValue("name", values._ushort))
Assert.IsFalse(Store.TryGetValue("name", values._Version))
Assert.IsFalse(Store.TryGetValue("name", ValuesA._object.[GetType](), values._object))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members
Overload List

Used By

PropertySerializer.Deserialize(Object,INameValueStore)

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Storage Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : Storage Class

Glossary Item Box

For a list of all members of this type, see Storage members.

Public Properties

 | Name | Description
Public Property | ContextPath | Retrieves the current context path of the store
Top

See Also

Reference

Storage Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContextPath Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > Storage Class : ContextPath Property

Glossary Item Box

Retrieves the current context path of the store

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ContextPath As String
C#
public string ContextPath {get;}

Example

Library/Library.Test/TestStorage.cs

C# Copy Code
Assert.IsNull(Store.ContextPath);

using (Store.SetContext("a"))
{
    Assert.AreEqual("a", Store.ContextPath);
    using (Store.SetContext("b"))
        Assert.AreEqual("b", Store.ContextPath);
    Assert.AreEqual("a", Store.ContextPath);
}

Assert.IsNull(Store.ContextPath);

using (Store.SetContext("a"))
{
    Assert.AreEqual("a", Store.ContextPath);
    Store.SetContext("b");
    Assert.AreEqual("b", Store.ContextPath);
}

Assert.IsNull(Store.ContextPath);
VB.NET Copy Code
Assert.IsNull(Store.ContextPath)

Using Store.SetContext("a")
    Assert.AreEqual("a", Store.ContextPath)
    Using Store.SetContext("b")
        Assert.AreEqual("b", Store.ContextPath)
    End Using
    Assert.AreEqual("a", Store.ContextPath)
End Using

Assert.IsNull(Store.ContextPath)

Using Store.SetContext("a")
    Assert.AreEqual("a", Store.ContextPath)
    Store.SetContext("b")
    Assert.AreEqual("b", Store.ContextPath)
End Using

Assert.IsNull(Store.ContextPath)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Storage Class
Storage Members

Used By

Object Storage.GetValue(String,Type,Object)
Boolean Storage.TryGetValue(String,Type,Object)
Storage.SetValue(String,Type,Object)
Storage.Delete(String)

Source Code

Library/Serialization/Storage.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
VariantNumberSerializer Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : VariantNumberSerializer Class

Glossary Item Box

Provides numeric serializers for packed int/long values.

Syntax

Visual Basic (Declaration)
Public Class VariantNumberSerializer
   Implements CSharpTest.Net.Serialization.ISerializer(Of Integer), CSharpTest.Net.Serialization.ISerializer(Of Long), CSharpTest.Net.Serialization.ISerializer(Of UInteger), CSharpTest.Net.Serialization.ISerializer(Of ULong)
C#
public class VariantNumberSerializer : CSharpTest.Net.Serialization.ISerializer<int>, CSharpTest.Net.Serialization.ISerializer<long>, CSharpTest.Net.Serialization.ISerializer<uint>, CSharpTest.Net.Serialization.ISerializer<ulong>

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.VariantNumberSerializer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

VariantNumberSerializer Members
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
VariantNumberSerializer Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : VariantNumberSerializer Class

Glossary Item Box

The following tables list the members exposed by VariantNumberSerializer.

Public Constructors

 | Name | Description
Public Constructor | VariantNumberSerializer Constructor |
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Instance | Gets a singleton of the VariantNumberSerializer
static (Shared in Visual Basic) | Int32 | Gets a typed version of the VariantNumberSerializer
static (Shared in Visual Basic) | Int64 | Gets a typed version of the VariantNumberSerializer
static (Shared in Visual Basic) | UInt32 | Gets a typed version of the VariantNumberSerializer
static (Shared in Visual Basic) | UInt64 | Gets a typed version of the VariantNumberSerializer
Top

See Also

Reference

VariantNumberSerializer Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
VariantNumberSerializer Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > VariantNumberSerializer Class : VariantNumberSerializer Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public VariantNumberSerializer()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

VariantNumberSerializer Class
VariantNumberSerializer Members

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
VariantNumberSerializer Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : VariantNumberSerializer Class

Glossary Item Box

For a list of all members of this type, see VariantNumberSerializer members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Instance | Gets a singleton of the VariantNumberSerializer
static (Shared in Visual Basic) | Int32 | Gets a typed version of the VariantNumberSerializer
static (Shared in Visual Basic) | Int64 | Gets a typed version of the VariantNumberSerializer
static (Shared in Visual Basic) | UInt32 | Gets a typed version of the VariantNumberSerializer
static (Shared in Visual Basic) | UInt64 | Gets a typed version of the VariantNumberSerializer
Top

See Also

Reference

VariantNumberSerializer Class
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Instance Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > VariantNumberSerializer Class : Instance Field

Glossary Item Box

Gets a singleton of the VariantNumberSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Instance As VariantNumberSerializer
C#
public static readonly VariantNumberSerializer Instance

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

VariantNumberSerializer Class
VariantNumberSerializer Members

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Int32 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > VariantNumberSerializer Class : Int32 Field

Glossary Item Box

Gets a typed version of the VariantNumberSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Int32 As ISerializer(Of Integer)
C#
public static readonly ISerializer<int> Int32

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

VariantNumberSerializer Class
VariantNumberSerializer Members

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Int64 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > VariantNumberSerializer Class : Int64 Field

Glossary Item Box

Gets a typed version of the VariantNumberSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Int64 As ISerializer(Of Long)
C#
public static readonly ISerializer<long> Int64

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

VariantNumberSerializer Class
VariantNumberSerializer Members

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UInt32 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > VariantNumberSerializer Class : UInt32 Field

Glossary Item Box

Gets a typed version of the VariantNumberSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly UInt32 As ISerializer(Of UInteger)
C#
public static readonly ISerializer<uint> UInt32

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

VariantNumberSerializer Class
VariantNumberSerializer Members

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UInt64 Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > VariantNumberSerializer Class : UInt64 Field

Glossary Item Box

Gets a typed version of the VariantNumberSerializer

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly UInt64 As ISerializer(Of ULong)
C#
public static readonly ISerializer<ulong> UInt64

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

VariantNumberSerializer Class
VariantNumberSerializer Members

Source Code

Library/Serialization/VariantNumberSerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
INameValueStore Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : INameValueStore Interface

Glossary Item Box

provides a basic inteface for a reader/writer of string name/value pairs

Syntax

Visual Basic (Declaration)
Public Interface INameValueStore
C#
public interface INameValueStore

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

INameValueStore Members
CSharpTest.Net.Serialization Namespace
PropertySerializer.Serialize(Object,INameValueStore)
PropertySerializer.Deserialize(Object,INameValueStore)
ObjectSerializer.Serialize(INameValueStore)
ObjectSerializer.Deserialize(INameValueStore)
PropertySerializer.Serialize(T,INameValueStore)
PropertySerializer.Deserialize(T,INameValueStore)

Source Code

Library/Serialization/INameValueStore.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
INameValueStore Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : INameValueStore Interface

Glossary Item Box

The following tables list the members exposed by INameValueStore.

Public Methods

 | Name | Description
Method | Delete | Removes a property from the storage by name
Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Method | Write | Writes the given property by name
Top

See Also

Reference

INameValueStore Interface
CSharpTest.Net.Serialization Namespace
PropertySerializer.Serialize(Object,INameValueStore)
PropertySerializer.Deserialize(Object,INameValueStore)
ObjectSerializer.Serialize(INameValueStore)
ObjectSerializer.Deserialize(INameValueStore)
PropertySerializer.Serialize(T,INameValueStore)
PropertySerializer.Deserialize(T,INameValueStore)

Source Code

Library/Serialization/INameValueStore.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
INameValueStore Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : INameValueStore Interface

Glossary Item Box

For a list of all members of this type, see INameValueStore members.

Public Methods

 | Name | Description
Method | Delete | Removes a property from the storage by name
Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Method | Write | Writes the given property by name
Top

See Also

Reference

INameValueStore Interface
CSharpTest.Net.Serialization Namespace
PropertySerializer.Serialize(Object,INameValueStore)
PropertySerializer.Deserialize(Object,INameValueStore)
ObjectSerializer.Serialize(INameValueStore)
ObjectSerializer.Deserialize(INameValueStore)
PropertySerializer.Serialize(T,INameValueStore)
PropertySerializer.Deserialize(T,INameValueStore)

Source Code

Library/Serialization/INameValueStore.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > INameValueStore Interface : Delete Method

path
Optional path for context information
name
The name of the property to remove

Glossary Item Box

Removes a property from the storage by name

Syntax

Visual Basic (Declaration)
Sub Delete( _
   ByVal path As String, _
   ByVal name As String _
)
C#
void Delete(
   string path,
   string name
)

Parameters

path
Optional path for context information
name
The name of the property to remove

Example

Library/Library.Test/TestSerializers.cs

C# Copy Code
string value;

Store.Write(null, "<?a", "b");

Assert.IsTrue(Store.Read(null, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Store.Write(null, "<?a", "b");

Assert.IsTrue(Store.Read(null, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Store.Write(">?1/\\", "<?a", "c");

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(">?1/\\", "<?a", out value));
Assert.AreEqual("c", value);

Store.Delete(">?1/\\", "<?a");
Assert.IsFalse(Store.Read(">?1/\\", "<?a", out value));

Store.Delete(null, "<?a");
Assert.IsFalse(Store.Read(null, "<?a", out value));
Assert.IsFalse(Store.Read(String.Empty, "<?a", out value));
VB.NET Copy Code
Dim value As String

Store.Write(Nothing, "<?a", "b")

Assert.IsTrue(Store.Read(Nothing, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Store.Write(Nothing, "<?a", "b")

Assert.IsTrue(Store.Read(Nothing, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Store.Write(">?1/\", "<?a", "c")

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read(">?1/\", "<?a", value))
Assert.AreEqual("c", value)

Store.Delete(">?1/\", "<?a")
Assert.IsFalse(Store.Read(">?1/\", "<?a", value))

Store.Delete(Nothing, "<?a")
Assert.IsFalse(Store.Read(Nothing, "<?a", value))
Assert.IsFalse(Store.Read([String].Empty, "<?a", value))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

INameValueStore Interface
INameValueStore Members

Source Code

Library/Serialization/INameValueStore.cs

Used By

Storage.SetValue(String,Type,Object)
Storage.Delete(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > INameValueStore Interface : Read Method

path
Optional path for context information
name
The name of the property
value
Returns the output value if available

Glossary Item Box

returns true if the property was successfully retireved into the output variable 'value'

Syntax

Visual Basic (Declaration)
Function Read( _
   ByVal path As String, _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
bool Read(
   string path,
   string name,
   out string value
)

Parameters

path
Optional path for context information
name
The name of the property
value
Returns the output value if available

Return Value

true if successful or false if data not available

Example

Library/Library.Test/TestSerializers.cs

C# Copy Code
string value;

Store.Write(null, "<?a", "b");

Assert.IsTrue(Store.Read(null, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Store.Write(null, "<?a", "b");

Assert.IsTrue(Store.Read(null, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Store.Write(">?1/\\", "<?a", "c");

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(">?1/\\", "<?a", out value));
Assert.AreEqual("c", value);

Store.Delete(">?1/\\", "<?a");
Assert.IsFalse(Store.Read(">?1/\\", "<?a", out value));

Store.Delete(null, "<?a");
Assert.IsFalse(Store.Read(null, "<?a", out value));
Assert.IsFalse(Store.Read(String.Empty, "<?a", out value));
VB.NET Copy Code
Dim value As String

Store.Write(Nothing, "<?a", "b")

Assert.IsTrue(Store.Read(Nothing, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Store.Write(Nothing, "<?a", "b")

Assert.IsTrue(Store.Read(Nothing, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Store.Write(">?1/\", "<?a", "c")

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read(">?1/\", "<?a", value))
Assert.AreEqual("c", value)

Store.Delete(">?1/\", "<?a")
Assert.IsFalse(Store.Read(">?1/\", "<?a", value))

Store.Delete(Nothing, "<?a")
Assert.IsFalse(Store.Read(Nothing, "<?a", value))
Assert.IsFalse(Store.Read([String].Empty, "<?a", value))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

INameValueStore Interface
INameValueStore Members

Source Code

Library/Serialization/INameValueStore.cs

Used By

Object Storage.GetValue(String,Type,Object)
Boolean Storage.TryGetValue(String,Type,Object)


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > INameValueStore Interface : Write Method

path
Optional path for context information
name
The name of the property
value
The value to store

Glossary Item Box

Writes the given property by name

Syntax

Visual Basic (Declaration)
Sub Write( _
   ByVal path As String, _
   ByVal name As String, _
   ByVal value As String _
)
C#
void Write(
   string path,
   string name,
   string value
)

Parameters

path
Optional path for context information
name
The name of the property
value
The value to store

Example

Library/Library.Test/TestSerializers.cs

C# Copy Code
string value;

Store.Write(null, "<?a", "b");

Assert.IsTrue(Store.Read(null, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Store.Write(null, "<?a", "b");

Assert.IsTrue(Store.Read(null, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Store.Write(">?1/\\", "<?a", "c");

Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
Assert.AreEqual("b", value);

Assert.IsTrue(Store.Read(">?1/\\", "<?a", out value));
Assert.AreEqual("c", value);

Store.Delete(">?1/\\", "<?a");
Assert.IsFalse(Store.Read(">?1/\\", "<?a", out value));

Store.Delete(null, "<?a");
Assert.IsFalse(Store.Read(null, "<?a", out value));
Assert.IsFalse(Store.Read(String.Empty, "<?a", out value));
VB.NET Copy Code
Dim value As String

Store.Write(Nothing, "<?a", "b")

Assert.IsTrue(Store.Read(Nothing, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Store.Write(Nothing, "<?a", "b")

Assert.IsTrue(Store.Read(Nothing, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Store.Write(">?1/\", "<?a", "c")

Assert.IsTrue(Store.Read([String].Empty, "<?a", value))
Assert.AreEqual("b", value)

Assert.IsTrue(Store.Read(">?1/\", "<?a", value))
Assert.AreEqual("c", value)

Store.Delete(">?1/\", "<?a")
Assert.IsFalse(Store.Read(">?1/\", "<?a", value))

Store.Delete(Nothing, "<?a")
Assert.IsFalse(Store.Read(Nothing, "<?a", value))
Assert.IsFalse(Store.Read([String].Empty, "<?a", value))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

INameValueStore Interface
INameValueStore Members

Source Code

Library/Serialization/INameValueStore.cs

Used By

Storage.SetValue(String,Type,Object)


%%PageItemTitle%%

T
[image]
CSharpTest.Net
ISerializer<T> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : ISerializer<T> Interface

Glossary Item Box

Provides serialization for a type

Syntax

Visual Basic (Declaration)
Public Interface ISerializer(Of T)
C#
public interface ISerializer<T>

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ISerializer<T> Members
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ISerializer<T> Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : ISerializer<T> Interface

Glossary Item Box

The following tables list the members exposed by ISerializer<T>.

Public Methods

 | Name | Description
Method | ReadFrom | Reads the object from a stream
Method | WriteTo | Writes the object to the stream
Top

See Also

Reference

ISerializer<T> Interface
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ISerializer<T> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace : ISerializer<T> Interface

Glossary Item Box

For a list of all members of this type, see ISerializer<T> members.

Public Methods

 | Name | Description
Method | ReadFrom | Reads the object from a stream
Method | WriteTo | Writes the object to the stream
Top

See Also

Reference

ISerializer<T> Interface
CSharpTest.Net.Serialization Namespace

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadFrom Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > ISerializer<T> Interface : ReadFrom Method

stream

Glossary Item Box

Reads the object from a stream

Syntax

Visual Basic (Declaration)
Function ReadFrom( _
   ByVal stream As Stream _
) As T
C#
T ReadFrom(
   Stream stream
)

Parameters

stream

Example

Library/Library.Test/TestSegmentedStream.cs

C# Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
{
    shared.Position = ushort.MaxValue - 25;
    Assert.AreEqual(ushort.MaxValue - 25, shared.Length);
    Assert.AreEqual(ushort.MaxValue - 25, shared.Position);

    using (Stream copy = ((IFactory<Stream>) shared).Create())
    {
        Assert.AreEqual(0L, copy.Position);//does not clone position of original stream...
        Assert.AreEqual(shared.Length, copy.Length);//does clone length of the stream...
        copy.Position = shared.Position;

        for (int i = 0; i < 100; i++)
        {
            PrimitiveSerializer.Int32.WriteTo(i, shared);
            Assert.AreEqual(i, PrimitiveSerializer.Int32.ReadFrom(copy));
        }
    }
}
VB.NET Copy Code
Using [shared] As New SharedMemoryStream()
    [shared].Position = UShort.MaxValue - 25
    Assert.AreEqual(UShort.MaxValue - 25, [shared].Length)
    Assert.AreEqual(UShort.MaxValue - 25, [shared].Position)

    Using copy As Stream = (DirectCast([shared], IFactory(Of Stream))).Create()
        Assert.AreEqual(0L, copy.Position)
        'does not clone position of original stream...
        Assert.AreEqual([shared].Length, copy.Length)
        'does clone length of the stream...
        copy.Position = [shared].Position

        Dim i As Integer = 0
        While i < 100
            PrimitiveSerializer.Int32.WriteTo(i, [shared])
            Assert.AreEqual(i, PrimitiveSerializer.Int32.ReadFrom(copy))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ISerializer<T> Interface
ISerializer<T> Members

Used By

BasicFileTests.TestRecoverCorruptedFile()
TKey SerializerExtensions.FromByteArray(ISerializer,Byte[])
KeyValuePair KeyValueSerializer.ReadFrom(Stream)

Source Code

Library/Serialization/ISerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteTo Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > ISerializer<T> Interface : WriteTo Method

value
stream

Glossary Item Box

Writes the object to the stream

Syntax

Visual Basic (Declaration)
Sub WriteTo( _
   ByVal value As T, _
   ByVal stream As Stream _
)
C#
void WriteTo(
   T value,
   Stream stream
)

Parameters

value
stream

Example

Library/Library.Test/TestSegmentedStream.cs

C# Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
{
    shared.Position = ushort.MaxValue - 25;
    Assert.AreEqual(ushort.MaxValue - 25, shared.Length);
    Assert.AreEqual(ushort.MaxValue - 25, shared.Position);

    using (Stream copy = ((IFactory<Stream>) shared).Create())
    {
        Assert.AreEqual(0L, copy.Position);//does not clone position of original stream...
        Assert.AreEqual(shared.Length, copy.Length);//does clone length of the stream...
        copy.Position = shared.Position;

        for (int i = 0; i < 100; i++)
        {
            PrimitiveSerializer.Int32.WriteTo(i, shared);
            Assert.AreEqual(i, PrimitiveSerializer.Int32.ReadFrom(copy));
        }
    }
}
VB.NET Copy Code
Using [shared] As New SharedMemoryStream()
    [shared].Position = UShort.MaxValue - 25
    Assert.AreEqual(UShort.MaxValue - 25, [shared].Length)
    Assert.AreEqual(UShort.MaxValue - 25, [shared].Position)

    Using copy As Stream = (DirectCast([shared], IFactory(Of Stream))).Create()
        Assert.AreEqual(0L, copy.Position)
        'does not clone position of original stream...
        Assert.AreEqual([shared].Length, copy.Length)
        'does clone length of the stream...
        copy.Position = [shared].Position

        Dim i As Integer = 0
        While i < 100
            PrimitiveSerializer.Int32.WriteTo(i, [shared])
            Assert.AreEqual(i, PrimitiveSerializer.Int32.ReadFrom(copy))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ISerializer<T> Interface
ISerializer<T> Members

Used By

TransactionLog.CommitTransaction(TransactionToken)
Byte[] SerializerExtensions.ToByteArray(ISerializer,TKey)
KeyValueSerializer.WriteTo(KeyValuePair,Stream)

Source Code

Library/Serialization/ISerializer.cs


%%ItemTitle%%

CSharpTest.Net.Serialization.StorageClasses Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Serialization.StorageClasses Namespace

Glossary Item Box

Classes

 | Class | Description
Class | AppSettingStorage | Stores values in the local application's configuration section: "AppSettings"
Class | DictionaryStorage | Stores values in a IDictionary, by default this dictionary is placed in the current AppDomain data slot to provide data that is consistant across instances of DictionaryStorage when no dictionary is provided to the constructor.
Class | FileStorage | Stores values in the local AppData folder in the path {Company}\{Product}.
Class | IsolatedStorage | Stores values in the IsolatedStorage for the application in {Company}\{Product} path.
Class | RegistryStorage | Stores values in the registry at HKCU\Software\{Company}\{Product} path.
Class | UserSettingStorage | Stores values in the local configuration section: "userSettings"

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
AppSettingStorage Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : AppSettingStorage Class

Glossary Item Box

Stores values in the local application's configuration section: "AppSettings"

Syntax

Visual Basic (Declaration)
Public Class AppSettingStorage
   Implements CSharpTest.Net.Serialization.INameValueStore
C#
public class AppSettingStorage : CSharpTest.Net.Serialization.INameValueStore

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage
CSharpTest.Net.Serialization.StorageClasses.UserSettingStorage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AppSettingStorage Members
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AppSettingStorage Class Members
See Also Fields Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : AppSettingStorage Class

Glossary Item Box

The following tables list the members exposed by AppSettingStorage.

Public Constructors

 | Name | Description
Public Constructor | AppSettingStorage Constructor | Stores values in the local application's configuration
Top

Protected Fields

 | Name | Description
static (Shared in Visual Basic) | Sync | Provides syncronization across instances of AppSettingsStorage classes modifying the configuration file(s)
Top

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

Protected Methods

 | Name | Description
Protected Method | MakePath | Creates the full name of the item from path and name
Protected Method | Open | Opens a configuration section and returns the key/value collection associated.
Top

See Also

Reference

AppSettingStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AppSettingStorage Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > AppSettingStorage Class : AppSettingStorage Constructor

Glossary Item Box

Stores values in the local application's configuration

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public AppSettingStorage()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AppSettingStorage Class
AppSettingStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AppSettingStorage Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : AppSettingStorage Class

Glossary Item Box

For a list of all members of this type, see AppSettingStorage members.

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

Protected Methods

 | Name | Description
Protected Method | MakePath | Creates the full name of the item from path and name
Protected Method | Open | Opens a configuration section and returns the key/value collection associated.
Top

See Also

Reference

AppSettingStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > AppSettingStorage Class : Delete Method

path
name

Glossary Item Box

Removes a property from the storage by name

Syntax

Visual Basic (Declaration)
Public Overridable Sub Delete( _
   ByVal path As String, _
   ByVal name As String _
)
C#
public virtual void Delete(
   string path,
   string name
)

Parameters

path
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AppSettingStorage Class
AppSettingStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MakePath Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > AppSettingStorage Class : MakePath Method

path
name

Glossary Item Box

Creates the full name of the item from path and name

Syntax

Visual Basic (Declaration)
Protected Overridable Function MakePath( _
   ByVal path As String, _
   ByVal name As String _
) As String
C#
protected virtual string MakePath(
   string path,
   string name
)

Parameters

path
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AppSettingStorage Class
AppSettingStorage Members

Used By

Boolean AppSettingStorage.Read(String,String,String)
AppSettingStorage.Write(String,String,String)
AppSettingStorage.Delete(String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
Open Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > AppSettingStorage Class : Open Method

path
config

Glossary Item Box

Opens a configuration section and returns the key/value collection associated.

Syntax

Visual Basic (Declaration)
Protected Overridable Function Open( _
   ByVal path As String, _
   ByRef config As Configuration _
) As KeyValueConfigurationCollection
C#
protected virtual KeyValueConfigurationCollection Open(
   string path,
   out Configuration config
)

Parameters

path
config

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AppSettingStorage Class
AppSettingStorage Members

Used By

Boolean AppSettingStorage.Read(String,String,String)
AppSettingStorage.Write(String,String,String)
AppSettingStorage.Delete(String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > AppSettingStorage Class : Read Method

path
name
value

Glossary Item Box

returns true if the property was successfully retireved into the output variable 'value'

Syntax

Visual Basic (Declaration)
Public Overridable Function Read( _
   ByVal path As String, _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
public virtual bool Read(
   string path,
   string name,
   out string value
)

Parameters

path
name
value

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AppSettingStorage Class
AppSettingStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > AppSettingStorage Class : Write Method

path
name
value

Glossary Item Box

Writes the given property by name

Syntax

Visual Basic (Declaration)
Public Overridable Sub Write( _
   ByVal path As String, _
   ByVal name As String, _
   ByVal value As String _
)
C#
public virtual void Write(
   string path,
   string name,
   string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AppSettingStorage Class
AppSettingStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
AppSettingStorage Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : AppSettingStorage Class

Glossary Item Box

For a list of all members of this type, see AppSettingStorage members.

Protected Fields

 | Name | Description
static (Shared in Visual Basic) | Sync | Provides syncronization across instances of AppSettingsStorage classes modifying the configuration file(s)
Top

See Also

Reference

AppSettingStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Sync Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > AppSettingStorage Class : Sync Field

Glossary Item Box

Provides syncronization across instances of AppSettingsStorage classes modifying the configuration file(s)

Syntax

Visual Basic (Declaration)
Protected Shared ReadOnly Sync As Object
C#
protected static readonly object Sync

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AppSettingStorage Class
AppSettingStorage Members

Used By

AppSettingStorage.Write(String,String,String)
AppSettingStorage.Delete(String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
DictionaryStorage Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : DictionaryStorage Class

Glossary Item Box

Stores values in a IDictionary, by default this dictionary is placed in the current AppDomain data slot to provide data that is consistant across instances of DictionaryStorage when no dictionary is provided to the constructor.

Syntax

Visual Basic (Declaration)
Public Class DictionaryStorage
   Implements CSharpTest.Net.Serialization.INameValueStore
C#
public class DictionaryStorage : CSharpTest.Net.Serialization.INameValueStore

Example

Library/Library.Test/TestSerializers.cs

C# Copy Code
}

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.StorageClasses.DictionaryStorage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DictionaryStorage Members
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DictionaryStorage Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : DictionaryStorage Class

Glossary Item Box

The following tables list the members exposed by DictionaryStorage.

Public Constructors

 | Name | Description
Public Constructor | DictionaryStorage Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

See Also

Reference

DictionaryStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DictionaryStorage Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > DictionaryStorage Class : DictionaryStorage Constructor

Glossary Item Box

Overload List

Overload | Description
DictionaryStorage Constructor(IDictionary<String,String>) | Constructs a DictionarySTorage with a specified dictionary object
DictionaryStorage Constructor() | dictionary is retrieved/placed in the current AppDomain data slot to provide data that is consistant across instances of DictionaryStorage.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DictionaryStorage Class
DictionaryStorage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DictionaryStorage Constructor(IDictionary<String,String>)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > DictionaryStorage Class > DictionaryStorage Constructor : DictionaryStorage Constructor(IDictionary<String,String>)

dictionary

Glossary Item Box

Constructs a DictionarySTorage with a specified dictionary object

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal dictionary As IDictionary(Of String,String) _
)
C#
public DictionaryStorage(
   IDictionary<string,string> dictionary
)

Parameters

dictionary

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DictionaryStorage Class
DictionaryStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DictionaryStorage Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > DictionaryStorage Class > DictionaryStorage Constructor : DictionaryStorage Constructor()

Glossary Item Box

dictionary is retrieved/placed in the current AppDomain data slot to provide data that is consistant across instances of DictionaryStorage.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public DictionaryStorage()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DictionaryStorage Class
DictionaryStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DictionaryStorage Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : DictionaryStorage Class

Glossary Item Box

For a list of all members of this type, see DictionaryStorage members.

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

See Also

Reference

DictionaryStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > DictionaryStorage Class : Delete Method

path
name

Glossary Item Box

Removes a property from the storage by name

Syntax

Visual Basic (Declaration)
Public Sub Delete( _
   ByVal path As String, _
   ByVal name As String _
)
C#
public void Delete(
   string path,
   string name
)

Parameters

path
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DictionaryStorage Class
DictionaryStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > DictionaryStorage Class : Read Method

path
name
value

Glossary Item Box

returns true if the property was successfully retireved into the output variable 'value'

Syntax

Visual Basic (Declaration)
Public Function Read( _
   ByVal path As String, _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
public bool Read(
   string path,
   string name,
   out string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DictionaryStorage Class
DictionaryStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > DictionaryStorage Class : Write Method

path
name
value

Glossary Item Box

Writes the given property by name

Syntax

Visual Basic (Declaration)
Public Sub Write( _
   ByVal path As String, _
   ByVal name As String, _
   ByVal value As String _
)
C#
public void Write(
   string path,
   string name,
   string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DictionaryStorage Class
DictionaryStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStorage Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : FileStorage Class

Glossary Item Box

Stores values in the local AppData folder in the path {Company}\{Product}.

Syntax

Visual Basic (Declaration)
Public Class FileStorage
   Implements CSharpTest.Net.Serialization.INameValueStore
C#
public class FileStorage : CSharpTest.Net.Serialization.INameValueStore

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.StorageClasses.FileStorage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStorage Members
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FileStorage Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : FileStorage Class

Glossary Item Box

The following tables list the members exposed by FileStorage.

Public Constructors

 | Name | Description
Public Constructor | FileStorage Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

See Also

Reference

FileStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStorage Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > FileStorage Class : FileStorage Constructor

Glossary Item Box

Overload List

Overload | Description
FileStorage Constructor() | Stores values in the local AppData folder in the path {Company}\{Product}.
FileStorage Constructor(String) | Stores values in the local AppData folder in the path {Company}\{Product}.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStorage Class
FileStorage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStorage Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > FileStorage Class > FileStorage Constructor : FileStorage Constructor()

Glossary Item Box

Stores values in the local AppData folder in the path {Company}\{Product}.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public FileStorage()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStorage Class
FileStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileStorage Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > FileStorage Class > FileStorage Constructor : FileStorage Constructor(String)

pathRoot

Glossary Item Box

Stores values in the local AppData folder in the path {Company}\{Product}.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal pathRoot As String _
)
C#
public FileStorage(
   string pathRoot
)

Parameters

pathRoot

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStorage Class
FileStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
FileStorage Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : FileStorage Class

Glossary Item Box

For a list of all members of this type, see FileStorage members.

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

See Also

Reference

FileStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > FileStorage Class : Delete Method

path
name

Glossary Item Box

Removes a property from the storage by name

Syntax

Visual Basic (Declaration)
Public Sub Delete( _
   ByVal path As String, _
   ByVal name As String _
)
C#
public void Delete(
   string path,
   string name
)

Parameters

path
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStorage Class
FileStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > FileStorage Class : Read Method

path
name
value

Glossary Item Box

returns true if the property was successfully retireved into the output variable 'value'

Syntax

Visual Basic (Declaration)
Public Function Read( _
   ByVal path As String, _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
public bool Read(
   string path,
   string name,
   out string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStorage Class
FileStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > FileStorage Class : Write Method

path
name
value

Glossary Item Box

Writes the given property by name

Syntax

Visual Basic (Declaration)
Public Sub Write( _
   ByVal path As String, _
   ByVal name As String, _
   ByVal value As String _
)
C#
public void Write(
   string path,
   string name,
   string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileStorage Class
FileStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsolatedStorage Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : IsolatedStorage Class

Glossary Item Box

Stores values in the IsolatedStorage for the application in {Company}\{Product} path.

Syntax

Visual Basic (Declaration)
Public Class IsolatedStorage
   Implements CSharpTest.Net.Serialization.INameValueStore
C#
public class IsolatedStorage : CSharpTest.Net.Serialization.INameValueStore

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.StorageClasses.IsolatedStorage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IsolatedStorage Members
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IsolatedStorage Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : IsolatedStorage Class

Glossary Item Box

The following tables list the members exposed by IsolatedStorage.

Public Constructors

 | Name | Description
Public Constructor | IsolatedStorage Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

See Also

Reference

IsolatedStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsolatedStorage Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > IsolatedStorage Class : IsolatedStorage Constructor

Glossary Item Box

Overload List

Overload | Description
IsolatedStorage Constructor() | Stores values in the IsolatedStorage for the application in {Company}\{Product} path.
IsolatedStorage Constructor(String) | Stores values in the IsolatedStorage for the application in path.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IsolatedStorage Class
IsolatedStorage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
IsolatedStorage Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > IsolatedStorage Class > IsolatedStorage Constructor : IsolatedStorage Constructor()

Glossary Item Box

Stores values in the IsolatedStorage for the application in {Company}\{Product} path.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public IsolatedStorage()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IsolatedStorage Class
IsolatedStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsolatedStorage Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > IsolatedStorage Class > IsolatedStorage Constructor : IsolatedStorage Constructor(String)

relativePath

Glossary Item Box

Stores values in the IsolatedStorage for the application in path.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal relativePath As String _
)
C#
public IsolatedStorage(
   string relativePath
)

Parameters

relativePath

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IsolatedStorage Class
IsolatedStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IsolatedStorage Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : IsolatedStorage Class

Glossary Item Box

For a list of all members of this type, see IsolatedStorage members.

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

See Also

Reference

IsolatedStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > IsolatedStorage Class : Delete Method

path
name

Glossary Item Box

Removes a property from the storage by name

Syntax

Visual Basic (Declaration)
Public Sub Delete( _
   ByVal path As String, _
   ByVal name As String _
)
C#
public void Delete(
   string path,
   string name
)

Parameters

path
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IsolatedStorage Class
IsolatedStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > IsolatedStorage Class : Read Method

path
name
value

Glossary Item Box

returns true if the property was successfully retireved into the output variable 'value'

Syntax

Visual Basic (Declaration)
Public Function Read( _
   ByVal path As String, _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
public bool Read(
   string path,
   string name,
   out string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IsolatedStorage Class
IsolatedStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > IsolatedStorage Class : Write Method

path
name
value

Glossary Item Box

Writes the given property by name

Syntax

Visual Basic (Declaration)
Public Sub Write( _
   ByVal path As String, _
   ByVal name As String, _
   ByVal value As String _
)
C#
public void Write(
   string path,
   string name,
   string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IsolatedStorage Class
IsolatedStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegistryStorage Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : RegistryStorage Class

Glossary Item Box

Stores values in the registry at HKCU\Software\{Company}\{Product} path.

Syntax

Visual Basic (Declaration)
Public Class RegistryStorage
   Implements CSharpTest.Net.Serialization.INameValueStore
C#
public class RegistryStorage : CSharpTest.Net.Serialization.INameValueStore

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.StorageClasses.RegistryStorage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegistryStorage Members
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
RegistryStorage Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : RegistryStorage Class

Glossary Item Box

The following tables list the members exposed by RegistryStorage.

Public Constructors

 | Name | Description
Public Constructor | RegistryStorage Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

See Also

Reference

RegistryStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegistryStorage Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > RegistryStorage Class : RegistryStorage Constructor

Glossary Item Box

Overload List

Overload | Description
RegistryStorage Constructor() | Stores values in the registry at HKCU\Software\{Company}\{Product} path.
RegistryStorage Constructor(String) | Stores values in the registry at HKCU\Software\{Company}\{Product} path.
RegistryStorage Constructor(RegistryKey,String) | Stores values in the registry at path.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegistryStorage Class
RegistryStorage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
RegistryStorage Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > RegistryStorage Class > RegistryStorage Constructor : RegistryStorage Constructor()

Glossary Item Box

Stores values in the registry at HKCU\Software\{Company}\{Product} path.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public RegistryStorage()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegistryStorage Class
RegistryStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegistryStorage Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > RegistryStorage Class > RegistryStorage Constructor : RegistryStorage Constructor(String)

hkcuPath

Glossary Item Box

Stores values in the registry at HKCU\Software\{Company}\{Product} path.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal hkcuPath As String _
)
C#
public RegistryStorage(
   string hkcuPath
)

Parameters

hkcuPath

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegistryStorage Class
RegistryStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegistryStorage Constructor(RegistryKey,String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > RegistryStorage Class > RegistryStorage Constructor : RegistryStorage Constructor(RegistryKey,String)

hiveRoot
path

Glossary Item Box

Stores values in the registry at path.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal hiveRoot As RegistryKey, _
   ByVal path As String _
)
C#
public RegistryStorage(
   RegistryKey hiveRoot,
   string path
)

Parameters

hiveRoot
path

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegistryStorage Class
RegistryStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
RegistryStorage Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : RegistryStorage Class

Glossary Item Box

For a list of all members of this type, see RegistryStorage members.

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value'
Public Method | Write | Writes the given property by name
Top

See Also

Reference

RegistryStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > RegistryStorage Class : Delete Method

path
name

Glossary Item Box

Removes a property from the storage by name

Syntax

Visual Basic (Declaration)
Public Sub Delete( _
   ByVal path As String, _
   ByVal name As String _
)
C#
public void Delete(
   string path,
   string name
)

Parameters

path
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegistryStorage Class
RegistryStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > RegistryStorage Class : Read Method

path
name
value

Glossary Item Box

returns true if the property was successfully retireved into the output variable 'value'

Syntax

Visual Basic (Declaration)
Public Function Read( _
   ByVal path As String, _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
public bool Read(
   string path,
   string name,
   out string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegistryStorage Class
RegistryStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > RegistryStorage Class : Write Method

path
name
value

Glossary Item Box

Writes the given property by name

Syntax

Visual Basic (Declaration)
Public Sub Write( _
   ByVal path As String, _
   ByVal name As String, _
   ByVal value As String _
)
C#
public void Write(
   string path,
   string name,
   string value
)

Parameters

path
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegistryStorage Class
RegistryStorage Members

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingStorage Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : UserSettingStorage Class

Glossary Item Box

Stores values in the local configuration section: "userSettings"

Syntax

Visual Basic (Declaration)
Public Class UserSettingStorage
   Inherits AppSettingStorage
   Implements CSharpTest.Net.Serialization.INameValueStore
C#
public class UserSettingStorage : AppSettingStorage, CSharpTest.Net.Serialization.INameValueStore

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage
CSharpTest.Net.Serialization.StorageClasses.UserSettingStorage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingStorage Members
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
UserSettingStorage Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : UserSettingStorage Class

Glossary Item Box

The following tables list the members exposed by UserSettingStorage.

Public Constructors

 | Name | Description
Public Constructor | UserSettingStorage Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name (Inherited from CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage)
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value' (Inherited from CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage)
Public Method | Write | Writes the given property by name (Inherited from CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage)
Top

Protected Methods

 | Name | Description
Protected Method | MakePath | Overridden. Creates the full name of the item from path and name
Protected Method | Open | Overridden. Opens a configuration section and returns the key/value collection associated.
Top

See Also

Reference

UserSettingStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingStorage Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > UserSettingStorage Class : UserSettingStorage Constructor

Glossary Item Box

Overload List

Overload | Description
UserSettingStorage Constructor() | Stores values in the local application's configuration
UserSettingStorage Constructor(ConfigurationUserLevel) | Stores values in the local application's configuration

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingStorage Class
UserSettingStorage Members


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingStorage Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > UserSettingStorage Class > UserSettingStorage Constructor : UserSettingStorage Constructor()

Glossary Item Box

Stores values in the local application's configuration

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public UserSettingStorage()

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingStorage Class
UserSettingStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UserSettingStorage Constructor(ConfigurationUserLevel)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > UserSettingStorage Class > UserSettingStorage Constructor : UserSettingStorage Constructor(ConfigurationUserLevel)

configUserLevel

Glossary Item Box

Stores values in the local application's configuration

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal configUserLevel As ConfigurationUserLevel _
)
C#
public UserSettingStorage(
   ConfigurationUserLevel configUserLevel
)

Parameters

configUserLevel

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingStorage Class
UserSettingStorage Members
Overload List

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
UserSettingStorage Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace : UserSettingStorage Class

Glossary Item Box

For a list of all members of this type, see UserSettingStorage members.

Public Methods

 | Name | Description
Public Method | Delete | Removes a property from the storage by name (Inherited from CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage)
Public Method | Read | returns true if the property was successfully retireved into the output variable 'value' (Inherited from CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage)
Public Method | Write | Writes the given property by name (Inherited from CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage)
Top

Protected Methods

 | Name | Description
Protected Method | MakePath | Overridden. Creates the full name of the item from path and name
Protected Method | Open | Overridden. Opens a configuration section and returns the key/value collection associated.
Top

See Also

Reference

UserSettingStorage Class
CSharpTest.Net.Serialization.StorageClasses Namespace

Source Code

Library/Serialization/StorageClasses.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MakePath Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > UserSettingStorage Class : MakePath Method

path
name

Glossary Item Box

Creates the full name of the item from path and name

Syntax

Visual Basic (Declaration)
Protected Overrides Function MakePath( _
   ByVal path As String, _
   ByVal name As String _
) As String
C#
protected override string MakePath(
   string path,
   string name
)

Parameters

path
name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingStorage Class
UserSettingStorage Members
Base Implementation in MakePath


%%PageItemTitle%%

[image]
CSharpTest.Net
Open Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization.StorageClasses Namespace > UserSettingStorage Class : Open Method

path
config

Glossary Item Box

Opens a configuration section and returns the key/value collection associated.

Syntax

Visual Basic (Declaration)
Protected Overrides Function Open( _
   ByVal path As String, _
   ByRef config As Configuration _
) As KeyValueConfigurationCollection
C#
protected override KeyValueConfigurationCollection Open(
   string path,
   out Configuration config
)

Parameters

path
config

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingStorage Class
UserSettingStorage Members
Base Implementation in Open


%%ItemTitle%%

CSharpTest.Net.Services Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Services Namespace

Glossary Item Box

Classes

 | Class | Description
Class | ServiceAccessEntry | An over-simplified ACE for a service's access control
Class | SvcControlManager | Advanced Service Control for installation/uninstallation and security settings
Class | SvcControlManager.NT_AUTHORITY | Represets common NT_AUTHORITY service accounts that do not require a password at install time.

Enumerations

 | Enumeration | Description
Enumeration | ServiceAccessRights | Access control rights specific to a Win32 Service

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
ServiceAccessEntry Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : ServiceAccessEntry Class

Glossary Item Box

An over-simplified ACE for a service's access control

Syntax

Visual Basic (Declaration)
Public Class ServiceAccessEntry
   Inherits System.Attribute
C#
public class ServiceAccessEntry : System.Attribute

Inheritance Hierarchy

System.Object
System.Attribute
CSharpTest.Net.Services.ServiceAccessEntry

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceAccessEntry Members
CSharpTest.Net.Services Namespace

Source Code

Library/Services/ServiceAccessRights.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ServiceAccessEntry Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : ServiceAccessEntry Class

Glossary Item Box

The following tables list the members exposed by ServiceAccessEntry.

Public Constructors

 | Name | Description
Public Constructor | ServiceAccessEntry Constructor | Constructs a ServiceAccessEntry to represent a simplified ACE entry for a service
Top

Public Fields

 | Name | Description
Public Field | AccessMask | The permission(s) to grant
Public Field | Qualifier | Grant or deny the access
Public Field | Sid | The well-known account identifier to grant/deny access to
Top

Public Properties

 | Name | Description
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

ServiceAccessEntry Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/ServiceAccessRights.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ServiceAccessEntry Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > ServiceAccessEntry Class : ServiceAccessEntry Constructor

sid
qualifier
accessMask

Glossary Item Box

Constructs a ServiceAccessEntry to represent a simplified ACE entry for a service

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal sid As WellKnownSidType, _
   ByVal qualifier As AceQualifier, _
   ByVal accessMask As ServiceAccessRights _
)
C#
public ServiceAccessEntry(
   WellKnownSidType sid,
   AceQualifier qualifier,
   ServiceAccessRights accessMask
)

Parameters

sid
qualifier
accessMask

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceAccessEntry Class
ServiceAccessEntry Members

Source Code

Library/Services/ServiceAccessRights.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
ServiceAccessEntry Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : ServiceAccessEntry Class

Glossary Item Box

For a list of all members of this type, see ServiceAccessEntry members.

Public Fields

 | Name | Description
Public Field | AccessMask | The permission(s) to grant
Public Field | Qualifier | Grant or deny the access
Public Field | Sid | The well-known account identifier to grant/deny access to
Top

See Also

Reference

ServiceAccessEntry Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/ServiceAccessRights.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AccessMask Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > ServiceAccessEntry Class : AccessMask Field

Glossary Item Box

The permission(s) to grant

Syntax

Visual Basic (Declaration)
Public ReadOnly AccessMask As ServiceAccessRights
C#
public readonly ServiceAccessRights AccessMask

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceAccessEntry Class
ServiceAccessEntry Members

Used By

SvcControlManager.SetAccess(IEnumerable)


%%PageItemTitle%%

[image]
CSharpTest.Net
Qualifier Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > ServiceAccessEntry Class : Qualifier Field

Glossary Item Box

Grant or deny the access

Syntax

Visual Basic (Declaration)
Public ReadOnly Qualifier As AceQualifier
C#
public readonly AceQualifier Qualifier

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceAccessEntry Class
ServiceAccessEntry Members

Used By

SvcControlManager.SetAccess(IEnumerable)


%%PageItemTitle%%

[image]
CSharpTest.Net
Sid Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > ServiceAccessEntry Class : Sid Field

Glossary Item Box

The well-known account identifier to grant/deny access to

Syntax

Visual Basic (Declaration)
Public ReadOnly Sid As WellKnownSidType
C#
public readonly WellKnownSidType Sid

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ServiceAccessEntry Class
ServiceAccessEntry Members

Used By

SvcControlManager.SetAccess(IEnumerable)


%%PageItemTitle%%

[image]
CSharpTest.Net
SvcControlManager Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : SvcControlManager Class

Glossary Item Box

Advanced Service Control for installation/uninstallation and security settings

Syntax

Visual Basic (Declaration)
Public Class SvcControlManager
C#
public class SvcControlManager

Inheritance Hierarchy

System.Object
CSharpTest.Net.Services.SvcControlManager

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Members
CSharpTest.Net.Services Namespace

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SvcControlManager Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : SvcControlManager Class

Glossary Item Box

The following tables list the members exposed by SvcControlManager.

Public Constructors

 | Name | Description
Public Constructor | SvcControlManager Constructor | Constructs the SvcControlManager for the service name provided.
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Create | Creates the specified service and returns a SvcControlManager for the service created
Public Method | Delete | Stops/Deletes the specified service
Public Method | Dispose | Disposes of the SvcControlManager
Public Method | SetAccess | Replaces the access control list for the service.
Public Method | SetDelayAutostart | Configures the service to use the delayed auto-start policy
Public Method | SetDescription | Sets the description text of the service.
Public Method | SetRestartOnFailure | Configures the service to auto-restart on failure
Public Method | SetServiceExeArgs | Changes the service's executable and arguments
Public Method | SetShutdownTimeout | Sets the service's default shutdown timeout period.
Public Method | Start | Starts the service with the arguments specified and waits for the service to enter the running state.
Public Method | Stop | Stops the service and waits for the service to enter the Stopped state.
Top

See Also

Reference

SvcControlManager Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SvcControlManager Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : SvcControlManager Constructor

serviceName

Glossary Item Box

Constructs the SvcControlManager for the service name provided.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal serviceName As String _
)
C#
public SvcControlManager(
   string serviceName
)

Parameters

serviceName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Used By

ServiceCommands.Installation.UninstallService(String)
SvcControlManager SvcControlManager.Create(String,String,Boolean,ServiceStartMode,String,String[],String,String)

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SvcControlManager Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : SvcControlManager Class

Glossary Item Box

For a list of all members of this type, see SvcControlManager members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Create | Creates the specified service and returns a SvcControlManager for the service created
Public Method | Delete | Stops/Deletes the specified service
Public Method | Dispose | Disposes of the SvcControlManager
Public Method | SetAccess | Replaces the access control list for the service.
Public Method | SetDelayAutostart | Configures the service to use the delayed auto-start policy
Public Method | SetDescription | Sets the description text of the service.
Public Method | SetRestartOnFailure | Configures the service to auto-restart on failure
Public Method | SetServiceExeArgs | Changes the service's executable and arguments
Public Method | SetShutdownTimeout | Sets the service's default shutdown timeout period.
Public Method | Start | Starts the service with the arguments specified and waits for the service to enter the running state.
Public Method | Stop | Stops the service and waits for the service to enter the Stopped state.
Top

See Also

Reference

SvcControlManager Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : Create Method

serviceName
displayName
interactive
startupType
exePath
arguments
accountName
password

Glossary Item Box

Creates the specified service and returns a SvcControlManager for the service created

Syntax

Visual Basic (Declaration)
Public Shared Function Create( _
   ByVal serviceName As String, _
   ByVal displayName As String, _
   ByVal interactive As Boolean, _
   ByVal startupType As ServiceStartMode, _
   ByVal exePath As String, _
   ByVal arguments() As String, _
   ByVal accountName As String, _
   ByVal password As String _
) As SvcControlManager
C#
public static SvcControlManager Create(
   string serviceName,
   string displayName,
   bool interactive,
   ServiceStartMode startupType,
   string exePath,
   string[] arguments,
   string accountName,
   string password
)

Parameters

serviceName
displayName
interactive
startupType
exePath
arguments
accountName
password

Exceptions

Exception | Description
System.ComponentModel.Win32Exception |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Used By

ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Delete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : Delete Method

Glossary Item Box

Stops/Deletes the specified service

Syntax

Visual Basic (Declaration)
Public Sub Delete()
C#
public void Delete()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Used By

ServiceCommands.Installation.UninstallService(String)

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : Dispose Method

Glossary Item Box

Disposes of the SvcControlManager

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetAccess Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : SetAccess Method

aces

Glossary Item Box

Replaces the access control list for the service.

Syntax

Visual Basic (Declaration)
Public Sub SetAccess( _
   ByVal aces As IEnumerable(Of ServiceAccessEntry) _
)
C#
public void SetAccess(
   IEnumerable<ServiceAccessEntry> aces
)

Parameters

aces

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetDelayAutostart Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : SetDelayAutostart Method

enabled

Glossary Item Box

Configures the service to use the delayed auto-start policy

Syntax

Visual Basic (Declaration)
Public Sub SetDelayAutostart( _
   ByVal enabled As Boolean _
)
C#
public void SetDelayAutostart(
   bool enabled
)

Parameters

enabled

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetDescription Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : SetDescription Method

description

Glossary Item Box

Sets the description text of the service.

Syntax

Visual Basic (Declaration)
Public Sub SetDescription( _
   ByVal description As String _
)
C#
public void SetDescription(
   string description
)

Parameters

description

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Used By

ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetRestartOnFailure Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : SetRestartOnFailure Method

restartAttempts
restartDelay
resetFailuresDelay

Glossary Item Box

Configures the service to auto-restart on failure

Syntax

Visual Basic (Declaration)
Public Sub SetRestartOnFailure( _
   ByVal restartAttempts As Integer, _
   ByVal restartDelay As Integer, _
   ByVal resetFailuresDelay As Integer _
)
C#
public void SetRestartOnFailure(
   int restartAttempts,
   int restartDelay,
   int resetFailuresDelay
)

Parameters

restartAttempts
restartDelay
resetFailuresDelay

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetServiceExeArgs Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : SetServiceExeArgs Method

exePath
arguments

Glossary Item Box

Changes the service's executable and arguments

Syntax

Visual Basic (Declaration)
Public Sub SetServiceExeArgs( _
   ByVal exePath As String, _
   ByVal arguments() As String _
)
C#
public void SetServiceExeArgs(
   string exePath,
   string[] arguments
)

Parameters

exePath
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetShutdownTimeout Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : SetShutdownTimeout Method

timeoutValue

Glossary Item Box

Sets the service's default shutdown timeout period.

Syntax

Visual Basic (Declaration)
Public Sub SetShutdownTimeout( _
   ByVal timeoutValue As TimeSpan _
)
C#
public void SetShutdownTimeout(
   TimeSpan timeoutValue
)

Parameters

timeoutValue

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : Start Method

arguments

Glossary Item Box

Starts the service with the arguments specified and waits for the service to enter the running state.

Syntax

Visual Basic (Declaration)
Public Sub Start( _
   ByVal arguments() As String _
)
C#
public void Start(
   string[] arguments
)

Parameters

arguments

Exceptions

Exception | Description
System.ApplicationException | The exception that is thrown when a non-fatal application error occurs.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Stop Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager Class : Stop Method

Glossary Item Box

Stops the service and waits for the service to enter the Stopped state.

Syntax

Visual Basic (Declaration)
Public Sub Stop()
C#
public void Stop()

Exceptions

Exception | Description
System.ApplicationException | The exception that is thrown when a non-fatal application error occurs.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager Class
SvcControlManager Members

Source Code

Library/Services/SvcControlManager.cs

Used By

SvcControlManager.Delete()


%%PageItemTitle%%

[image]
CSharpTest.Net
SvcControlManager.NT_AUTHORITY Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : SvcControlManager.NT_AUTHORITY Class

Glossary Item Box

Represets common NT_AUTHORITY service accounts that do not require a password at install time.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class SvcControlManager.NT_AUTHORITY
C#
public static class SvcControlManager.NT_AUTHORITY

Inheritance Hierarchy

System.Object
CSharpTest.Net.Services.SvcControlManager.NT_AUTHORITY

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager.NT_AUTHORITY Members
CSharpTest.Net.Services Namespace

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SvcControlManager.NT_AUTHORITY Class Members
See Also Fields Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : SvcControlManager.NT_AUTHORITY Class

Glossary Item Box

The following tables list the members exposed by SvcControlManager.NT_AUTHORITY.

Public Fields

 | Name | Description
Public Field | LocalService | NT_AUTHORITY\LocalService
Public Field | LocalSystem | NT_AUTHORITY\LocalSystem
Public Field | NetworkService | NT_AUTHORITY\NetworkService
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Account | Selects the account bysed on the System.ServiceProcess.ServiceAccount enumeration
Top

See Also

Reference

SvcControlManager.NT_AUTHORITY Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SvcControlManager.NT_AUTHORITY Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : SvcControlManager.NT_AUTHORITY Class

Glossary Item Box

For a list of all members of this type, see SvcControlManager.NT_AUTHORITY members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Account | Selects the account bysed on the System.ServiceProcess.ServiceAccount enumeration
Top

See Also

Reference

SvcControlManager.NT_AUTHORITY Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Account Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager.NT_AUTHORITY Class : Account Method

account

Glossary Item Box

Selects the account bysed on the System.ServiceProcess.ServiceAccount enumeration

Syntax

Visual Basic (Declaration)
Public Shared Function Account( _
   ByVal account As ServiceAccount _
) As String
C#
public static string Account(
   ServiceAccount account
)

Parameters

account

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager.NT_AUTHORITY Class
SvcControlManager.NT_AUTHORITY Members

Used By

ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
SvcControlManager.NT_AUTHORITY Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : SvcControlManager.NT_AUTHORITY Class

Glossary Item Box

For a list of all members of this type, see SvcControlManager.NT_AUTHORITY members.

Public Fields

 | Name | Description
Public Field | LocalService | NT_AUTHORITY\LocalService
Public Field | LocalSystem | NT_AUTHORITY\LocalSystem
Public Field | NetworkService | NT_AUTHORITY\NetworkService
Top

See Also

Reference

SvcControlManager.NT_AUTHORITY Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalService Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager.NT_AUTHORITY Class : LocalService Field

Glossary Item Box

NT_AUTHORITY\LocalService

Syntax

Visual Basic (Declaration)
Public Const LocalService As String
C#
public const string LocalService

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager.NT_AUTHORITY Class
SvcControlManager.NT_AUTHORITY Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalSystem Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager.NT_AUTHORITY Class : LocalSystem Field

Glossary Item Box

NT_AUTHORITY\LocalSystem

Syntax

Visual Basic (Declaration)
Public Const LocalSystem As String
C#
public const string LocalSystem

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager.NT_AUTHORITY Class
SvcControlManager.NT_AUTHORITY Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NetworkService Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace > SvcControlManager.NT_AUTHORITY Class : NetworkService Field

Glossary Item Box

NT_AUTHORITY\NetworkService

Syntax

Visual Basic (Declaration)
Public Const NetworkService As String
C#
public const string NetworkService

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SvcControlManager.NT_AUTHORITY Class
SvcControlManager.NT_AUTHORITY Members

Source Code

Library/Services/SvcControlManager.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ServiceAccessRights Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : ServiceAccessRights Enumeration

Glossary Item Box

Access control rights specific to a Win32 Service

Syntax

Visual Basic (Declaration)
Public Enum ServiceAccessRights
   Inherits System.Enum
C#
public enum ServiceAccessRights : System.Enum

Members

Member | Description
ACCESS_SYSTEM_SECURITY | Required to call the QueryServiceObjectSecurity or SetServiceObjectSecurity function to access the SACL. The proper way to obtain this access is to enable the SE_SECURITY_NAME privilege in the caller's current access token, open the handle for ACCESS_SYSTEM_SECURITY access, and then disable the privilege.
DELETE | Required to call the DeleteService function to delete the service.
GENERIC_EXECUTE | Includes STANDARD_RIGHTS_EXECUTE, SERVICE_START, SERVICE_STOP, SERVICE_PAUSE_CONTINUE, and SERVICE_USER_DEFINED_CONTROL
GENERIC_READ | Includes STANDARD_RIGHTS_READ, SERVICE_QUERY_CONFIG, SERVICE_QUERY_STATUS, SERVICE_INTERROGATE and SERVICE_ENUMERATE_DEPENDENTS.
GENERIC_WRITE | Includes STANDARD_RIGHTS_WRITE and SERVICE_CHANGE_CONFIG.
READ_CONTROL | Required to call the QueryServiceObjectSecurity function to query the security descriptor of the service object.
SERVICE_ALL_ACCESS | Includes STANDARD_RIGHTS_REQUIRED in addition to all access rights in this table.
SERVICE_CHANGE_CONFIG | Required to call the ChangeServiceConfig or ChangeServiceConfig2 function to change the service configuration. Because this grants the caller the right to change the executable file that the system runs, it should be granted only to administrators.
SERVICE_ENUMERATE_DEPENDENTS | Required to call the EnumDependentServices function to enumerate all the services dependent on the service.
SERVICE_INTERROGATE | Required to call the EnumDependentServices function to enumerate all the services dependent on the service.
SERVICE_PAUSE_CONTINUE | Required to call the ControlService function to pause or continue the service.
SERVICE_QUERY_CONFIG | Required to call the QueryServiceConfig and QueryServiceConfig2 functions to query the service configuration.
SERVICE_QUERY_STATUS | Required to call the QueryServiceStatusEx function to ask the service control manager about the status of the service.
SERVICE_START | Required to call the StartService function to start the service.
SERVICE_STOP | Required to call the ControlService function to stop the service.
SERVICE_USER_DEFINED_CONTROL | Required to call the ControlService function to specify a user-defined control code.
STANDARD_RIGHTS_EXECUTE | READ_CONTROL
STANDARD_RIGHTS_READ | READ_CONTROL
STANDARD_RIGHTS_REQUIRED | READ_CONTROL, DELETE, WRITE_DAC, WRITE_OWNER
STANDARD_RIGHTS_WRITE | READ_CONTROL
WRITE_DAC | Required to call the SetServiceObjectSecurity function to modify the Dacl member of the service object's security descriptor.
WRITE_OWNER | Required to call the SetServiceObjectSecurity function to modify the Owner and Group members of the service object's security descriptor.

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Services.ServiceAccessRights

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Services Namespace

Source Code

Library/Services/ServiceAccessRights.cs


%%ItemTitle%%

CSharpTest.Net.Synchronization Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Synchronization Namespace

Glossary Item Box

Classes

 | Class | Description
Class | DebugLockFactory | Creates a debugging lock factory that can track locks allocated and all acquired/released read/write locks
Class | DebugLockFactory<T> | Creates a debugging lock factory that can track locks allocated and all acquired/released read/write locks
Class | DebugLocking | Creates a tracking/assertion wrapper around an implementation of an ILockStrategy to verify lock state before and after acquisition and release of both reader and writer locks.
Class | DebugLocking<T> | Creates a tracking/assertion wrapper around an implementation of an ILockStrategy to verify lock state before and after acquisition and release of both reader and writer locks.
Class | ExclusiveLocking | wraps the reader/writer lock around Monitor
Class | IgnoreLockFactory | Singleton instance of ignore locking
Class | IgnoreLocking | wraps the reader/writer lock around Monitor
Class | LockCounterFactory | Creates a debugging lock factory that can track locks allocated and all acquired/released read/write locks
Class | LockCounterFactory<T> | Creates a debugging lock factory that can track locks allocated and all acquired/released read/write locks
Class | LockFactory<T> | A generic implementation that constructs a lock by type
Class | MutexLock | Creates a lock on a mutex that can be released via the Dispose() method, for use in a using statement
Class | ReaderWriterLocking | wraps the System.Threading.ReaderWriterLock lock, does not support read->write upgrades
Class | ReservedWriteLocking | provides a simple and fast, writer only lock, request for read immediatly return true.
Class | ReservedWriteLocking<T> | provides a simple and fast, writer only lock, request for read immediatly return true.
Class | SimpleReadWriteLocking | provides a simple and fast, reader-writer lock, does not support read->write upgrades, if you need an upgradeable lock, use UpgradeableReadWriteLocking
Class | WriterOnlyLocking | provides a writer-only lock around Monitor. The TryRead/ReleaseRead methods are no-ops and always return true.

Interfaces

 | Interface | Description
Interface | ILockFactory | A factory that produces instances of ILockStrategy to aquire/release read/write locks
Interface | ILockStrategy | An interface that allows reader/writer locking with the using() statement

Structures

 | Structure | Description
Structure | ReadLock | Allows a read lock to be disposed or elevated to a write lock
Structure | SafeLock | Used to acquire a lock(object) with a timeout, either specified or the default of 2 minutes.
Structure | SafeLock<TException> | Exactly as SafeLock except that <T> specifies the exception type to throw. Used to acquire a lock(object) with a timeout, either specified or the default of 2 minutes.
Structure | WriteLock | Allows a write lock to be disposed

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLockFactory Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory Class

Glossary Item Box

Creates a debugging lock factory that can track locks allocated and all acquired/released read/write locks

Syntax

Visual Basic (Declaration)
Public Class DebugLockFactory
   Inherits LockCounterFactory
   Implements CSharpTest.Net.Interfaces.IFactory(Of ILockStrategy), ILockFactory
C#
public class DebugLockFactory : LockCounterFactory, CSharpTest.Net.Interfaces.IFactory<ILockStrategy>, ILockFactory

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.LockCounterFactory
CSharpTest.Net.Synchronization.DebugLockFactory
CSharpTest.Net.Synchronization.DebugLockFactory<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DebugLockFactory Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory Class

Glossary Item Box

The following tables list the members exposed by DebugLockFactory.

Public Constructors

 | Name | Description
Public Constructor | DebugLockFactory Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxReaderCount | Returns the highest number of concurrent reads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count) (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalReaderCount | Returns the total number of read locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalWriterCount | Returns the total number of write locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Top

Public Properties

 | Name | Description
Public Property | CaptureStack | Toggle if the entire stack is captured on lock aquisition/release for newly created locks
Public Property | ConcurrentReads | Toggle if reads are allowed even if write lock was acquired
Public Property | LimitNestedReaders | Reader nesting limit for newly created locks
Public Property | LimitNestedWriters | Writer nesting limit for newly created locks
Public Property | LimitTimeout | Timeout limit for newly created locks
Public Property | LocalReaderCount | Returns the total number of current readers for this thread
Public Property | LocalWriterCount | Returns the total number of current writers for this thread
Top

Public Methods

 | Name | Description
Public Method | Create | Overridden. Constructs the lock wrapped in a DebugLocking instance
Public Method | GlobalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by any thread (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Method | LocalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by this thread
Top

See Also

Reference

DebugLockFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLockFactory Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : DebugLockFactory Constructor

Glossary Item Box

Overload List

Overload | Description
DebugLockFactory Constructor(ILockFactory) | Constructs the lock tracking factory
DebugLockFactory Constructor(ILockFactory,Boolean,Int32,Int32,Boolean,Int32) | Constructs the lock tracking factory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLockFactory Constructor(ILockFactory)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class > DebugLockFactory Constructor : DebugLockFactory Constructor(ILockFactory)

factory

Glossary Item Box

Constructs the lock tracking factory

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal factory As ILockFactory _
)
C#
public DebugLockFactory(
   ILockFactory factory
)

Parameters

factory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members
Overload List

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLockFactory Constructor(ILockFactory,Boolean,Int32,Int32,Boolean,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class > DebugLockFactory Constructor : DebugLockFactory Constructor(ILockFactory,Boolean,Int32,Int32,Boolean,Int32)

factory
captureStack
limitTimeout
limitNestedReaders
concurrentReads
limitNestedWriters

Glossary Item Box

Constructs the lock tracking factory

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal factory As ILockFactory, _
   ByVal captureStack As Boolean, _
   ByVal limitTimeout As Integer, _
   ByVal limitNestedReaders As Integer, _
   ByVal concurrentReads As Boolean, _
   ByVal limitNestedWriters As Integer _
)
C#
public DebugLockFactory(
   ILockFactory factory,
   bool captureStack,
   int limitTimeout,
   int limitNestedReaders,
   bool concurrentReads,
   int limitNestedWriters
)

Parameters

factory
captureStack
limitTimeout
limitNestedReaders
concurrentReads
limitNestedWriters

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members
Overload List

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DebugLockFactory Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory Class

Glossary Item Box

For a list of all members of this type, see DebugLockFactory members.

Public Methods

 | Name | Description
Public Method | Create | Overridden. Constructs the lock wrapped in a DebugLocking instance
Public Method | GlobalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by any thread (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Method | LocalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by this thread
Top

See Also

Reference

DebugLockFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : Create Method

Glossary Item Box

Constructs the lock wrapped in a DebugLocking instance

Syntax

Visual Basic (Declaration)
Public Overrides Function Create() As ILockStrategy
C#
public override ILockStrategy Create()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members
Base Implementation in Create
ILockStrategy

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalAssertNoLocks Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : LocalAssertNoLocks Method

Glossary Item Box

Asserts that none of the locks handed out are currently locked for read or write by this thread

Syntax

Visual Basic (Declaration)
Public Sub LocalAssertNoLocks()
C#
public void LocalAssertNoLocks()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DebugLockFactory Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory Class

Glossary Item Box

For a list of all members of this type, see DebugLockFactory members.

Public Properties

 | Name | Description
Public Property | CaptureStack | Toggle if the entire stack is captured on lock aquisition/release for newly created locks
Public Property | ConcurrentReads | Toggle if reads are allowed even if write lock was acquired
Public Property | LimitNestedReaders | Reader nesting limit for newly created locks
Public Property | LimitNestedWriters | Writer nesting limit for newly created locks
Public Property | LimitTimeout | Timeout limit for newly created locks
Public Property | LocalReaderCount | Returns the total number of current readers for this thread
Public Property | LocalWriterCount | Returns the total number of current writers for this thread
Top

See Also

Reference

DebugLockFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CaptureStack Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : CaptureStack Property

Glossary Item Box

Toggle if the entire stack is captured on lock aquisition/release for newly created locks

Syntax

Visual Basic (Declaration)
Public Property CaptureStack As Boolean
C#
public bool CaptureStack {get; set;}

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>(
    true, -1, 1, true, 1);

Assert.AreEqual(true, factory.CaptureStack);
factory.CaptureStack = false;
Assert.AreEqual(false, factory.CaptureStack);

Assert.AreEqual(true, factory.ConcurrentReads);
factory.ConcurrentReads = false;
Assert.AreEqual(false, factory.ConcurrentReads);

Assert.AreEqual(-1, factory.LimitTimeout);
factory.LimitTimeout = 1000;
Assert.AreEqual(1000, factory.LimitTimeout);

Assert.AreEqual(1, factory.LimitNestedReaders);
factory.LimitNestedReaders = 10;
Assert.AreEqual(10, factory.LimitNestedReaders);

Assert.AreEqual(1, factory.LimitNestedWriters);
factory.LimitNestedWriters = 5;
Assert.AreEqual(5, factory.LimitNestedWriters);
VB.NET Copy Code
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(True, -1, 1, True, 1)

Assert.AreEqual(True, factory.CaptureStack)
factory.CaptureStack = False
Assert.AreEqual(False, factory.CaptureStack)

Assert.AreEqual(True, factory.ConcurrentReads)
factory.ConcurrentReads = False
Assert.AreEqual(False, factory.ConcurrentReads)

Assert.AreEqual(-1, factory.LimitTimeout)
factory.LimitTimeout = 1000
Assert.AreEqual(1000, factory.LimitTimeout)

Assert.AreEqual(1, factory.LimitNestedReaders)
factory.LimitNestedReaders = 10
Assert.AreEqual(10, factory.LimitNestedReaders)

Assert.AreEqual(1, factory.LimitNestedWriters)
factory.LimitNestedWriters = 5
Assert.AreEqual(5, factory.LimitNestedWriters)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ConcurrentReads Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : ConcurrentReads Property

Glossary Item Box

Toggle if reads are allowed even if write lock was acquired

Syntax

Visual Basic (Declaration)
Public Property ConcurrentReads As Boolean
C#
public bool ConcurrentReads {get; set;}

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>(
    true, -1, 1, true, 1);

Assert.AreEqual(true, factory.CaptureStack);
factory.CaptureStack = false;
Assert.AreEqual(false, factory.CaptureStack);

Assert.AreEqual(true, factory.ConcurrentReads);
factory.ConcurrentReads = false;
Assert.AreEqual(false, factory.ConcurrentReads);

Assert.AreEqual(-1, factory.LimitTimeout);
factory.LimitTimeout = 1000;
Assert.AreEqual(1000, factory.LimitTimeout);

Assert.AreEqual(1, factory.LimitNestedReaders);
factory.LimitNestedReaders = 10;
Assert.AreEqual(10, factory.LimitNestedReaders);

Assert.AreEqual(1, factory.LimitNestedWriters);
factory.LimitNestedWriters = 5;
Assert.AreEqual(5, factory.LimitNestedWriters);
VB.NET Copy Code
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(True, -1, 1, True, 1)

Assert.AreEqual(True, factory.CaptureStack)
factory.CaptureStack = False
Assert.AreEqual(False, factory.CaptureStack)

Assert.AreEqual(True, factory.ConcurrentReads)
factory.ConcurrentReads = False
Assert.AreEqual(False, factory.ConcurrentReads)

Assert.AreEqual(-1, factory.LimitTimeout)
factory.LimitTimeout = 1000
Assert.AreEqual(1000, factory.LimitTimeout)

Assert.AreEqual(1, factory.LimitNestedReaders)
factory.LimitNestedReaders = 10
Assert.AreEqual(10, factory.LimitNestedReaders)

Assert.AreEqual(1, factory.LimitNestedWriters)
factory.LimitNestedWriters = 5
Assert.AreEqual(5, factory.LimitNestedWriters)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LimitNestedReaders Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : LimitNestedReaders Property

Glossary Item Box

Reader nesting limit for newly created locks

Syntax

Visual Basic (Declaration)
Public Property LimitNestedReaders As Integer
C#
public int LimitNestedReaders {get; set;}

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>(
    true, -1, 1, true, 1);

Assert.AreEqual(true, factory.CaptureStack);
factory.CaptureStack = false;
Assert.AreEqual(false, factory.CaptureStack);

Assert.AreEqual(true, factory.ConcurrentReads);
factory.ConcurrentReads = false;
Assert.AreEqual(false, factory.ConcurrentReads);

Assert.AreEqual(-1, factory.LimitTimeout);
factory.LimitTimeout = 1000;
Assert.AreEqual(1000, factory.LimitTimeout);

Assert.AreEqual(1, factory.LimitNestedReaders);
factory.LimitNestedReaders = 10;
Assert.AreEqual(10, factory.LimitNestedReaders);

Assert.AreEqual(1, factory.LimitNestedWriters);
factory.LimitNestedWriters = 5;
Assert.AreEqual(5, factory.LimitNestedWriters);
VB.NET Copy Code
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(True, -1, 1, True, 1)

Assert.AreEqual(True, factory.CaptureStack)
factory.CaptureStack = False
Assert.AreEqual(False, factory.CaptureStack)

Assert.AreEqual(True, factory.ConcurrentReads)
factory.ConcurrentReads = False
Assert.AreEqual(False, factory.ConcurrentReads)

Assert.AreEqual(-1, factory.LimitTimeout)
factory.LimitTimeout = 1000
Assert.AreEqual(1000, factory.LimitTimeout)

Assert.AreEqual(1, factory.LimitNestedReaders)
factory.LimitNestedReaders = 10
Assert.AreEqual(10, factory.LimitNestedReaders)

Assert.AreEqual(1, factory.LimitNestedWriters)
factory.LimitNestedWriters = 5
Assert.AreEqual(5, factory.LimitNestedWriters)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LimitNestedWriters Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : LimitNestedWriters Property

Glossary Item Box

Writer nesting limit for newly created locks

Syntax

Visual Basic (Declaration)
Public Property LimitNestedWriters As Integer
C#
public int LimitNestedWriters {get; set;}

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>(
    true, -1, 1, true, 1);

Assert.AreEqual(true, factory.CaptureStack);
factory.CaptureStack = false;
Assert.AreEqual(false, factory.CaptureStack);

Assert.AreEqual(true, factory.ConcurrentReads);
factory.ConcurrentReads = false;
Assert.AreEqual(false, factory.ConcurrentReads);

Assert.AreEqual(-1, factory.LimitTimeout);
factory.LimitTimeout = 1000;
Assert.AreEqual(1000, factory.LimitTimeout);

Assert.AreEqual(1, factory.LimitNestedReaders);
factory.LimitNestedReaders = 10;
Assert.AreEqual(10, factory.LimitNestedReaders);

Assert.AreEqual(1, factory.LimitNestedWriters);
factory.LimitNestedWriters = 5;
Assert.AreEqual(5, factory.LimitNestedWriters);
VB.NET Copy Code
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(True, -1, 1, True, 1)

Assert.AreEqual(True, factory.CaptureStack)
factory.CaptureStack = False
Assert.AreEqual(False, factory.CaptureStack)

Assert.AreEqual(True, factory.ConcurrentReads)
factory.ConcurrentReads = False
Assert.AreEqual(False, factory.ConcurrentReads)

Assert.AreEqual(-1, factory.LimitTimeout)
factory.LimitTimeout = 1000
Assert.AreEqual(1000, factory.LimitTimeout)

Assert.AreEqual(1, factory.LimitNestedReaders)
factory.LimitNestedReaders = 10
Assert.AreEqual(10, factory.LimitNestedReaders)

Assert.AreEqual(1, factory.LimitNestedWriters)
factory.LimitNestedWriters = 5
Assert.AreEqual(5, factory.LimitNestedWriters)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LimitTimeout Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : LimitTimeout Property

Glossary Item Box

Timeout limit for newly created locks

Syntax

Visual Basic (Declaration)
Public Property LimitTimeout As Integer
C#
public int LimitTimeout {get; set;}

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>(
    true, -1, 1, true, 1);

Assert.AreEqual(true, factory.CaptureStack);
factory.CaptureStack = false;
Assert.AreEqual(false, factory.CaptureStack);

Assert.AreEqual(true, factory.ConcurrentReads);
factory.ConcurrentReads = false;
Assert.AreEqual(false, factory.ConcurrentReads);

Assert.AreEqual(-1, factory.LimitTimeout);
factory.LimitTimeout = 1000;
Assert.AreEqual(1000, factory.LimitTimeout);

Assert.AreEqual(1, factory.LimitNestedReaders);
factory.LimitNestedReaders = 10;
Assert.AreEqual(10, factory.LimitNestedReaders);

Assert.AreEqual(1, factory.LimitNestedWriters);
factory.LimitNestedWriters = 5;
Assert.AreEqual(5, factory.LimitNestedWriters);
VB.NET Copy Code
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(True, -1, 1, True, 1)

Assert.AreEqual(True, factory.CaptureStack)
factory.CaptureStack = False
Assert.AreEqual(False, factory.CaptureStack)

Assert.AreEqual(True, factory.ConcurrentReads)
factory.ConcurrentReads = False
Assert.AreEqual(False, factory.ConcurrentReads)

Assert.AreEqual(-1, factory.LimitTimeout)
factory.LimitTimeout = 1000
Assert.AreEqual(1000, factory.LimitTimeout)

Assert.AreEqual(1, factory.LimitNestedReaders)
factory.LimitNestedReaders = 10
Assert.AreEqual(10, factory.LimitNestedReaders)

Assert.AreEqual(1, factory.LimitNestedWriters)
factory.LimitNestedWriters = 5
Assert.AreEqual(5, factory.LimitNestedWriters)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalReaderCount Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : LocalReaderCount Property

Glossary Item Box

Returns the total number of current readers for this thread

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LocalReaderCount As Integer
C#
public int LocalReaderCount {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members

Used By

DebugLockFactory.LocalAssertNoLocks()

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalWriterCount Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory Class : LocalWriterCount Property

Glossary Item Box

Returns the total number of current writers for this thread

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LocalWriterCount As Integer
C#
public int LocalWriterCount {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory Class
DebugLockFactory Members

Used By

DebugLockFactory.LocalAssertNoLocks()

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
DebugLockFactory<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory<T> Class

Glossary Item Box

Creates a debugging lock factory that can track locks allocated and all acquired/released read/write locks

Syntax

Visual Basic (Declaration)
Public Class DebugLockFactory(Of T As {New, ILockStrategy})
   Inherits DebugLockFactory
   Implements CSharpTest.Net.Interfaces.IFactory(Of ILockStrategy), ILockFactory
C#
public class DebugLockFactory<T> : DebugLockFactory, CSharpTest.Net.Interfaces.IFactory<ILockStrategy>, ILockFactory
where T: new(), ILockStrategy

Type Parameters

T

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>(
    false, 0, 1, false, 1);

using (ILockStrategy lck = factory.Create())
{
    using (lck.Write())
    using (lck.Write()) //second lock, allow recurse 1 time as per constructor
    {
        try { using (lck.Write()) { Assert.Fail(); } }
        catch (Exception ex)
        {
            Assert.IsTrue(ex is DebugAssertionFailedException);//nesting prohibited by debug lock
        }
    }

    using (lck.Read())
    using (lck.Read()) //second lock, allow recurse 1 time as per constructor
    {
        try { using (lck.Read()) { Assert.Fail(); } }
        catch (Exception ex)
        {
            Assert.IsTrue(ex is DebugAssertionFailedException);//nesting prohibited by debug lock
        }
    }
}
VB.NET Copy Code
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)

Using lck As ILockStrategy = factory.Create()
    Using lck.Write()
        Using lck.Write()
            'second lock, allow recurse 1 time as per constructor
            Try
                Using lck.Write()
                    Assert.Fail()
                End Using
            Catch ex As Exception
                    'nesting prohibited by debug lock
                Assert.IsTrue(TypeOf ex Is DebugAssertionFailedException)
            End Try
        End Using
    End Using

    Using lck.Read()
        Using lck.Read()
            'second lock, allow recurse 1 time as per constructor
            Try
                Using lck.Read()
                    Assert.Fail()
                End Using
            Catch ex As Exception
                    'nesting prohibited by debug lock
                Assert.IsTrue(TypeOf ex Is DebugAssertionFailedException)
            End Try
        End Using
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.LockCounterFactory
CSharpTest.Net.Synchronization.DebugLockFactory
CSharpTest.Net.Synchronization.DebugLockFactory<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory<T> Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DebugLockFactory<T> Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory<T> Class

Glossary Item Box

The following tables list the members exposed by DebugLockFactory<T>.

Public Constructors

 | Name | Description
Public Constructor | DebugLockFactory<T> Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxReaderCount | Returns the highest number of concurrent reads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count) (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalReaderCount | Returns the total number of read locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalWriterCount | Returns the total number of write locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Top

Public Properties

 | Name | Description
Public Property | CaptureStack | Toggle if the entire stack is captured on lock aquisition/release for newly created locks (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | ConcurrentReads | Toggle if reads are allowed even if write lock was acquired (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LimitNestedReaders | Reader nesting limit for newly created locks (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LimitNestedWriters | Writer nesting limit for newly created locks (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LimitTimeout | Timeout limit for newly created locks (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LocalReaderCount | Returns the total number of current readers for this thread (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LocalWriterCount | Returns the total number of current writers for this thread (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Top

Public Methods

 | Name | Description
Public Method | Create | Constructs the lock wrapped in a DebugLocking instance (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Method | GlobalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by any thread (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Method | LocalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by this thread (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Top

See Also

Reference

DebugLockFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLockFactory<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory<T> Class : DebugLockFactory<T> Constructor

Glossary Item Box

Overload List

Overload | Description
DebugLockFactory<T> Constructor() | Constructs the lock tracking factory
DebugLockFactory<T> Constructor(Boolean,Int32,Int32,Boolean,Int32) | Constructs the lock tracking factory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory<T> Class
DebugLockFactory<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLockFactory<T> Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory<T> Class > DebugLockFactory<T> Constructor : DebugLockFactory<T> Constructor()

Glossary Item Box

Constructs the lock tracking factory

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public DebugLockFactory<T>()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory<T> Class
DebugLockFactory<T> Members
Overload List

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLockFactory<T> Constructor(Boolean,Int32,Int32,Boolean,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLockFactory<T> Class > DebugLockFactory<T> Constructor : DebugLockFactory<T> Constructor(Boolean,Int32,Int32,Boolean,Int32)

captureStack
limitTimeout
limitNestedReaders
concurrentReads
limitNestedWriters

Glossary Item Box

Constructs the lock tracking factory

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal captureStack As Boolean, _
   ByVal limitTimeout As Integer, _
   ByVal limitNestedReaders As Integer, _
   ByVal concurrentReads As Boolean, _
   ByVal limitNestedWriters As Integer _
)
C#
public DebugLockFactory<T>(
   bool captureStack,
   int limitTimeout,
   int limitNestedReaders,
   bool concurrentReads,
   int limitNestedWriters
)

Parameters

captureStack
limitTimeout
limitNestedReaders
concurrentReads
limitNestedWriters

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>(
    false, 0, 1, false, 1);

using (ILockStrategy lck = factory.Create())
{
    using (lck.Write())
    using (lck.Write()) //second lock, allow recurse 1 time as per constructor
    {
        try { using (lck.Write()) { Assert.Fail(); } }
        catch (Exception ex)
        {
            Assert.IsTrue(ex is DebugAssertionFailedException);//nesting prohibited by debug lock
        }
    }

    using (lck.Read())
    using (lck.Read()) //second lock, allow recurse 1 time as per constructor
    {
        try { using (lck.Read()) { Assert.Fail(); } }
        catch (Exception ex)
        {
            Assert.IsTrue(ex is DebugAssertionFailedException);//nesting prohibited by debug lock
        }
    }
}
VB.NET Copy Code
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)

Using lck As ILockStrategy = factory.Create()
    Using lck.Write()
        Using lck.Write()
            'second lock, allow recurse 1 time as per constructor
            Try
                Using lck.Write()
                    Assert.Fail()
                End Using
            Catch ex As Exception
                    'nesting prohibited by debug lock
                Assert.IsTrue(TypeOf ex Is DebugAssertionFailedException)
            End Try
        End Using
    End Using

    Using lck.Read()
        Using lck.Read()
            'second lock, allow recurse 1 time as per constructor
            Try
                Using lck.Read()
                    Assert.Fail()
                End Using
            Catch ex As Exception
                    'nesting prohibited by debug lock
                Assert.IsTrue(TypeOf ex Is DebugAssertionFailedException)
            End Try
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLockFactory<T> Class
DebugLockFactory<T> Members
Overload List

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLocking Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking Class

Glossary Item Box

Creates a tracking/assertion wrapper around an implementation of an ILockStrategy to verify lock state before and after acquisition and release of both reader and writer locks.

Syntax

Visual Basic (Declaration)
Public Class DebugLocking
   Implements ILockStrategy
C#
public class DebugLocking : ILockStrategy

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.DebugLocking
CSharpTest.Net.Synchronization.DebugLocking<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DebugLocking Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking Class

Glossary Item Box

The following tables list the members exposed by DebugLocking.

Public Constructors

 | Name | Description
Public Constructor | DebugLocking Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads
Public Field | MaxReaderCount | Returns the highest number of concurrent reads
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count)
Public Field | TotalReaderCount | Returns the total number of read locks acquired
Public Field | TotalWriterCount | Returns the total number of write locks acquired
Top

Public Properties

 | Name | Description
Public Property | CaptureStack | Capture the stack on every lock aquisition and release
Public Property | LocalReaderCount | Returns the total number of current readers for this thread
Public Property | LocalWriterCount | Returns the total number of current writers for this thread
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of this lock
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

DebugLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLocking Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : DebugLocking Constructor

Glossary Item Box

Overload List

Overload | Description
DebugLocking Constructor(ILockStrategy) | Constructs the lock tracking object
DebugLocking Constructor(ILockStrategy,Boolean,Int32,Int32,Boolean,Int32) | Constructs the lock tracking object

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLocking Constructor(ILockStrategy)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class > DebugLocking Constructor : DebugLocking Constructor(ILockStrategy)

lck

Glossary Item Box

Constructs the lock tracking object

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal lck As ILockStrategy _
)
C#
public DebugLocking(
   ILockStrategy lck
)

Parameters

lck

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members
Overload List

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLocking Constructor(ILockStrategy,Boolean,Int32,Int32,Boolean,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class > DebugLocking Constructor : DebugLocking Constructor(ILockStrategy,Boolean,Int32,Int32,Boolean,Int32)

lck
captureStack
limitTimeout
limitNestedReaders
concurrentReads
limitNestedWriters

Glossary Item Box

Constructs the lock tracking object

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal lck As ILockStrategy, _
   ByVal captureStack As Boolean, _
   ByVal limitTimeout As Integer, _
   ByVal limitNestedReaders As Integer, _
   ByVal concurrentReads As Boolean, _
   ByVal limitNestedWriters As Integer _
)
C#
public DebugLocking(
   ILockStrategy lck,
   bool captureStack,
   int limitTimeout,
   int limitNestedReaders,
   bool concurrentReads,
   int limitNestedWriters
)

Parameters

lck
captureStack
limitTimeout
limitNestedReaders
concurrentReads
limitNestedWriters

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members
Overload List

Source Code

Library/Synchronization/DebugLocking.cs

Used By

ILockStrategy DebugLockFactory.Create()


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DebugLocking Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking Class

Glossary Item Box

For a list of all members of this type, see DebugLocking members.

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of this lock
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

DebugLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : Dispose Method

Glossary Item Box

Disposes of this lock

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : Read Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Overload List

Overload | Description
Read(Int32) | Returns a reader lock that can be elevated to a write lock
Read() | Returns a reader lock that can be elevated to a write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class > Read Method : Read(Int32) Method

timeout

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read( _
   ByVal timeout As Integer _
) As ReadLock
C#
public ReadLock Read(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(0, l.MaxReaderCount);

    using (l.Read())
    {
        Assert.AreEqual(1, l.CurrentReaderCount);
        Assert.AreEqual(1, l.LocalReaderCount);
        using (l.Read(0))
        {
            Assert.AreEqual(2, l.CurrentReaderCount);
            Assert.AreEqual(2, l.LocalReaderCount);
        }
    }

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(2, l.MaxReaderCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(0, l.MaxReaderCount)

    Using l.Read()
        Assert.AreEqual(1, l.CurrentReaderCount)
        Assert.AreEqual(1, l.LocalReaderCount)
        Using l.Read(0)
            Assert.AreEqual(2, l.CurrentReaderCount)
            Assert.AreEqual(2, l.LocalReaderCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(2, l.MaxReaderCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class > Read Method : Read() Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read() As ReadLock
C#
public ReadLock Read()

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(0, l.MaxReaderCount);

    using (l.Read())
    {
        Assert.AreEqual(1, l.CurrentReaderCount);
        Assert.AreEqual(1, l.LocalReaderCount);
        using (l.Read(0))
        {
            Assert.AreEqual(2, l.CurrentReaderCount);
            Assert.AreEqual(2, l.LocalReaderCount);
        }
    }

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(2, l.MaxReaderCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(0, l.MaxReaderCount)

    Using l.Read()
        Assert.AreEqual(1, l.CurrentReaderCount)
        Assert.AreEqual(1, l.LocalReaderCount)
        Using l.Read(0)
            Assert.AreEqual(2, l.CurrentReaderCount)
            Assert.AreEqual(2, l.LocalReaderCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(2, l.MaxReaderCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : ReleaseRead Method

Glossary Item Box

Releases a read lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseRead()
C#
public void ReleaseRead()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : ReleaseWrite Method

Glossary Item Box

Releases a writer lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseWrite()
C#
public void ReleaseWrite()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : TryRead Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryRead( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryRead(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : TryWrite Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryWrite( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryWrite(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : Write Method

Glossary Item Box

Returns a read and write lock

Overload List

Overload | Description
Write(Int32) | Returns a read and write lock
Write() | Returns a read and write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class > Write Method : Write(Int32) Method

timeout

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write( _
   ByVal timeout As Integer _
) As WriteLock
C#
public WriteLock Write(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(0, l.MaxWriterCount);

    using (l.Write())
    {
        Assert.AreEqual(1, l.CurrentWriterCount);
        Assert.AreEqual(1, l.LocalWriterCount);
        using (l.Write(0))
        {
            Assert.AreEqual(2, l.CurrentWriterCount);
            Assert.AreEqual(2, l.LocalWriterCount);
        }
    }

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(2, l.MaxWriterCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(0, l.MaxWriterCount)

    Using l.Write()
        Assert.AreEqual(1, l.CurrentWriterCount)
        Assert.AreEqual(1, l.LocalWriterCount)
        Using l.Write(0)
            Assert.AreEqual(2, l.CurrentWriterCount)
            Assert.AreEqual(2, l.LocalWriterCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(2, l.MaxWriterCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write() As WriteLock
C#
public WriteLock Write()

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(0, l.MaxWriterCount);

    using (l.Write())
    {
        Assert.AreEqual(1, l.CurrentWriterCount);
        Assert.AreEqual(1, l.LocalWriterCount);
        using (l.Write(0))
        {
            Assert.AreEqual(2, l.CurrentWriterCount);
            Assert.AreEqual(2, l.LocalWriterCount);
        }
    }

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(2, l.MaxWriterCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(0, l.MaxWriterCount)

    Using l.Write()
        Assert.AreEqual(1, l.CurrentWriterCount)
        Assert.AreEqual(1, l.LocalWriterCount)
        Using l.Write(0)
            Assert.AreEqual(2, l.CurrentWriterCount)
            Assert.AreEqual(2, l.LocalWriterCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(2, l.MaxWriterCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DebugLocking Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking Class

Glossary Item Box

For a list of all members of this type, see DebugLocking members.

Public Properties

 | Name | Description
Public Property | CaptureStack | Capture the stack on every lock aquisition and release
Public Property | LocalReaderCount | Returns the total number of current readers for this thread
Public Property | LocalWriterCount | Returns the total number of current writers for this thread
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

See Also

Reference

DebugLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CaptureStack Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : CaptureStack Property

Glossary Item Box

Capture the stack on every lock aquisition and release

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CaptureStack As Boolean
C#
public bool CaptureStack {get;}

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking lck = new DebugLocking<IgnoreLocking>())
    Assert.IsFalse(lck.CaptureStack);
using (DebugLocking lck = new DebugLocking<IgnoreLocking>(true, 0, 0, false, 0))
    Assert.IsTrue(lck.CaptureStack);
VB.NET Copy Code
Using lck As DebugLocking = New DebugLocking(Of IgnoreLocking)()
    Assert.IsFalse(lck.CaptureStack)
End Using
Using lck As DebugLocking = New DebugLocking(Of IgnoreLocking)(True, 0, 0, False, 0)
    Assert.IsTrue(lck.CaptureStack)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Used By

Boolean DebugLocking.TryRead(Int32)
DebugLocking.ReleaseRead()
Boolean DebugLocking.TryWrite(Int32)
DebugLocking.ReleaseWrite()

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalReaderCount Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : LocalReaderCount Property

Glossary Item Box

Returns the total number of current readers for this thread

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LocalReaderCount As Integer
C#
public int LocalReaderCount {get;}

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(0, l.MaxReaderCount);

    using (l.Read())
    {
        Assert.AreEqual(1, l.CurrentReaderCount);
        Assert.AreEqual(1, l.LocalReaderCount);
        using (l.Read(0))
        {
            Assert.AreEqual(2, l.CurrentReaderCount);
            Assert.AreEqual(2, l.LocalReaderCount);
        }
    }

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(2, l.MaxReaderCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(0, l.MaxReaderCount)

    Using l.Read()
        Assert.AreEqual(1, l.CurrentReaderCount)
        Assert.AreEqual(1, l.LocalReaderCount)
        Using l.Read(0)
            Assert.AreEqual(2, l.CurrentReaderCount)
            Assert.AreEqual(2, l.LocalReaderCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(2, l.MaxReaderCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalWriterCount Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : LocalWriterCount Property

Glossary Item Box

Returns the total number of current writers for this thread

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LocalWriterCount As Integer
C#
public int LocalWriterCount {get;}

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(0, l.MaxWriterCount);

    using (l.Write())
    {
        Assert.AreEqual(1, l.CurrentWriterCount);
        Assert.AreEqual(1, l.LocalWriterCount);
        using (l.Write(0))
        {
            Assert.AreEqual(2, l.CurrentWriterCount);
            Assert.AreEqual(2, l.LocalWriterCount);
        }
    }

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(2, l.MaxWriterCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(0, l.MaxWriterCount)

    Using l.Write()
        Assert.AreEqual(1, l.CurrentWriterCount)
        Assert.AreEqual(1, l.LocalWriterCount)
        Using l.Write(0)
            Assert.AreEqual(2, l.CurrentWriterCount)
            Assert.AreEqual(2, l.LocalWriterCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(2, l.MaxWriterCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : WriteVersion Property

Glossary Item Box

Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WriteVersion As Integer
C#
public int WriteVersion {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
DebugLocking Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking Class

Glossary Item Box

For a list of all members of this type, see DebugLocking members.

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads
Public Field | MaxReaderCount | Returns the highest number of concurrent reads
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count)
Public Field | TotalReaderCount | Returns the total number of read locks acquired
Public Field | TotalWriterCount | Returns the total number of write locks acquired
Top

See Also

Reference

DebugLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CurrentReaderCount Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : CurrentReaderCount Field

Glossary Item Box

Returns the total number of current readers for all threads

Syntax

Visual Basic (Declaration)
Public CurrentReaderCount As Integer
C#
public int CurrentReaderCount

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(0, l.MaxReaderCount);

    using (l.Read())
    {
        Assert.AreEqual(1, l.CurrentReaderCount);
        Assert.AreEqual(1, l.LocalReaderCount);
        using (l.Read(0))
        {
            Assert.AreEqual(2, l.CurrentReaderCount);
            Assert.AreEqual(2, l.LocalReaderCount);
        }
    }

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(2, l.MaxReaderCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(0, l.MaxReaderCount)

    Using l.Read()
        Assert.AreEqual(1, l.CurrentReaderCount)
        Assert.AreEqual(1, l.LocalReaderCount)
        Using l.Read(0)
            Assert.AreEqual(2, l.CurrentReaderCount)
            Assert.AreEqual(2, l.LocalReaderCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(2, l.MaxReaderCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Used By

DebugLocking.Dispose()
Boolean DebugLocking.TryRead(Int32)
DebugLocking.ReleaseRead()
Boolean DebugLocking.TryWrite(Int32)

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CurrentWriterCount Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : CurrentWriterCount Field

Glossary Item Box

Returns the total number of current writers for all threads

Syntax

Visual Basic (Declaration)
Public CurrentWriterCount As Integer
C#
public int CurrentWriterCount

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(0, l.MaxWriterCount);

    using (l.Write())
    {
        Assert.AreEqual(1, l.CurrentWriterCount);
        Assert.AreEqual(1, l.LocalWriterCount);
        using (l.Write(0))
        {
            Assert.AreEqual(2, l.CurrentWriterCount);
            Assert.AreEqual(2, l.LocalWriterCount);
        }
    }

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(2, l.MaxWriterCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(0, l.MaxWriterCount)

    Using l.Write()
        Assert.AreEqual(1, l.CurrentWriterCount)
        Assert.AreEqual(1, l.LocalWriterCount)
        Using l.Write(0)
            Assert.AreEqual(2, l.CurrentWriterCount)
            Assert.AreEqual(2, l.LocalWriterCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(2, l.MaxWriterCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Used By

DebugLocking.Dispose()
Boolean DebugLocking.TryWrite(Int32)
DebugLocking.ReleaseWrite()

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxReaderCount Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : MaxReaderCount Field

Glossary Item Box

Returns the highest number of concurrent reads

Syntax

Visual Basic (Declaration)
Public MaxReaderCount As Integer
C#
public int MaxReaderCount

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(0, l.MaxReaderCount);

    using (l.Read())
    {
        Assert.AreEqual(1, l.CurrentReaderCount);
        Assert.AreEqual(1, l.LocalReaderCount);
        using (l.Read(0))
        {
            Assert.AreEqual(2, l.CurrentReaderCount);
            Assert.AreEqual(2, l.LocalReaderCount);
        }
    }

    Assert.AreEqual(0, l.CurrentReaderCount);
    Assert.AreEqual(0, l.LocalReaderCount);
    Assert.AreEqual(2, l.MaxReaderCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(0, l.MaxReaderCount)

    Using l.Read()
        Assert.AreEqual(1, l.CurrentReaderCount)
        Assert.AreEqual(1, l.LocalReaderCount)
        Using l.Read(0)
            Assert.AreEqual(2, l.CurrentReaderCount)
            Assert.AreEqual(2, l.LocalReaderCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentReaderCount)
    Assert.AreEqual(0, l.LocalReaderCount)
    Assert.AreEqual(2, l.MaxReaderCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Used By

Boolean DebugLocking.TryRead(Int32)

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxWriterCount Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : MaxWriterCount Field

Glossary Item Box

Returns the highest number of concurrent writes (aka max recursive count)

Syntax

Visual Basic (Declaration)
Public MaxWriterCount As Integer
C#
public int MaxWriterCount

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(0, l.MaxWriterCount);

    using (l.Write())
    {
        Assert.AreEqual(1, l.CurrentWriterCount);
        Assert.AreEqual(1, l.LocalWriterCount);
        using (l.Write(0))
        {
            Assert.AreEqual(2, l.CurrentWriterCount);
            Assert.AreEqual(2, l.LocalWriterCount);
        }
    }

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(2, l.MaxWriterCount);
}
VB.NET Copy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(0, l.MaxWriterCount)

    Using l.Write()
        Assert.AreEqual(1, l.CurrentWriterCount)
        Assert.AreEqual(1, l.LocalWriterCount)
        Using l.Write(0)
            Assert.AreEqual(2, l.CurrentWriterCount)
            Assert.AreEqual(2, l.LocalWriterCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(2, l.MaxWriterCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Used By

Boolean DebugLocking.TryWrite(Int32)

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TotalReaderCount Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : TotalReaderCount Field

Glossary Item Box

Returns the total number of read locks acquired

Syntax

Visual Basic (Declaration)
Public TotalReaderCount As Integer
C#
public int TotalReaderCount

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Used By

Boolean DebugLocking.TryRead(Int32)

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TotalWriterCount Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class : TotalWriterCount Field

Glossary Item Box

Returns the total number of write locks acquired

Syntax

Visual Basic (Declaration)
Public TotalWriterCount As Integer
C#
public int TotalWriterCount

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking Class
DebugLocking Members

Used By

Boolean DebugLocking.TryWrite(Int32)

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
DebugLocking<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking<T> Class

Glossary Item Box

Creates a tracking/assertion wrapper around an implementation of an ILockStrategy to verify lock state before and after acquisition and release of both reader and writer locks.

Syntax

Visual Basic (Declaration)
Public Class DebugLocking(Of T As {New, ILockStrategy})
   Inherits DebugLocking
   Implements ILockStrategy
C#
public class DebugLocking<T> : DebugLocking, ILockStrategy
where T: new(), ILockStrategy

Type Parameters

T

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking lck = new DebugLocking<IgnoreLocking>())
    Assert.IsFalse(lck.CaptureStack);
using (DebugLocking lck = new DebugLocking<IgnoreLocking>(true, 0, 0, false, 0))
    Assert.IsTrue(lck.CaptureStack);
VB.NET Copy Code
Using lck As DebugLocking = New DebugLocking(Of IgnoreLocking)()
    Assert.IsFalse(lck.CaptureStack)
End Using
Using lck As DebugLocking = New DebugLocking(Of IgnoreLocking)(True, 0, 0, False, 0)
    Assert.IsTrue(lck.CaptureStack)
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.DebugLocking
CSharpTest.Net.Synchronization.DebugLocking<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking<T> Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
DebugLocking<T> Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking<T> Class

Glossary Item Box

The following tables list the members exposed by DebugLocking<T>.

Public Constructors

 | Name | Description
Public Constructor | DebugLocking<T> Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | MaxReaderCount | Returns the highest number of concurrent reads (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count) (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | TotalReaderCount | Returns the total number of read locks acquired (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | TotalWriterCount | Returns the total number of write locks acquired (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Top

Public Properties

 | Name | Description
Public Property | CaptureStack | Capture the stack on every lock aquisition and release (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Property | LocalReaderCount | Returns the total number of current readers for this thread (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Property | LocalWriterCount | Returns the total number of current writers for this thread (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued. (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Top

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of this lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | ReleaseRead | Releases a read lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | ReleaseWrite | Releases a writer lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | Write | Overloaded. Returns a read and write lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Top

See Also

Reference

DebugLocking<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLocking<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking<T> Class : DebugLocking<T> Constructor

Glossary Item Box

Overload List

Overload | Description
DebugLocking<T> Constructor() | Constructs the lock tracking object
DebugLocking<T> Constructor(Boolean,Int32,Int32,Boolean,Int32) | Constructs the lock tracking object

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking<T> Class
DebugLocking<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLocking<T> Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking<T> Class > DebugLocking<T> Constructor : DebugLocking<T> Constructor()

Glossary Item Box

Constructs the lock tracking object

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public DebugLocking<T>()

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking lck = new DebugLocking<IgnoreLocking>())
    Assert.IsFalse(lck.CaptureStack);
using (DebugLocking lck = new DebugLocking<IgnoreLocking>(true, 0, 0, false, 0))
    Assert.IsTrue(lck.CaptureStack);
VB.NET Copy Code
Using lck As DebugLocking = New DebugLocking(Of IgnoreLocking)()
    Assert.IsFalse(lck.CaptureStack)
End Using
Using lck As DebugLocking = New DebugLocking(Of IgnoreLocking)(True, 0, 0, False, 0)
    Assert.IsTrue(lck.CaptureStack)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking<T> Class
DebugLocking<T> Members
Overload List

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugLocking<T> Constructor(Boolean,Int32,Int32,Boolean,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking<T> Class > DebugLocking<T> Constructor : DebugLocking<T> Constructor(Boolean,Int32,Int32,Boolean,Int32)

captureStack
limitTimeout
limitNestedReaders
concurrentReads
limitNestedWriters

Glossary Item Box

Constructs the lock tracking object

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal captureStack As Boolean, _
   ByVal limitTimeout As Integer, _
   ByVal limitNestedReaders As Integer, _
   ByVal concurrentReads As Boolean, _
   ByVal limitNestedWriters As Integer _
)
C#
public DebugLocking<T>(
   bool captureStack,
   int limitTimeout,
   int limitNestedReaders,
   bool concurrentReads,
   int limitNestedWriters
)

Parameters

captureStack
limitTimeout
limitNestedReaders
concurrentReads
limitNestedWriters

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C# Copy Code
using (DebugLocking lck = new DebugLocking<IgnoreLocking>())
    Assert.IsFalse(lck.CaptureStack);
using (DebugLocking lck = new DebugLocking<IgnoreLocking>(true, 0, 0, false, 0))
    Assert.IsTrue(lck.CaptureStack);
VB.NET Copy Code
Using lck As DebugLocking = New DebugLocking(Of IgnoreLocking)()
    Assert.IsFalse(lck.CaptureStack)
End Using
Using lck As DebugLocking = New DebugLocking(Of IgnoreLocking)(True, 0, 0, False, 0)
    Assert.IsTrue(lck.CaptureStack)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

DebugLocking<T> Class
DebugLocking<T> Members
Overload List

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExclusiveLocking Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ExclusiveLocking Class

Glossary Item Box

wraps the reader/writer lock around Monitor

Syntax

Visual Basic (Declaration)
Public Class ExclusiveLocking
   Implements ILockStrategy
C#
public class ExclusiveLocking : ILockStrategy

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.ExclusiveLocking

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ExclusiveLocking Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ExclusiveLocking Class

Glossary Item Box

The following tables list the members exposed by ExclusiveLocking.

Public Constructors

 | Name | Description
Public Constructor | ExclusiveLocking Constructor |
Top

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

Public Methods

 | Name | Description
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

ExclusiveLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExclusiveLocking Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class : ExclusiveLocking Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public ExclusiveLocking()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ExclusiveLocking Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ExclusiveLocking Class

Glossary Item Box

For a list of all members of this type, see ExclusiveLocking members.

Public Methods

 | Name | Description
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

ExclusiveLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class : Read Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Overload List

Overload | Description
Read() | Returns a reader lock that can be elevated to a write lock
Read(Int32) | Returns a reader lock that can be elevated to a write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class > Read Method : Read() Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read() As ReadLock
C#
public ReadLock Read()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class > Read Method : Read(Int32) Method

timeout

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read( _
   ByVal timeout As Integer _
) As ReadLock
C#
public ReadLock Read(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class : ReleaseRead Method

Glossary Item Box

Releases a read lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseRead()
C#
public void ReleaseRead()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class : ReleaseWrite Method

Glossary Item Box

Releases a writer lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseWrite()
C#
public void ReleaseWrite()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class : TryRead Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryRead( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryRead(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class : TryWrite Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryWrite( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryWrite(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class : Write Method

Glossary Item Box

Returns a read and write lock

Overload List

Overload | Description
Write() | Returns a read and write lock
Write(Int32) | Returns a read and write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write() As WriteLock
C#
public WriteLock Write()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class > Write Method : Write(Int32) Method

timeout

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write( _
   ByVal timeout As Integer _
) As WriteLock
C#
public WriteLock Write(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ExclusiveLocking Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ExclusiveLocking Class

Glossary Item Box

For a list of all members of this type, see ExclusiveLocking members.

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

See Also

Reference

ExclusiveLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ExclusiveLocking Class : WriteVersion Property

Glossary Item Box

Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WriteVersion As Integer
C#
public int WriteVersion {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExclusiveLocking Class
ExclusiveLocking Members

Source Code

Library/Synchronization/ExclusiveLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnoreLockFactory Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : IgnoreLockFactory Class

Glossary Item Box

Singleton instance of ignore locking

Syntax

Visual Basic (Declaration)
Public Class IgnoreLockFactory
   Implements CSharpTest.Net.Interfaces.IFactory(Of ILockStrategy), ILockFactory
C#
public class IgnoreLockFactory : CSharpTest.Net.Interfaces.IFactory<ILockStrategy>, ILockFactory

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.IgnoreLockFactory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLockFactory Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IgnoreLockFactory Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : IgnoreLockFactory Class

Glossary Item Box

The following tables list the members exposed by IgnoreLockFactory.

Public Constructors

 | Name | Description
Public Constructor | IgnoreLockFactory Constructor |
Top

Public Methods

 | Name | Description
Public Method | Create | Returns the IgnoreLocking.Instance singleton
Top

See Also

Reference

IgnoreLockFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnoreLockFactory Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLockFactory Class : IgnoreLockFactory Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public IgnoreLockFactory()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLockFactory Class
IgnoreLockFactory Members

Used By

BPlusTree TestFileSerialized.BTreeFactory.Create()
BPlusTree TestSimpleDictionary.BTreeFactory.Create()


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IgnoreLockFactory Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : IgnoreLockFactory Class

Glossary Item Box

For a list of all members of this type, see IgnoreLockFactory members.

Public Methods

 | Name | Description
Public Method | Create | Returns the IgnoreLocking.Instance singleton
Top

See Also

Reference

IgnoreLockFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLockFactory Class : Create Method

Glossary Item Box

Returns the IgnoreLocking.Instance singleton

Syntax

Visual Basic (Declaration)
Public Function Create() As ILockStrategy
C#
public ILockStrategy Create()

Example

Library/Library.Test/LockingTests/TestIgnoreLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    Assert.AreEqual(0, l.WriteVersion);
    using(l.Write())
        Assert.AreEqual(0, l.WriteVersion);
    Assert.AreEqual(0, l.WriteVersion);
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Assert.AreEqual(0, l.WriteVersion)
    Using l.Write()
        Assert.AreEqual(0, l.WriteVersion)
    End Using
    Assert.AreEqual(0, l.WriteVersion)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLockFactory Class
IgnoreLockFactory Members
ILockStrategy

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnoreLocking Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : IgnoreLocking Class

Glossary Item Box

wraps the reader/writer lock around Monitor

Syntax

Visual Basic (Declaration)
Public Class IgnoreLocking
   Implements ILockStrategy
C#
public class IgnoreLocking : ILockStrategy

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedList<int> list = new SynchronizedList<int>(new List<int>(), new IgnoreLocking());
list.Insert(0, 1);
Assert.AreEqual(1, list.Count);
list.ReplaceStorage(new List<int>());
Assert.AreEqual(0, list.Count);
VB.NET Copy Code
Dim list As New SynchronizedList(Of Integer)(New List(Of Integer)(), New IgnoreLocking())
list.Insert(0, 1)
Assert.AreEqual(1, list.Count)
list.ReplaceStorage(New List(Of Integer)())
Assert.AreEqual(0, list.Count)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.IgnoreLocking

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IgnoreLocking Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : IgnoreLocking Class

Glossary Item Box

The following tables list the members exposed by IgnoreLocking.

Public Constructors

 | Name | Description
Public Constructor | IgnoreLocking Constructor |
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Instance | Singleton instance of ignore locking
Top

Public Properties

 | Name | Description
Public Property | WriteVersion | Returns Zero.
Top

Public Methods

 | Name | Description
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

IgnoreLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnoreLocking Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : IgnoreLocking Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public IgnoreLocking()

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
SynchronizedList<int> list = new SynchronizedList<int>(new List<int>(), new IgnoreLocking());
list.Insert(0, 1);
Assert.AreEqual(1, list.Count);
list.ReplaceStorage(new List<int>());
Assert.AreEqual(0, list.Count);
VB.NET Copy Code
Dim list As New SynchronizedList(Of Integer)(New List(Of Integer)(), New IgnoreLocking())
list.Insert(0, 1)
Assert.AreEqual(1, list.Count)
list.ReplaceStorage(New List(Of Integer)())
Assert.AreEqual(0, list.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IgnoreLocking Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : IgnoreLocking Class

Glossary Item Box

For a list of all members of this type, see IgnoreLocking members.

Public Methods

 | Name | Description
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

IgnoreLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : Read Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Overload List

Overload | Description
Read() | Returns a reader lock that can be elevated to a write lock
Read(Int32) | Returns a reader lock that can be elevated to a write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class > Read Method : Read() Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read() As ReadLock
C#
public ReadLock Read()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class > Read Method : Read(Int32) Method

timeout

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read( _
   ByVal timeout As Integer _
) As ReadLock
C#
public ReadLock Read(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : ReleaseRead Method

Glossary Item Box

Releases a read lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseRead()
C#
public void ReleaseRead()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : ReleaseWrite Method

Glossary Item Box

Releases a writer lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseWrite()
C#
public void ReleaseWrite()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : TryRead Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryRead( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryRead(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : TryWrite Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryWrite( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryWrite(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : Write Method

Glossary Item Box

Returns a read and write lock

Overload List

Overload | Description
Write() | Returns a read and write lock
Write(Int32) | Returns a read and write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write() As WriteLock
C#
public WriteLock Write()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class > Write Method : Write(Int32) Method

timeout

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write( _
   ByVal timeout As Integer _
) As WriteLock
C#
public WriteLock Write(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IgnoreLocking Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : IgnoreLocking Class

Glossary Item Box

For a list of all members of this type, see IgnoreLocking members.

Public Properties

 | Name | Description
Public Property | WriteVersion | Returns Zero.
Top

See Also

Reference

IgnoreLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : WriteVersion Property

Glossary Item Box

Returns Zero.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WriteVersion As Integer
C#
public int WriteVersion {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
IgnoreLocking Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : IgnoreLocking Class

Glossary Item Box

For a list of all members of this type, see IgnoreLocking members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | Instance | Singleton instance of ignore locking
Top

See Also

Reference

IgnoreLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Instance Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > IgnoreLocking Class : Instance Field

Glossary Item Box

Singleton instance of ignore locking

Syntax

Visual Basic (Declaration)
Public Shared Instance As IgnoreLocking
C#
public static IgnoreLocking Instance

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IgnoreLocking Class
IgnoreLocking Members

Used By

ILockStrategy IgnoreLockFactory.Create()

Source Code

Library/Synchronization/IgnoreLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LockCounterFactory Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockCounterFactory Class

Glossary Item Box

Creates a debugging lock factory that can track locks allocated and all acquired/released read/write locks

Syntax

Visual Basic (Declaration)
Public Class LockCounterFactory
   Implements CSharpTest.Net.Interfaces.IFactory(Of ILockStrategy), ILockFactory
C#
public class LockCounterFactory : CSharpTest.Net.Interfaces.IFactory<ILockStrategy>, ILockFactory

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.LockCounterFactory
CSharpTest.Net.Synchronization.DebugLockFactory
CSharpTest.Net.Synchronization.LockCounterFactory<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LockCounterFactory Class Members
See Also Fields Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockCounterFactory Class

Glossary Item Box

The following tables list the members exposed by LockCounterFactory.

Public Constructors

 | Name | Description
Public Constructor | LockCounterFactory Constructor | Constructs the lock tracking factory
Top

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads
Public Field | MaxReaderCount | Returns the highest number of concurrent reads
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count)
Public Field | TotalReaderCount | Returns the total number of read locks acquired
Public Field | TotalWriterCount | Returns the total number of write locks acquired
Top

Public Methods

 | Name | Description
Public Method | Create | Constructs the lock wrapped in a DebugLocking instance
Public Method | GlobalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by any thread
Top

See Also

Reference

LockCounterFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LockCounterFactory Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : LockCounterFactory Constructor

factory

Glossary Item Box

Constructs the lock tracking factory

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal factory As ILockFactory _
)
C#
public LockCounterFactory(
   ILockFactory factory
)

Parameters

factory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LockCounterFactory Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockCounterFactory Class

Glossary Item Box

For a list of all members of this type, see LockCounterFactory members.

Public Methods

 | Name | Description
Public Method | Create | Constructs the lock wrapped in a DebugLocking instance
Public Method | GlobalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by any thread
Top

See Also

Reference

LockCounterFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : Create Method

Glossary Item Box

Constructs the lock wrapped in a DebugLocking instance

Syntax

Visual Basic (Declaration)
Public Overridable Function Create() As ILockStrategy
C#
public virtual ILockStrategy Create()

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members
ILockStrategy

Source Code

Library/Synchronization/LockCounterFactory.cs

Used By

ILockStrategy DebugLockFactory.Create()


%%PageItemTitle%%

[image]
CSharpTest.Net
GlobalAssertNoLocks Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : GlobalAssertNoLocks Method

Glossary Item Box

Asserts that none of the locks handed out are currently locked for read or write by any thread

Syntax

Visual Basic (Declaration)
Public Sub GlobalAssertNoLocks()
C#
public void GlobalAssertNoLocks()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
LockCounterFactory Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockCounterFactory Class

Glossary Item Box

For a list of all members of this type, see LockCounterFactory members.

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads
Public Field | MaxReaderCount | Returns the highest number of concurrent reads
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count)
Public Field | TotalReaderCount | Returns the total number of read locks acquired
Public Field | TotalWriterCount | Returns the total number of write locks acquired
Top

See Also

Reference

LockCounterFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CurrentReaderCount Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : CurrentReaderCount Field

Glossary Item Box

Returns the total number of current readers for all threads

Syntax

Visual Basic (Declaration)
Public CurrentReaderCount As Integer
C#
public int CurrentReaderCount

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members

Used By

LockCounterFactory.GlobalAssertNoLocks()

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CurrentWriterCount Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : CurrentWriterCount Field

Glossary Item Box

Returns the total number of current writers for all threads

Syntax

Visual Basic (Declaration)
Public CurrentWriterCount As Integer
C#
public int CurrentWriterCount

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members

Used By

LockCounterFactory.GlobalAssertNoLocks()

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxReaderCount Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : MaxReaderCount Field

Glossary Item Box

Returns the highest number of concurrent reads

Syntax

Visual Basic (Declaration)
Public MaxReaderCount As Integer
C#
public int MaxReaderCount

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MaxWriterCount Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : MaxWriterCount Field

Glossary Item Box

Returns the highest number of concurrent writes (aka max recursive count)

Syntax

Visual Basic (Declaration)
Public MaxWriterCount As Integer
C#
public int MaxWriterCount

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TotalReaderCount Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : TotalReaderCount Field

Glossary Item Box

Returns the total number of read locks acquired

Syntax

Visual Basic (Declaration)
Public TotalReaderCount As Integer
C#
public int TotalReaderCount

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TotalWriterCount Field
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory Class : TotalWriterCount Field

Glossary Item Box

Returns the total number of write locks acquired

Syntax

Visual Basic (Declaration)
Public TotalWriterCount As Integer
C#
public int TotalWriterCount

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory Class
LockCounterFactory Members

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
LockCounterFactory<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockCounterFactory<T> Class

Glossary Item Box

Creates a debugging lock factory that can track locks allocated and all acquired/released read/write locks

Syntax

Visual Basic (Declaration)
Public Class LockCounterFactory(Of T As {New, ILockStrategy})
   Inherits LockCounterFactory
   Implements CSharpTest.Net.Interfaces.IFactory(Of ILockStrategy), ILockFactory
C#
public class LockCounterFactory<T> : LockCounterFactory, CSharpTest.Net.Interfaces.IFactory<ILockStrategy>, ILockFactory
where T: new(), ILockStrategy

Type Parameters

T

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.LockCounterFactory
CSharpTest.Net.Synchronization.LockCounterFactory<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory<T> Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LockCounterFactory<T> Class Members
See Also Fields Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockCounterFactory<T> Class

Glossary Item Box

The following tables list the members exposed by LockCounterFactory<T>.

Public Constructors

 | Name | Description
Public Constructor | LockCounterFactory<T> Constructor | Constructs the lock tracking factory
Top

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxReaderCount | Returns the highest number of concurrent reads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count) (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalReaderCount | Returns the total number of read locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalWriterCount | Returns the total number of write locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Top

Public Methods

 | Name | Description
Public Method | Create | Constructs the lock wrapped in a DebugLocking instance (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Method | GlobalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by any thread (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Top

See Also

Reference

LockCounterFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LockCounterFactory<T> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockCounterFactory<T> Class : LockCounterFactory<T> Constructor

Glossary Item Box

Constructs the lock tracking factory

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public LockCounterFactory<T>()

Example

Library/Library.Test/TestSynchronizedCollections.cs

C# Copy Code
LockCounterFactory<SimpleReadWriteLocking> factory = new LockCounterFactory<SimpleReadWriteLocking>();
ILockStrategy lck = factory.Create();
SynchronizedList<int> list = new SynchronizedList<int>(lck);

Assert.IsTrue(ReferenceEquals(lck, list.Lock));
list.Add(42);
Assert.AreEqual(1, factory.TotalWriterCount);
Assert.AreEqual(0, factory.TotalReaderCount);

list[0] = 51;
Assert.AreEqual(2, factory.TotalWriterCount);

list.Insert(1, 52);
Assert.AreEqual(3, factory.TotalWriterCount);

list.RemoveAt(1);
Assert.AreEqual(4, factory.TotalWriterCount);

list.Remove(-1);
Assert.AreEqual(5, factory.TotalWriterCount);

Assert.AreEqual(51, list[0]);
Assert.AreEqual(1, factory.TotalReaderCount);

foreach (int i in list)
    GC.KeepAlive(i);
Assert.AreEqual(2, factory.TotalReaderCount);

Assert.AreEqual(0, list.IndexOf(51));
Assert.AreEqual(3, factory.TotalReaderCount);

Assert.AreEqual(1, list.Count);
Assert.AreEqual(4, factory.TotalReaderCount);
VB.NET Copy Code
Dim factory As New LockCounterFactory(Of SimpleReadWriteLocking)()
Dim lck As ILockStrategy = factory.Create()
Dim list As New SynchronizedList(Of Integer)(lck)

Assert.IsTrue(ReferenceEquals(lck, list.Lock))
list.Add(42)
Assert.AreEqual(1, factory.TotalWriterCount)
Assert.AreEqual(0, factory.TotalReaderCount)

list(0) = 51
Assert.AreEqual(2, factory.TotalWriterCount)

list.Insert(1, 52)
Assert.AreEqual(3, factory.TotalWriterCount)

list.RemoveAt(1)
Assert.AreEqual(4, factory.TotalWriterCount)

list.Remove(-1)
Assert.AreEqual(5, factory.TotalWriterCount)

Assert.AreEqual(51, list(0))
Assert.AreEqual(1, factory.TotalReaderCount)

For Each i As Integer In list
    GC.KeepAlive(i)
Next
Assert.AreEqual(2, factory.TotalReaderCount)

Assert.AreEqual(0, list.IndexOf(51))
Assert.AreEqual(3, factory.TotalReaderCount)

Assert.AreEqual(1, list.Count)
Assert.AreEqual(4, factory.TotalReaderCount)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockCounterFactory<T> Class
LockCounterFactory<T> Members

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
LockFactory<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockFactory<T> Class

Glossary Item Box

A generic implementation that constructs a lock by type

Syntax

Visual Basic (Declaration)
Public Class LockFactory(Of T As {New, ILockStrategy})
   Implements CSharpTest.Net.Interfaces.IFactory(Of ILockStrategy), ILockFactory
C#
public class LockFactory<T> : CSharpTest.Net.Interfaces.IFactory<ILockStrategy>, ILockFactory
where T: new(), ILockStrategy

Type Parameters

T

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.LockFactory<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockFactory<T> Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockFactory.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LockFactory<T> Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockFactory<T> Class

Glossary Item Box

The following tables list the members exposed by LockFactory<T>.

Public Constructors

 | Name | Description
Public Constructor | LockFactory<T> Constructor |
Top

Public Methods

 | Name | Description
Public Method | Create | Returns a new lock of type T
Top

See Also

Reference

LockFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LockFactory<T> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockFactory<T> Class : LockFactory<T> Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public LockFactory<T>()

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockFactory<T> Class
LockFactory<T> Members

Used By

Int32 BPlusTree.RecoverFile(BPlusTree.Options)
ThreadedBTreeTest.TestConcurrentCreateReadUpdateDelete8000()

Source Code

Library/Synchronization/LockFactory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LockFactory<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockFactory<T> Class

Glossary Item Box

For a list of all members of this type, see LockFactory<T> members.

Public Methods

 | Name | Description
Public Method | Create | Returns a new lock of type T
Top

See Also

Reference

LockFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Create Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > LockFactory<T> Class : Create Method

Glossary Item Box

Returns a new lock of type T

Syntax

Visual Basic (Declaration)
Public Function Create() As ILockStrategy
C#
public ILockStrategy Create()

Example

Library/Library.Test/LockingTests/TestReaderWriterLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (l.Read())
    Assert.IsFalse(l.TryWrite(10));
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using l.Read()
        Assert.IsFalse(l.TryWrite(10))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LockFactory<T> Class
LockFactory<T> Members
ILockStrategy

Source Code

Library/Synchronization/LockFactory.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexLock Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : MutexLock Class

Glossary Item Box

Creates a lock on a mutex that can be released via the Dispose() method, for use in a using statement

Syntax

Visual Basic (Declaration)
Public Class MutexLock
C#
public class MutexLock

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (Mutex mtx = new Mutex())
{
    Thread t = new Thread(
        delegate()
        { GC.KeepAlive(new MutexLock(1, mtx)); }
        );
    t.Start();
    t.Join();

    //So the previous thread abandoned the mutex...
    using (MutexLock lck = new MutexLock(mtx))
    {
        Assert.IsTrue(lck.WasAbandonded);
        Assert.AreEqual(mtx, lck.MutexHandle);
    }
}
VB.NET Copy Code
Using mtx As New Mutex()
    Dim t As New Thread(Function() Do
        GC.KeepAlive(New MutexLock(1, mtx))
    End Function)
    t.Start()
    t.Join()

    'So the previous thread abandoned the mutex...
    Using lck As New MutexLock(mtx)
        Assert.IsTrue(lck.WasAbandonded)
        Assert.AreEqual(mtx, lck.MutexHandle)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.MutexLock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
MutexLock Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : MutexLock Class

Glossary Item Box

The following tables list the members exposed by MutexLock.

Public Constructors

 | Name | Description
Public Constructor | MutexLock Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | IsLocked | Returns true if this object holds a lock on the mutex
Public Property | MutexHandle | Returns the mutex
Public Property | WasAbandonded | Returns true if the lock was obtained from an abandoned mutex
Public Property | WasNew | Returns true if this object created a new named mutex
Top

Public Methods

 | Name | Description
Public Method | Dispose | Releases the lock on the mutex, and if created by this closes the mutex
Top

See Also

Reference

MutexLock Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexLock Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class : MutexLock Constructor

Glossary Item Box

Overload List

Overload | Description
MutexLock Constructor(String) | Creates and locks the named mutex
MutexLock Constructor(String,Object[]) | Creates and locks the named mutex
MutexLock Constructor(Int32,String,Object[]) | Creates and locks the named mutex or throws TimeoutException
MutexLock Constructor(Int32,String) | Creates and locks the named mutex or throws TimeoutException
MutexLock Constructor(Mutex) | Locks the provided mutex
MutexLock Constructor(Int32,Mutex) | Locks the provided mutex or throws TimeoutException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexLock Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class > MutexLock Constructor : MutexLock Constructor(String)

name

Glossary Item Box

Creates and locks the named mutex

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal name As String _
)
C#
public MutexLock(
   string name
)

Parameters

name

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (new MutexLock("MutexLock.TestMutexLockByName"))
{
    Assert.IsFalse(CanLock(new Mutex(false, "MutexLock.TestMutexLockByName")));
}
VB.NET Copy Code
Using New MutexLock("MutexLock.TestMutexLockByName")
    Assert.IsFalse(CanLock(New Mutex(False, "MutexLock.TestMutexLockByName")))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members
Overload List

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexLock Constructor(String,Object[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class > MutexLock Constructor : MutexLock Constructor(String,Object[])

format
args

Glossary Item Box

Creates and locks the named mutex

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public MutexLock(
   string format,
   params object[] args
)

Parameters

format
args

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (new MutexLock("MutexLock.{0}", "TestMutexLockByFormattedName"))
{
    Assert.IsFalse(CanLock(new Mutex(false, "MutexLock.TestMutexLockByFormattedName")));
}
VB.NET Copy Code
Using New MutexLock("MutexLock.{0}", "TestMutexLockByFormattedName")
    Assert.IsFalse(CanLock(New Mutex(False, "MutexLock.TestMutexLockByFormattedName")))
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members
Overload List

Used By

IpcChannelRegistrar.RegisterInstance(String,String,String)
IpcChannelRegistrar.UnregisterInstance(String,String)
IEnumerable IpcChannelRegistrar.GetRegisteredInstances(String,IEnumerable)

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexLock Constructor(Int32,String,Object[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class > MutexLock Constructor : MutexLock Constructor(Int32,String,Object[])

timeout
format
args

Glossary Item Box

Creates and locks the named mutex or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal timeout As Integer, _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public MutexLock(
   int timeout,
   string format,
   params object[] args
)

Parameters

timeout
format
args

Exceptions

Exception | Description
System.TimeoutException | Raises System.TimeoutException if mutex was not obtained.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members
Overload List

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexLock Constructor(Int32,String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class > MutexLock Constructor : MutexLock Constructor(Int32,String)

timeout
name

Glossary Item Box

Creates and locks the named mutex or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal timeout As Integer, _
   ByVal name As String _
)
C#
public MutexLock(
   int timeout,
   string name
)

Parameters

timeout
name

Exceptions

Exception | Description
System.TimeoutException | Raises System.TimeoutException if mutex was not obtained.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members
Overload List

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexLock Constructor(Mutex)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class > MutexLock Constructor : MutexLock Constructor(Mutex)

mutex

Glossary Item Box

Locks the provided mutex

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal mutex As Mutex _
)
C#
public MutexLock(
   Mutex mutex
)

Parameters

mutex

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (Mutex mtx = new Mutex())
{
    Thread t = new Thread(
        delegate()
        { GC.KeepAlive(new MutexLock(1, mtx)); }
        );
    t.Start();
    t.Join();

    //So the previous thread abandoned the mutex...
    using (MutexLock lck = new MutexLock(mtx))
    {
        Assert.IsTrue(lck.WasAbandonded);
        Assert.AreEqual(mtx, lck.MutexHandle);
    }
}
VB.NET Copy Code
Using mtx As New Mutex()
    Dim t As New Thread(Function() Do
        GC.KeepAlive(New MutexLock(1, mtx))
    End Function)
    t.Start()
    t.Join()

    'So the previous thread abandoned the mutex...
    Using lck As New MutexLock(mtx)
        Assert.IsTrue(lck.WasAbandonded)
        Assert.AreEqual(mtx, lck.MutexHandle)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members
Overload List

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexLock Constructor(Int32,Mutex)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class > MutexLock Constructor : MutexLock Constructor(Int32,Mutex)

timeout
mutex

Glossary Item Box

Locks the provided mutex or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal timeout As Integer, _
   ByVal mutex As Mutex _
)
C#
public MutexLock(
   int timeout,
   Mutex mutex
)

Parameters

timeout
mutex

Exceptions

Exception | Description
System.TimeoutException | Raises System.TimeoutException if mutex was not obtained.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members
Overload List

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
MutexLock Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : MutexLock Class

Glossary Item Box

For a list of all members of this type, see MutexLock members.

Public Methods

 | Name | Description
Public Method | Dispose | Releases the lock on the mutex, and if created by this closes the mutex
Top

See Also

Reference

MutexLock Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class : Dispose Method

Glossary Item Box

Releases the lock on the mutex, and if created by this closes the mutex

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (MutexLock lck = new MutexLock(Guid.NewGuid().ToString()))
{
    Assert.IsTrue(lck.IsLocked);
    lck.Dispose();
    Assert.IsFalse(lck.IsLocked);
}
VB.NET Copy Code
Using lck As New MutexLock(Guid.NewGuid().ToString())
    Assert.IsTrue(lck.IsLocked)
    lck.Dispose()
    Assert.IsFalse(lck.IsLocked)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
MutexLock Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : MutexLock Class

Glossary Item Box

For a list of all members of this type, see MutexLock members.

Public Properties

 | Name | Description
Public Property | IsLocked | Returns true if this object holds a lock on the mutex
Public Property | MutexHandle | Returns the mutex
Public Property | WasAbandonded | Returns true if the lock was obtained from an abandoned mutex
Public Property | WasNew | Returns true if this object created a new named mutex
Top

See Also

Reference

MutexLock Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsLocked Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class : IsLocked Property

Glossary Item Box

Returns true if this object holds a lock on the mutex

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsLocked As Boolean
C#
public bool IsLocked {get;}

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (MutexLock lck = new MutexLock(Guid.NewGuid().ToString()))
{
    Assert.IsTrue(lck.IsLocked);
    lck.Dispose();
    Assert.IsFalse(lck.IsLocked);
}
VB.NET Copy Code
Using lck As New MutexLock(Guid.NewGuid().ToString())
    Assert.IsTrue(lck.IsLocked)
    lck.Dispose()
    Assert.IsFalse(lck.IsLocked)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MutexHandle Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class : MutexHandle Property

Glossary Item Box

Returns the mutex

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MutexHandle As Mutex
C#
public Mutex MutexHandle {get;}

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (Mutex mtx = new Mutex())
{
    Thread t = new Thread(
        delegate()
        { GC.KeepAlive(new MutexLock(1, mtx)); }
        );
    t.Start();
    t.Join();

    //So the previous thread abandoned the mutex...
    using (MutexLock lck = new MutexLock(mtx))
    {
        Assert.IsTrue(lck.WasAbandonded);
        Assert.AreEqual(mtx, lck.MutexHandle);
    }
}
VB.NET Copy Code
Using mtx As New Mutex()
    Dim t As New Thread(Function() Do
        GC.KeepAlive(New MutexLock(1, mtx))
    End Function)
    t.Start()
    t.Join()

    'So the previous thread abandoned the mutex...
    Using lck As New MutexLock(mtx)
        Assert.IsTrue(lck.WasAbandonded)
        Assert.AreEqual(mtx, lck.MutexHandle)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WasAbandonded Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class : WasAbandonded Property

Glossary Item Box

Returns true if the lock was obtained from an abandoned mutex

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WasAbandonded As Boolean
C#
public bool WasAbandonded {get;}

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (Mutex mtx = new Mutex())
{
    Thread t = new Thread(
        delegate()
        { GC.KeepAlive(new MutexLock(1, mtx)); }
        );
    t.Start();
    t.Join();

    //So the previous thread abandoned the mutex...
    using (MutexLock lck = new MutexLock(mtx))
    {
        Assert.IsTrue(lck.WasAbandonded);
        Assert.AreEqual(mtx, lck.MutexHandle);
    }
}
VB.NET Copy Code
Using mtx As New Mutex()
    Dim t As New Thread(Function() Do
        GC.KeepAlive(New MutexLock(1, mtx))
    End Function)
    t.Start()
    t.Join()

    'So the previous thread abandoned the mutex...
    Using lck As New MutexLock(mtx)
        Assert.IsTrue(lck.WasAbandonded)
        Assert.AreEqual(mtx, lck.MutexHandle)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WasNew Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > MutexLock Class : WasNew Property

Glossary Item Box

Returns true if this object created a new named mutex

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WasNew As Boolean
C#
public bool WasNew {get;}

Example

Library/Library.Test/LockingTests/TestMutexLock.cs

C# Copy Code
using (MutexLock lck = new MutexLock(Guid.NewGuid().ToString()))
    Assert.IsTrue(lck.WasNew);
VB.NET Copy Code
Using lck As New MutexLock(Guid.NewGuid().ToString())
    Assert.IsTrue(lck.WasNew)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

MutexLock Class
MutexLock Members

Source Code

Library/Synchronization/MutexLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReaderWriterLocking Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReaderWriterLocking Class

Glossary Item Box

wraps the System.Threading.ReaderWriterLock lock, does not support read->write upgrades

Syntax

Visual Basic (Declaration)
Public Class ReaderWriterLocking
   Implements ILockStrategy
C#
public class ReaderWriterLocking : ILockStrategy

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.ReaderWriterLocking

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ReaderWriterLocking Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReaderWriterLocking Class

Glossary Item Box

The following tables list the members exposed by ReaderWriterLocking.

Public Constructors

 | Name | Description
Public Constructor | ReaderWriterLocking Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

Public Methods

 | Name | Description
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

ReaderWriterLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReaderWriterLocking Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class : ReaderWriterLocking Constructor

Glossary Item Box

Overload List

Overload | Description
ReaderWriterLocking Constructor() | wraps the reader/writer lock
ReaderWriterLocking Constructor(ReaderWriterLock) | wraps the reader/writer lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReaderWriterLocking Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class > ReaderWriterLocking Constructor : ReaderWriterLocking Constructor()

Glossary Item Box

wraps the reader/writer lock

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public ReaderWriterLocking()

Example

BPlusTree/BPlusTree.Test/ThreadedBTreeTest.cs

C# Copy Code
BPlusTree<KeyInfo, DataValue>.OptionsV2 options = new BPlusTree<KeyInfo, DataValue>.OptionsV2(
    new KeyInfoSerializer(), new DataValueSerializer(), new KeyInfoComparer());

const int keysize = 16 + 4;
const int valuesize = keysize + 256 + 44;

options.CalcBTreeOrder(keysize, valuesize);
options.FileName = TempFile.TempPath;
options.CreateFile = CreatePolicy.Always;
options.FileBlockSize = 8192;
options.StorageType = StorageType.Disk;

options.CacheKeepAliveTimeout = 10000;
options.CacheKeepAliveMinimumHistory = 0;
options.CacheKeepAliveMaximumHistory = 200;

options.CallLevelLock = new ReaderWriterLocking();
options.LockingFactory = new LockFactory<SimpleReadWriteLocking>();
options.LockTimeout = 10000;

using(BPlusTree<KeyInfo, DataValue> dictionary = new BPlusTree<KeyInfo, DataValue>(options))
using(WorkQueue work = new WorkQueue(Environment.ProcessorCount))
{
    Exception lastError = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { lastError = e.GetException(); };

    for (int i = 0; i < Environment.ProcessorCount; i++)
        work.Enqueue(new ThreadedTest(dictionary, 1000).Run);

    Assert.IsTrue(work.Complete(true, 60000));
    Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError);
}
VB.NET Copy Code
Dim options As New BPlusTree(Of KeyInfo, DataValue).OptionsV2(New KeyInfoSerializer(), New DataValueSerializer(), New KeyInfoComparer())

Const  keysize As Integer = 16 + 4
Const  valuesize As Integer = keysize + 256 + 44

options.CalcBTreeOrder(keysize, valuesize)
options.FileName = TempFile.TempPath
options.CreateFile = CreatePolicy.Always
options.FileBlockSize = 8192
options.StorageType = StorageType.Disk

options.CacheKeepAliveTimeout = 10000
options.CacheKeepAliveMinimumHistory = 0
options.CacheKeepAliveMaximumHistory = 200

options.CallLevelLock = New ReaderWriterLocking()
options.LockingFactory = New LockFactory(Of SimpleReadWriteLocking)()
options.LockTimeout = 10000

Using dictionary As New BPlusTree(Of KeyInfo, DataValue)(options)
    Using work As New WorkQueue(Environment.ProcessorCount)
        Dim lastError As Exception = Nothing
        work.OnError += Function(o As Object, e As ErrorEventArgs) Do
            lastError = e.GetException()
        End Function

        Dim i As Integer = 0
        While i < Environment.ProcessorCount
            work.Enqueue(New ThreadedTest(dictionary, 1000).Run)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Assert.IsTrue(work.Complete(True, 60000))
        Assert.IsNull(lastError, "Exception raised in worker: {0}", lastError)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members
Overload List

Used By

ThreadedBTreeTest.TestCallLevelLocking()
ThreadedBTreeTest.TestConcurrentCreateReadUpdateDelete8000()

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReaderWriterLocking Constructor(ReaderWriterLock)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class > ReaderWriterLocking Constructor : ReaderWriterLocking Constructor(ReaderWriterLock)

lck

Glossary Item Box

wraps the reader/writer lock

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal lck As ReaderWriterLock _
)
C#
public ReaderWriterLocking(
   ReaderWriterLock lck
)

Parameters

lck

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members
Overload List

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ReaderWriterLocking Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReaderWriterLocking Class

Glossary Item Box

For a list of all members of this type, see ReaderWriterLocking members.

Public Methods

 | Name | Description
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

ReaderWriterLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class : Read Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Overload List

Overload | Description
Read() | Returns a reader lock that can be elevated to a write lock
Read(Int32) | Returns a reader lock that can be elevated to a write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class > Read Method : Read() Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read() As ReadLock
C#
public ReadLock Read()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class > Read Method : Read(Int32) Method

timeout

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read( _
   ByVal timeout As Integer _
) As ReadLock
C#
public ReadLock Read(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class : ReleaseRead Method

Glossary Item Box

Releases a read lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseRead()
C#
public void ReleaseRead()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class : ReleaseWrite Method

Glossary Item Box

Releases a writer lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseWrite()
C#
public void ReleaseWrite()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class : TryRead Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryRead( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryRead(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class : TryWrite Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryWrite( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryWrite(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class : Write Method

Glossary Item Box

Returns a read and write lock

Overload List

Overload | Description
Write() | Returns a read and write lock
Write(Int32) | Returns a read and write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write() As WriteLock
C#
public WriteLock Write()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class > Write Method : Write(Int32) Method

timeout

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write( _
   ByVal timeout As Integer _
) As WriteLock
C#
public WriteLock Write(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ReaderWriterLocking Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReaderWriterLocking Class

Glossary Item Box

For a list of all members of this type, see ReaderWriterLocking members.

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

See Also

Reference

ReaderWriterLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReaderWriterLocking Class : WriteVersion Property

Glossary Item Box

Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WriteVersion As Integer
C#
public int WriteVersion {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReaderWriterLocking Class
ReaderWriterLocking Members

Source Code

Library/Synchronization/ReaderWriterLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReservedWriteLocking Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReservedWriteLocking Class

Glossary Item Box

provides a simple and fast, writer only lock, request for read immediatly return true.

Syntax

Visual Basic (Declaration)
Public Class ReservedWriteLocking
   Implements ILockStrategy
C#
public class ReservedWriteLocking : ILockStrategy

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.ReservedWriteLocking
CSharpTest.Net.Synchronization.ReservedWriteLocking<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ReservedWriteLocking Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReservedWriteLocking Class

Glossary Item Box

The following tables list the members exposed by ReservedWriteLocking.

Public Constructors

 | Name | Description
Public Constructor | ReservedWriteLocking Constructor | Constructs the reader-writer lock using the lock provided
Top

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | The first call reserves the Write lock for the current thread but does not stop reader access until the write lock is acquired again.
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

ReservedWriteLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReservedWriteLocking Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : ReservedWriteLocking Constructor

lck

Glossary Item Box

Constructs the reader-writer lock using the lock provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal lck As ILockStrategy _
)
C#
public ReservedWriteLocking(
   ILockStrategy lck
)

Parameters

lck

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ReservedWriteLocking Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReservedWriteLocking Class

Glossary Item Box

For a list of all members of this type, see ReservedWriteLocking members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | The first call reserves the Write lock for the current thread but does not stop reader access until the write lock is acquired again.
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

ReservedWriteLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Overridable Sub Dispose()
C#
public virtual void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : Read Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Overload List

Overload | Description
Read() | Returns a reader lock that can be elevated to a write lock
Read(Int32) | Returns a reader lock that can be elevated to a write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class > Read Method : Read() Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read() As ReadLock
C#
public ReadLock Read()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class > Read Method : Read(Int32) Method

millisecondsTimeout

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read( _
   ByVal millisecondsTimeout As Integer _
) As ReadLock
C#
public ReadLock Read(
   int millisecondsTimeout
)

Parameters

millisecondsTimeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : ReleaseRead Method

Glossary Item Box

Releases a read lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseRead()
C#
public void ReleaseRead()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : ReleaseWrite Method

Glossary Item Box

Releases a writer lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseWrite()
C#
public void ReleaseWrite()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : TryRead Method

millisecondsTimeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryRead( _
   ByVal millisecondsTimeout As Integer _
) As Boolean
C#
public bool TryRead(
   int millisecondsTimeout
)

Parameters

millisecondsTimeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : TryWrite Method

millisecondsTimeout

Glossary Item Box

The first call reserves the Write lock for the current thread but does not stop reader access until the write lock is acquired again.

Syntax

Visual Basic (Declaration)
Public Overridable Function TryWrite( _
   ByVal millisecondsTimeout As Integer _
) As Boolean
C#
public virtual bool TryWrite(
   int millisecondsTimeout
)

Parameters

millisecondsTimeout

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : Write Method

Glossary Item Box

Returns a read and write lock

Overload List

Overload | Description
Write() | Returns a read and write lock
Write(Int32) | Returns a read and write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write() As WriteLock
C#
public WriteLock Write()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class > Write Method : Write(Int32) Method

millisecondsTimeout

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write( _
   ByVal millisecondsTimeout As Integer _
) As WriteLock
C#
public WriteLock Write(
   int millisecondsTimeout
)

Parameters

millisecondsTimeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ReservedWriteLocking Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReservedWriteLocking Class

Glossary Item Box

For a list of all members of this type, see ReservedWriteLocking members.

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

See Also

Reference

ReservedWriteLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking Class : WriteVersion Property

Glossary Item Box

Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WriteVersion As Integer
C#
public int WriteVersion {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking Class
ReservedWriteLocking Members

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
ReservedWriteLocking<T> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReservedWriteLocking<T> Class

Glossary Item Box

provides a simple and fast, writer only lock, request for read immediatly return true.

Syntax

Visual Basic (Declaration)
Public Class ReservedWriteLocking(Of T As {New, ILockStrategy})
   Inherits ReservedWriteLocking
   Implements ILockStrategy
C#
public class ReservedWriteLocking<T> : ReservedWriteLocking, ILockStrategy
where T: new(), ILockStrategy

Type Parameters

T

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.ReservedWriteLocking
CSharpTest.Net.Synchronization.ReservedWriteLocking<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking<T> Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ReservedWriteLocking<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReservedWriteLocking<T> Class

Glossary Item Box

The following tables list the members exposed by ReservedWriteLocking<T>.

Public Constructors

 | Name | Description
Public Constructor | ReservedWriteLocking<T> Constructor | Constructs the reader-writer lock using a new T()
Top

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued. (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | ReleaseRead | Releases a read lock (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | ReleaseWrite | Releases a writer lock (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | TryWrite | The first call reserves the Write lock for the current thread but does not stop reader access until the write lock is acquired again. (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | Write | Overloaded. Returns a read and write lock (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Top

See Also

Reference

ReservedWriteLocking<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReservedWriteLocking<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReservedWriteLocking<T> Class : ReservedWriteLocking<T> Constructor

Glossary Item Box

Constructs the reader-writer lock using a new T()

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public ReservedWriteLocking<T>()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReservedWriteLocking<T> Class
ReservedWriteLocking<T> Members

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SimpleReadWriteLocking Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SimpleReadWriteLocking Class

Glossary Item Box

provides a simple and fast, reader-writer lock, does not support read->write upgrades, if you need an upgradeable lock, use UpgradeableReadWriteLocking

Syntax

Visual Basic (Declaration)
Public Class SimpleReadWriteLocking
   Implements ILockStrategy
C#
public class SimpleReadWriteLocking : ILockStrategy

Example

Library/Library.Test/LockingTests/TestSimpleReadWriteLocking.cs

C# Copy Code
Object obj = new object();
ILockStrategy l = new SimpleReadWriteLocking(obj);
using(new ThreadedWriter(l))
    Assert.IsFalse(Monitor.TryEnter(obj, 0));
l.Dispose();
VB.NET Copy Code
Dim obj As [Object] = New Object()
Dim l As ILockStrategy = New SimpleReadWriteLocking(obj)
Using New ThreadedWriter(l)
    Assert.IsFalse(Monitor.TryEnter(obj, 0))
End Using
l.Dispose()

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.SimpleReadWriteLocking

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SimpleReadWriteLocking Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SimpleReadWriteLocking Class

Glossary Item Box

The following tables list the members exposed by SimpleReadWriteLocking.

Public Constructors

 | Name | Description
Public Constructor | SimpleReadWriteLocking Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

Protected Methods

 | Name | Description
Protected Method | WaitForExclusive | This is the only real work to be done, once we've acquired the write lock we have to wait for all readers to complete. If/when that happens we can then own the write lock. The case where this does not take place is when a thread that already owns the lock calls us to lock again. In this case we can just return success and ignore the outstanding read requests. The major problem with this approach is that if function A() does a read-lock and calls function B() which does a write lock, this will fail. So the solution is to either use the upgradeable version (see the derived class UpgradableReadWriteLocking) and upgrade, or to start with a write lock in function A().
Top

See Also

Reference

SimpleReadWriteLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SimpleReadWriteLocking Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : SimpleReadWriteLocking Constructor

Glossary Item Box

Overload List

Overload | Description
SimpleReadWriteLocking Constructor() | Constructs the reader-writer lock using 'this' as the syncronization object
SimpleReadWriteLocking Constructor(Object) | Constructs the reader-writer lock using the specified object for syncronization

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SimpleReadWriteLocking Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class > SimpleReadWriteLocking Constructor : SimpleReadWriteLocking Constructor()

Glossary Item Box

Constructs the reader-writer lock using 'this' as the syncronization object

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public SimpleReadWriteLocking()

Example

BPlusTree/BPlusTree.Test/TestBPlusTreeOptions.cs

C# Copy Code
var options = new BPlusTree<int, int>.OptionsV2(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
{
    CreateFile = CreatePolicy.IfNeeded,
    BTreeOrder = 4
};
var copy = options.Clone();

Assert.IsFalse(Object.ReferenceEquals(options, copy));
Assert.IsFalse(Object.ReferenceEquals(options.CallLevelLock, copy.CallLevelLock));

//If we get/set the lock prior to clone we will have the same lock instance.
options.CallLevelLock = new SimpleReadWriteLocking();
copy = options.Clone();

Assert.IsFalse(Object.ReferenceEquals(options, copy));
Assert.IsTrue(Object.ReferenceEquals(options.CallLevelLock, copy.CallLevelLock));
VB.NET Copy Code
Dim options As var = New BPlusTree(Of Integer, Integer).OptionsV2(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32) With { _
    Key .CreateFile = CreatePolicy.IfNeeded, _
    Key .BTreeOrder = 4 _
}
Dim copy As var = options.Clone()

Assert.IsFalse([Object].ReferenceEquals(options, copy))
Assert.IsFalse([Object].ReferenceEquals(options.CallLevelLock, copy.CallLevelLock))

'If we get/set the lock prior to clone we will have the same lock instance.
options.CallLevelLock = New SimpleReadWriteLocking()
copy = options.Clone()

Assert.IsFalse([Object].ReferenceEquals(options, copy))
Assert.IsTrue([Object].ReferenceEquals(options.CallLevelLock, copy.CallLevelLock))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members
Overload List

Used By

TestBPlusTreeOptions.TestCloneWithCallLockV1()
TestBPlusTreeOptions.TestCloneWithCallLockV2()

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SimpleReadWriteLocking Constructor(Object)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class > SimpleReadWriteLocking Constructor : SimpleReadWriteLocking Constructor(Object)

syncRoot

Glossary Item Box

Constructs the reader-writer lock using the specified object for syncronization

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal syncRoot As Object _
)
C#
public SimpleReadWriteLocking(
   object syncRoot
)

Parameters

syncRoot

Example

Library/Library.Test/LockingTests/TestSimpleReadWriteLocking.cs

C# Copy Code
Object obj = new object();
ILockStrategy l = new SimpleReadWriteLocking(obj);
using(new ThreadedWriter(l))
    Assert.IsFalse(Monitor.TryEnter(obj, 0));
l.Dispose();
VB.NET Copy Code
Dim obj As [Object] = New Object()
Dim l As ILockStrategy = New SimpleReadWriteLocking(obj)
Using New ThreadedWriter(l)
    Assert.IsFalse(Monitor.TryEnter(obj, 0))
End Using
l.Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members
Overload List

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SimpleReadWriteLocking Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SimpleReadWriteLocking Class

Glossary Item Box

For a list of all members of this type, see SimpleReadWriteLocking members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

Protected Methods

 | Name | Description
Protected Method | WaitForExclusive | This is the only real work to be done, once we've acquired the write lock we have to wait for all readers to complete. If/when that happens we can then own the write lock. The case where this does not take place is when a thread that already owns the lock calls us to lock again. In this case we can just return success and ignore the outstanding read requests. The major problem with this approach is that if function A() does a read-lock and calls function B() which does a write lock, this will fail. So the solution is to either use the upgradeable version (see the derived class UpgradableReadWriteLocking) and upgrade, or to start with a write lock in function A().
Top

See Also

Reference

SimpleReadWriteLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : Dispose Method

Glossary Item Box

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

Visual Basic (Declaration)
Public Overridable Sub Dispose()
C#
public virtual void Dispose()

Exceptions

Exception | Description
System.InvalidOperationException | The exception that is thrown when a method call is invalid for the object's current state.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : Read Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Overload List

Overload | Description
Read() | Returns a reader lock that can be elevated to a write lock
Read(Int32) | Returns a reader lock that can be elevated to a write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class > Read Method : Read() Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read() As ReadLock
C#
public ReadLock Read()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class > Read Method : Read(Int32) Method

millisecondsTimeout

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read( _
   ByVal millisecondsTimeout As Integer _
) As ReadLock
C#
public ReadLock Read(
   int millisecondsTimeout
)

Parameters

millisecondsTimeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : ReleaseRead Method

Glossary Item Box

Releases a read lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseRead()
C#
public void ReleaseRead()

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.
System.Threading.SynchronizationLockException | The exception that is thrown when a method requires the caller to own the lock on a given Monitor, and the method is invoked by a caller that does not own that lock.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : ReleaseWrite Method

Glossary Item Box

Releases a writer lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseWrite()
C#
public void ReleaseWrite()

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : TryRead Method

millisecondsTimeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryRead( _
   ByVal millisecondsTimeout As Integer _
) As Boolean
C#
public bool TryRead(
   int millisecondsTimeout
)

Parameters

millisecondsTimeout

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : TryWrite Method

millisecondsTimeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Overridable Function TryWrite( _
   ByVal millisecondsTimeout As Integer _
) As Boolean
C#
public virtual bool TryWrite(
   int millisecondsTimeout
)

Parameters

millisecondsTimeout

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitForExclusive Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : WaitForExclusive Method

targetReaders
millisecondsTimeout

Glossary Item Box

This is the only real work to be done, once we've acquired the write lock we have to wait for all readers to complete. If/when that happens we can then own the write lock. The case where this does not take place is when a thread that already owns the lock calls us to lock again. In this case we can just return success and ignore the outstanding read requests. The major problem with this approach is that if function A() does a read-lock and calls function B() which does a write lock, this will fail. So the solution is to either use the upgradeable version (see the derived class UpgradableReadWriteLocking) and upgrade, or to start with a write lock in function A().

Syntax

Visual Basic (Declaration)
Protected Function WaitForExclusive( _
   ByVal targetReaders As Integer, _
   ByVal millisecondsTimeout As Integer _
) As Boolean
C#
protected bool WaitForExclusive(
   int targetReaders,
   int millisecondsTimeout
)

Parameters

targetReaders
millisecondsTimeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members

Used By

Boolean SimpleReadWriteLocking.TryWrite(Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : Write Method

Glossary Item Box

Returns a read and write lock

Overload List

Overload | Description
Write() | Returns a read and write lock
Write(Int32) | Returns a read and write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write() As WriteLock
C#
public WriteLock Write()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class > Write Method : Write(Int32) Method

millisecondsTimeout

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write( _
   ByVal millisecondsTimeout As Integer _
) As WriteLock
C#
public WriteLock Write(
   int millisecondsTimeout
)

Parameters

millisecondsTimeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SimpleReadWriteLocking Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SimpleReadWriteLocking Class

Glossary Item Box

For a list of all members of this type, see SimpleReadWriteLocking members.

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

See Also

Reference

SimpleReadWriteLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SimpleReadWriteLocking Class : WriteVersion Property

Glossary Item Box

Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WriteVersion As Integer
C#
public int WriteVersion {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SimpleReadWriteLocking Class
SimpleReadWriteLocking Members

Source Code

Library/Synchronization/SimpleReadWriteLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriterOnlyLocking Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : WriterOnlyLocking Class

Glossary Item Box

provides a writer-only lock around Monitor. The TryRead/ReleaseRead methods are no-ops and always return true.

Syntax

Visual Basic (Declaration)
Public Class WriterOnlyLocking
   Implements ILockStrategy
C#
public class WriterOnlyLocking : ILockStrategy

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.WriterOnlyLocking

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
WriterOnlyLocking Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : WriterOnlyLocking Class

Glossary Item Box

The following tables list the members exposed by WriterOnlyLocking.

Public Constructors

 | Name | Description
Public Constructor | WriterOnlyLocking Constructor |
Top

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

Public Methods

 | Name | Description
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

WriterOnlyLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriterOnlyLocking Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class : WriterOnlyLocking Constructor

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public WriterOnlyLocking()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
WriterOnlyLocking Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : WriterOnlyLocking Class

Glossary Item Box

For a list of all members of this type, see WriterOnlyLocking members.

Public Methods

 | Name | Description
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Public Method | ReleaseRead | Releases a read lock
Public Method | ReleaseWrite | Releases a writer lock
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Public Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

WriterOnlyLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class : Read Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Overload List

Overload | Description
Read() | Returns a reader lock that can be elevated to a write lock
Read(Int32) | Returns a reader lock that can be elevated to a write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class > Read Method : Read() Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read() As ReadLock
C#
public ReadLock Read()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class > Read Method : Read(Int32) Method

timeout

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Read( _
   ByVal timeout As Integer _
) As ReadLock
C#
public ReadLock Read(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members
Overload List
ReadLock

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class : ReleaseRead Method

Glossary Item Box

Releases a read lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseRead()
C#
public void ReleaseRead()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class : ReleaseWrite Method

Glossary Item Box

Releases a writer lock

Syntax

Visual Basic (Declaration)
Public Sub ReleaseWrite()
C#
public void ReleaseWrite()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRead Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class : TryRead Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryRead( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryRead(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryWrite Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class : TryWrite Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Public Function TryWrite( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool TryWrite(
   int timeout
)

Parameters

timeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class : Write Method

Glossary Item Box

Returns a read and write lock

Overload List

Overload | Description
Write() | Returns a read and write lock
Write(Int32) | Returns a read and write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write() As WriteLock
C#
public WriteLock Write()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int32) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class > Write Method : Write(Int32) Method

timeout

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Public Overloads Function Write( _
   ByVal timeout As Integer _
) As WriteLock
C#
public WriteLock Write(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members
Overload List
WriteLock

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
WriterOnlyLocking Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : WriterOnlyLocking Class

Glossary Item Box

For a list of all members of this type, see WriterOnlyLocking members.

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.
Top

See Also

Reference

WriterOnlyLocking Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriterOnlyLocking Class : WriteVersion Property

Glossary Item Box

Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WriteVersion As Integer
C#
public int WriteVersion {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriterOnlyLocking Class
WriterOnlyLocking Members

Source Code

Library/Synchronization/WriterOnlyLocking.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadLock Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReadLock Structure

Glossary Item Box

Allows a read lock to be disposed or elevated to a write lock

Syntax

Visual Basic (Declaration)
Public Structure ReadLock
   Inherits System.ValueType
C#
public struct ReadLock : System.ValueType

Example

Library/Library.Test/LockingTests/TestReaderWriterLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (l.Read())
    Assert.IsFalse(l.TryWrite(10));
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using l.Read()
        Assert.IsFalse(l.TryWrite(10))
    End Using
End Using

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Synchronization.ReadLock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReadLock Members
CSharpTest.Net.Synchronization Namespace
ReadLock ILockStrategy.Read()
ReadLock ILockStrategy.Read(Int32)
ReadLock ReservedWriteLocking.Read()
ReadLock ReservedWriteLocking.Read(Int32)
ReadLock DebugLocking.Read(Int32)
ReadLock DebugLocking.Read()
ReadLock ExclusiveLocking.Read()
ReadLock ExclusiveLocking.Read(Int32)
ReadLock IgnoreLocking.Read()
ReadLock IgnoreLocking.Read(Int32)
ReadLock ReaderWriterLocking.Read()
ReadLock ReaderWriterLocking.Read(Int32)
ReadLock SimpleReadWriteLocking.Read()
ReadLock SimpleReadWriteLocking.Read(Int32)
ReadLock WriterOnlyLocking.Read()
ReadLock WriterOnlyLocking.Read(Int32)

Used By

ThreadedBTreeTest.TestCallLevelLocking()
Boolean SynchronizedDictionary.ContainsKey(TKey)
Boolean SynchronizedDictionary.TryGetValue(TKey,TValue)
SynchronizedDictionary.CopyTo(KeyValuePair[],Int32)
Boolean SynchronizedList.Contains(T)
Int32 SynchronizedList.IndexOf(T)
SynchronizedList.CopyTo(T[],Int32)

Source Code

Library/Synchronization/ReadLock.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ReadLock Structure Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReadLock Structure

Glossary Item Box

The following tables list the members exposed by ReadLock.

Public Constructors

 | Name | Description
Public Constructor | ReadLock Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | HasReadLock | Returns true if read access is locked
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Acquire | Acquires the lock within the timeout or throws TimeoutException
Top

See Also

Reference

ReadLock Structure
CSharpTest.Net.Synchronization Namespace
ReadLock ILockStrategy.Read()
ReadLock ILockStrategy.Read(Int32)
ReadLock ReservedWriteLocking.Read()
ReadLock ReservedWriteLocking.Read(Int32)
ReadLock DebugLocking.Read(Int32)
ReadLock DebugLocking.Read()
ReadLock ExclusiveLocking.Read()
ReadLock ExclusiveLocking.Read(Int32)
ReadLock IgnoreLocking.Read()
ReadLock IgnoreLocking.Read(Int32)
ReadLock ReaderWriterLocking.Read()
ReadLock ReaderWriterLocking.Read(Int32)
ReadLock SimpleReadWriteLocking.Read()
ReadLock SimpleReadWriteLocking.Read(Int32)
ReadLock WriterOnlyLocking.Read()
ReadLock WriterOnlyLocking.Read(Int32)

Used By

ThreadedBTreeTest.TestCallLevelLocking()
Boolean SynchronizedDictionary.ContainsKey(TKey)
Boolean SynchronizedDictionary.TryGetValue(TKey,TValue)
SynchronizedDictionary.CopyTo(KeyValuePair[],Int32)
Boolean SynchronizedList.Contains(T)
Int32 SynchronizedList.IndexOf(T)
SynchronizedList.CopyTo(T[],Int32)

Source Code

Library/Synchronization/ReadLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadLock Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReadLock Structure : ReadLock Constructor

Glossary Item Box

Overload List

Overload | Description
ReadLock Constructor(ILockStrategy,Boolean) | Tracks an existing read lock on a resource
ReadLock Constructor(ILockStrategy,Int32) | Acquires a read lock on the resource

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReadLock Structure
ReadLock Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadLock Constructor(ILockStrategy,Boolean)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReadLock Structure > ReadLock Constructor : ReadLock Constructor(ILockStrategy,Boolean)

lck
locked

Glossary Item Box

Tracks an existing read lock on a resource

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal lck As ILockStrategy, _
   ByVal locked As Boolean _
)
C#
public ReadLock(
   ILockStrategy lck,
   bool locked
)

Parameters

lck
locked

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReadLock Structure
ReadLock Members
Overload List

Used By

ReadLock IgnoreLocking.Read()
ReadLock IgnoreLocking.Read(Int32)
ReadLock ReadLock.Acquire(ILockStrategy,Int32)

Source Code

Library/Synchronization/ReadLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadLock Constructor(ILockStrategy,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReadLock Structure > ReadLock Constructor : ReadLock Constructor(ILockStrategy,Int32)

lck
timeout

Glossary Item Box

Acquires a read lock on the resource

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal lck As ILockStrategy, _
   ByVal timeout As Integer _
)
C#
public ReadLock(
   ILockStrategy lck,
   int timeout
)

Parameters

lck
timeout

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (new ThreadedWriter(l))
using (ReadLock r = new ReadLock(l, 0))
    Assert.IsFalse(r.HasReadLock);
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using New ThreadedWriter(l)
        Using r As New ReadLock(l, 0)
            Assert.IsFalse(r.HasReadLock)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReadLock Structure
ReadLock Members
Overload List

Source Code

Library/Synchronization/ReadLock.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ReadLock Structure Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReadLock Structure

Glossary Item Box

For a list of all members of this type, see ReadLock members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Acquire | Acquires the lock within the timeout or throws TimeoutException
Top

See Also

Reference

ReadLock Structure
CSharpTest.Net.Synchronization Namespace
ReadLock ILockStrategy.Read()
ReadLock ILockStrategy.Read(Int32)
ReadLock ReservedWriteLocking.Read()
ReadLock ReservedWriteLocking.Read(Int32)
ReadLock DebugLocking.Read(Int32)
ReadLock DebugLocking.Read()
ReadLock ExclusiveLocking.Read()
ReadLock ExclusiveLocking.Read(Int32)
ReadLock IgnoreLocking.Read()
ReadLock IgnoreLocking.Read(Int32)
ReadLock ReaderWriterLocking.Read()
ReadLock ReaderWriterLocking.Read(Int32)
ReadLock SimpleReadWriteLocking.Read()
ReadLock SimpleReadWriteLocking.Read(Int32)
ReadLock WriterOnlyLocking.Read()
ReadLock WriterOnlyLocking.Read(Int32)

Used By

ThreadedBTreeTest.TestCallLevelLocking()
Boolean SynchronizedDictionary.ContainsKey(TKey)
Boolean SynchronizedDictionary.TryGetValue(TKey,TValue)
SynchronizedDictionary.CopyTo(KeyValuePair[],Int32)
Boolean SynchronizedList.Contains(T)
Int32 SynchronizedList.IndexOf(T)
SynchronizedList.CopyTo(T[],Int32)

Source Code

Library/Synchronization/ReadLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Acquire Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReadLock Structure : Acquire Method

lck
timeout

Glossary Item Box

Acquires the lock within the timeout or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Shared Function Acquire( _
   ByVal lck As ILockStrategy, _
   ByVal timeout As Integer _
) As ReadLock
C#
public static ReadLock Acquire(
   ILockStrategy lck,
   int timeout
)

Parameters

lck
timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (IDisposable r = ReadLock.Acquire(l, 0))
{
    r.Dispose();//since the using statement has the same boxed pointer to r, we are allowed to dispose
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using r As IDisposable = ReadLock.Acquire(l, 0)
            'since the using statement has the same boxed pointer to r, we are allowed to dispose
        r.Dispose()
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReadLock Structure
ReadLock Members
ILockStrategy

Used By

ReadLock ReservedWriteLocking.Read()
ReadLock ReservedWriteLocking.Read(Int32)
ReadLock DebugLocking.Read(Int32)
ReadLock DebugLocking.Read()
ReadLock ExclusiveLocking.Read()
ReadLock ExclusiveLocking.Read(Int32)
ReadLock ReaderWriterLocking.Read()
ReadLock ReaderWriterLocking.Read(Int32)
ReadLock SimpleReadWriteLocking.Read()
ReadLock SimpleReadWriteLocking.Read(Int32)
ReadLock WriterOnlyLocking.Read()
ReadLock WriterOnlyLocking.Read(Int32)

Source Code

Library/Synchronization/ReadLock.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ReadLock Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReadLock Structure

Glossary Item Box

For a list of all members of this type, see ReadLock members.

Public Properties

 | Name | Description
Public Property | HasReadLock | Returns true if read access is locked
Top

See Also

Reference

ReadLock Structure
CSharpTest.Net.Synchronization Namespace
ReadLock ILockStrategy.Read()
ReadLock ILockStrategy.Read(Int32)
ReadLock ReservedWriteLocking.Read()
ReadLock ReservedWriteLocking.Read(Int32)
ReadLock DebugLocking.Read(Int32)
ReadLock DebugLocking.Read()
ReadLock ExclusiveLocking.Read()
ReadLock ExclusiveLocking.Read(Int32)
ReadLock IgnoreLocking.Read()
ReadLock IgnoreLocking.Read(Int32)
ReadLock ReaderWriterLocking.Read()
ReadLock ReaderWriterLocking.Read(Int32)
ReadLock SimpleReadWriteLocking.Read()
ReadLock SimpleReadWriteLocking.Read(Int32)
ReadLock WriterOnlyLocking.Read()
ReadLock WriterOnlyLocking.Read(Int32)

Used By

ThreadedBTreeTest.TestCallLevelLocking()
Boolean SynchronizedDictionary.ContainsKey(TKey)
Boolean SynchronizedDictionary.TryGetValue(TKey,TValue)
SynchronizedDictionary.CopyTo(KeyValuePair[],Int32)
Boolean SynchronizedList.Contains(T)
Int32 SynchronizedList.IndexOf(T)
SynchronizedList.CopyTo(T[],Int32)

Source Code

Library/Synchronization/ReadLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HasReadLock Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ReadLock Structure : HasReadLock Property

Glossary Item Box

Returns true if read access is locked

Syntax

Visual Basic (Declaration)
Public ReadOnly Property HasReadLock As Boolean
C#
public bool HasReadLock {get;}

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (new ThreadedWriter(l))
using (ReadLock r = new ReadLock(l, 0))
    Assert.IsFalse(r.HasReadLock);
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using New ThreadedWriter(l)
        Using r As New ReadLock(l, 0)
            Assert.IsFalse(r.HasReadLock)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ReadLock Structure
ReadLock Members

Source Code

Library/Synchronization/ReadLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeLock Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SafeLock Structure

Glossary Item Box

Used to acquire a lock(object) with a timeout, either specified or the default of 2 minutes.

Syntax

Visual Basic (Declaration)
Public Structure SafeLock
   Inherits System.ValueType
C#
public struct SafeLock : System.ValueType

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
object instance = new object();
using (IDisposable safeLock = new SafeLock(instance, 0))
{
    safeLock.Dispose();//since the using statement has the same boxed pointer to r, we are allowed to dispose
}
VB.NET Copy Code
Dim instance As New Object()
Using safeLock As IDisposable = New SafeLock(instance, 0)
        'since the using statement has the same boxed pointer to r, we are allowed to dispose
    safeLock.Dispose()
End Using

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Synchronization.SafeLock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SafeLock Structure Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SafeLock Structure

Glossary Item Box

The following tables list the members exposed by SafeLock.

Public Constructors

 | Name | Description
Public Constructor | SafeLock Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | DefaultTimeout | The default timeout value used when one is not provided to the constructor
Top

See Also

Reference

SafeLock Structure
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeLock Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SafeLock Structure : SafeLock Constructor

Glossary Item Box

Overload List

Overload | Description
SafeLock Constructor(Object) | Acquires the monitor lock on the object within 2 minutes, or throws TimeoutException
SafeLock Constructor(Object,Int32) | Acquires the monitor lock on the object within timeoutMilliseconds, or throws TimeoutException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock Structure
SafeLock Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeLock Constructor(Object)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SafeLock Structure > SafeLock Constructor : SafeLock Constructor(Object)

monitor

Glossary Item Box

Acquires the monitor lock on the object within 2 minutes, or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal monitor As Object _
)
C#
public SafeLock(
   object monitor
)

Parameters

monitor

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
object instance = new object();
using (new SafeLock(instance))
{ }
VB.NET Copy Code
Dim instance As New Object()
Using New SafeLock(instance)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock Structure
SafeLock Members
Overload List

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeLock Constructor(Object,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SafeLock Structure > SafeLock Constructor : SafeLock Constructor(Object,Int32)

monitor
timeoutMilliseconds

Glossary Item Box

Acquires the monitor lock on the object within timeoutMilliseconds, or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal monitor As Object, _
   ByVal timeoutMilliseconds As Integer _
)
C#
public SafeLock(
   object monitor,
   int timeoutMilliseconds
)

Parameters

monitor
timeoutMilliseconds

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
object instance = new object();
using (IDisposable safeLock = new SafeLock(instance, 0))
{
    safeLock.Dispose();//since the using statement has the same boxed pointer to r, we are allowed to dispose
}
VB.NET Copy Code
Dim instance As New Object()
Using safeLock As IDisposable = New SafeLock(instance, 0)
        'since the using statement has the same boxed pointer to r, we are allowed to dispose
    safeLock.Dispose()
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock Structure
SafeLock Members
Overload List

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
SafeLock Structure Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SafeLock Structure

Glossary Item Box

For a list of all members of this type, see SafeLock members.

Public Fields

 | Name | Description
Public Field | DefaultTimeout | The default timeout value used when one is not provided to the constructor
Top

See Also

Reference

SafeLock Structure
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultTimeout Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SafeLock Structure : DefaultTimeout Field

Glossary Item Box

The default timeout value used when one is not provided to the constructor

Syntax

Visual Basic (Declaration)
Public Const DefaultTimeout As Integer
C#
public const int DefaultTimeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock Structure
SafeLock Members

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%%

TException
[image]
CSharpTest.Net
SafeLock<TException> Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SafeLock<TException> Structure

Glossary Item Box

Exactly as SafeLock except that <T> specifies the exception type to throw. Used to acquire a lock(object) with a timeout, either specified or the default of 2 minutes.

Syntax

Visual Basic (Declaration)
Public Structure SafeLock(Of TException As {New, Exception})
   Inherits System.ValueType
C#
public struct SafeLock<TException> : System.ValueType
where TException: new(), Exception

Type Parameters

TException

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
object instance = new object();
using (new SafeLock<InvalidOperationException>(instance))
{ }
VB.NET Copy Code
Dim instance As New Object()
Using New SafeLock(Of InvalidOperationException)(instance)
End Using

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Synchronization.SafeLock<TException>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock<TException> Members
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SafeLock<TException> Structure Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : SafeLock<TException> Structure

Glossary Item Box

The following tables list the members exposed by SafeLock<TException>.

Public Constructors

 | Name | Description
Public Constructor | SafeLock<TException> Constructor | Overloaded.
Top

See Also

Reference

SafeLock<TException> Structure
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeLock<TException> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SafeLock<TException> Structure : SafeLock<TException> Constructor

Glossary Item Box

Overload List

Overload | Description
SafeLock<TException> Constructor(Object) | Acquires the monitor lock on the object within 2 minutes, or throws TimeoutException
SafeLock<TException> Constructor(Object,Int32) | Acquires the monitor lock on the object within timeoutMilliseconds, or throws TimeoutException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock<TException> Structure
SafeLock<TException> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeLock<TException> Constructor(Object)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SafeLock<TException> Structure > SafeLock<TException> Constructor : SafeLock<TException> Constructor(Object)

monitor

Glossary Item Box

Acquires the monitor lock on the object within 2 minutes, or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal monitor As Object _
)
C#
public SafeLock<TException>(
   object monitor
)

Parameters

monitor

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
object instance = new object();
using (new SafeLock<InvalidOperationException>(instance))
{ }
VB.NET Copy Code
Dim instance As New Object()
Using New SafeLock(Of InvalidOperationException)(instance)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock<TException> Structure
SafeLock<TException> Members
Overload List

Source Code

Library/Synchronization/SafeLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeLock<TException> Constructor(Object,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > SafeLock<TException> Structure > SafeLock<TException> Constructor : SafeLock<TException> Constructor(Object,Int32)

monitor
timeoutMilliseconds

Glossary Item Box

Acquires the monitor lock on the object within timeoutMilliseconds, or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal monitor As Object, _
   ByVal timeoutMilliseconds As Integer _
)
C#
public SafeLock<TException>(
   object monitor,
   int timeoutMilliseconds
)

Parameters

monitor
timeoutMilliseconds

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SafeLock<TException> Structure
SafeLock<TException> Members
Overload List

Source Code

Library/Synchronization/SafeLock.cs

Used By

SimpleReadWriteLocking.Dispose()


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteLock Structure
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : WriteLock Structure

Glossary Item Box

Allows a write lock to be disposed

Syntax

Visual Basic (Declaration)
Public Structure WriteLock
   Inherits System.ValueType
C#
public struct WriteLock : System.ValueType

Example

Library/Library.Test/LockingTests/TestIgnoreLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    Assert.AreEqual(0, l.WriteVersion);
    using(l.Write())
        Assert.AreEqual(0, l.WriteVersion);
    Assert.AreEqual(0, l.WriteVersion);
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Assert.AreEqual(0, l.WriteVersion)
    Using l.Write()
        Assert.AreEqual(0, l.WriteVersion)
    End Using
    Assert.AreEqual(0, l.WriteVersion)
End Using

Inheritance Hierarchy

System.Object
System.ValueType
CSharpTest.Net.Synchronization.WriteLock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriteLock Members
CSharpTest.Net.Synchronization Namespace
WriteLock ILockStrategy.Write()
WriteLock ILockStrategy.Write(Int32)
WriteLock ReservedWriteLocking.Write()
WriteLock ReservedWriteLocking.Write(Int32)
WriteLock DebugLocking.Write(Int32)
WriteLock DebugLocking.Write()
WriteLock ExclusiveLocking.Write()
WriteLock ExclusiveLocking.Write(Int32)
WriteLock IgnoreLocking.Write()
WriteLock IgnoreLocking.Write(Int32)
WriteLock ReaderWriterLocking.Write()
WriteLock ReaderWriterLocking.Write(Int32)
WriteLock SimpleReadWriteLocking.Write()
WriteLock SimpleReadWriteLocking.Write(Int32)
WriteLock WriterOnlyLocking.Write()
WriteLock WriterOnlyLocking.Write(Int32)

Used By

BPlusTree.Rollback()
BPlusTree.UnloadCache()
BPlusTree.Clear()
ThreadedBTreeTest.TestCallLevelLocking()
IDictionary SynchronizedDictionary.ReplaceStorage(IDictionary)
SynchronizedDictionary.Add(TKey,TValue)
Boolean SynchronizedDictionary.Remove(TKey)
SynchronizedDictionary.Clear()
TValue SynchronizedDictionary.GetOrAdd(TKey,TValue)
TValue SynchronizedDictionary.GetOrAdd(TKey,Converter)
Boolean SynchronizedDictionary.TryAdd(TKey,TValue)
Boolean SynchronizedDictionary.TryAdd(TKey,Converter)
TValue SynchronizedDictionary.AddOrUpdate(TKey,TValue,KeyValueUpdate)
TValue SynchronizedDictionary.AddOrUpdate(TKey,Converter,KeyValueUpdate)
Boolean SynchronizedDictionary.AddOrUpdate(TKey,T)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,KeyValueUpdate)
Boolean SynchronizedDictionary.TryRemove(TKey,TValue)
Boolean SynchronizedDictionary.TryRemove(TKey,KeyValuePredicate)
Boolean SynchronizedDictionary.TryRemove(TKey,T)
IList SynchronizedList.ReplaceStorage(IList)
Int32 SynchronizedList.Add(T)
SynchronizedList.Insert(Int32,T)
Boolean SynchronizedList.Remove(T)
SynchronizedList.RemoveAt(Int32)
SynchronizedList.Clear()

Source Code

Library/Synchronization/WriteLock.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
WriteLock Structure Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : WriteLock Structure

Glossary Item Box

The following tables list the members exposed by WriteLock.

Public Constructors

 | Name | Description
Public Constructor | WriteLock Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | HasWriteLock | Returns true if write access is locked
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Acquire | Acquires the lock within the timeout or throws TimeoutException
Top

See Also

Reference

WriteLock Structure
CSharpTest.Net.Synchronization Namespace
WriteLock ILockStrategy.Write()
WriteLock ILockStrategy.Write(Int32)
WriteLock ReservedWriteLocking.Write()
WriteLock ReservedWriteLocking.Write(Int32)
WriteLock DebugLocking.Write(Int32)
WriteLock DebugLocking.Write()
WriteLock ExclusiveLocking.Write()
WriteLock ExclusiveLocking.Write(Int32)
WriteLock IgnoreLocking.Write()
WriteLock IgnoreLocking.Write(Int32)
WriteLock ReaderWriterLocking.Write()
WriteLock ReaderWriterLocking.Write(Int32)
WriteLock SimpleReadWriteLocking.Write()
WriteLock SimpleReadWriteLocking.Write(Int32)
WriteLock WriterOnlyLocking.Write()
WriteLock WriterOnlyLocking.Write(Int32)

Used By

BPlusTree.Rollback()
BPlusTree.UnloadCache()
BPlusTree.Clear()
ThreadedBTreeTest.TestCallLevelLocking()
IDictionary SynchronizedDictionary.ReplaceStorage(IDictionary)
SynchronizedDictionary.Add(TKey,TValue)
Boolean SynchronizedDictionary.Remove(TKey)
SynchronizedDictionary.Clear()
TValue SynchronizedDictionary.GetOrAdd(TKey,TValue)
TValue SynchronizedDictionary.GetOrAdd(TKey,Converter)
Boolean SynchronizedDictionary.TryAdd(TKey,TValue)
Boolean SynchronizedDictionary.TryAdd(TKey,Converter)
TValue SynchronizedDictionary.AddOrUpdate(TKey,TValue,KeyValueUpdate)
TValue SynchronizedDictionary.AddOrUpdate(TKey,Converter,KeyValueUpdate)
Boolean SynchronizedDictionary.AddOrUpdate(TKey,T)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,KeyValueUpdate)
Boolean SynchronizedDictionary.TryRemove(TKey,TValue)
Boolean SynchronizedDictionary.TryRemove(TKey,KeyValuePredicate)
Boolean SynchronizedDictionary.TryRemove(TKey,T)
IList SynchronizedList.ReplaceStorage(IList)
Int32 SynchronizedList.Add(T)
SynchronizedList.Insert(Int32,T)
Boolean SynchronizedList.Remove(T)
SynchronizedList.RemoveAt(Int32)
SynchronizedList.Clear()

Source Code

Library/Synchronization/WriteLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteLock Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriteLock Structure : WriteLock Constructor

Glossary Item Box

Overload List

Overload | Description
WriteLock Constructor(ILockStrategy,Boolean) | Tracks an existing read lock on a resource
WriteLock Constructor(ILockStrategy,Int32) | Acquires a read lock on the resource

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriteLock Structure
WriteLock Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteLock Constructor(ILockStrategy,Boolean)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriteLock Structure > WriteLock Constructor : WriteLock Constructor(ILockStrategy,Boolean)

lck
locked

Glossary Item Box

Tracks an existing read lock on a resource

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal lck As ILockStrategy, _
   ByVal locked As Boolean _
)
C#
public WriteLock(
   ILockStrategy lck,
   bool locked
)

Parameters

lck
locked

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriteLock Structure
WriteLock Members
Overload List

Used By

WriteLock IgnoreLocking.Write()
WriteLock IgnoreLocking.Write(Int32)
WriteLock WriteLock.Acquire(ILockStrategy,Int32)

Source Code

Library/Synchronization/WriteLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteLock Constructor(ILockStrategy,Int32)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriteLock Structure > WriteLock Constructor : WriteLock Constructor(ILockStrategy,Int32)

lck
timeout

Glossary Item Box

Acquires a read lock on the resource

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal lck As ILockStrategy, _
   ByVal timeout As Integer _
)
C#
public WriteLock(
   ILockStrategy lck,
   int timeout
)

Parameters

lck
timeout

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (new ThreadedWriter(l))
using (WriteLock w = new WriteLock(l, 0))
    Assert.IsFalse(w.HasWriteLock);
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using New ThreadedWriter(l)
        Using w As New WriteLock(l, 0)
            Assert.IsFalse(w.HasWriteLock)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriteLock Structure
WriteLock Members
Overload List

Source Code

Library/Synchronization/WriteLock.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
WriteLock Structure Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : WriteLock Structure

Glossary Item Box

For a list of all members of this type, see WriteLock members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Acquire | Acquires the lock within the timeout or throws TimeoutException
Top

See Also

Reference

WriteLock Structure
CSharpTest.Net.Synchronization Namespace
WriteLock ILockStrategy.Write()
WriteLock ILockStrategy.Write(Int32)
WriteLock ReservedWriteLocking.Write()
WriteLock ReservedWriteLocking.Write(Int32)
WriteLock DebugLocking.Write(Int32)
WriteLock DebugLocking.Write()
WriteLock ExclusiveLocking.Write()
WriteLock ExclusiveLocking.Write(Int32)
WriteLock IgnoreLocking.Write()
WriteLock IgnoreLocking.Write(Int32)
WriteLock ReaderWriterLocking.Write()
WriteLock ReaderWriterLocking.Write(Int32)
WriteLock SimpleReadWriteLocking.Write()
WriteLock SimpleReadWriteLocking.Write(Int32)
WriteLock WriterOnlyLocking.Write()
WriteLock WriterOnlyLocking.Write(Int32)

Used By

BPlusTree.Rollback()
BPlusTree.UnloadCache()
BPlusTree.Clear()
ThreadedBTreeTest.TestCallLevelLocking()
IDictionary SynchronizedDictionary.ReplaceStorage(IDictionary)
SynchronizedDictionary.Add(TKey,TValue)
Boolean SynchronizedDictionary.Remove(TKey)
SynchronizedDictionary.Clear()
TValue SynchronizedDictionary.GetOrAdd(TKey,TValue)
TValue SynchronizedDictionary.GetOrAdd(TKey,Converter)
Boolean SynchronizedDictionary.TryAdd(TKey,TValue)
Boolean SynchronizedDictionary.TryAdd(TKey,Converter)
TValue SynchronizedDictionary.AddOrUpdate(TKey,TValue,KeyValueUpdate)
TValue SynchronizedDictionary.AddOrUpdate(TKey,Converter,KeyValueUpdate)
Boolean SynchronizedDictionary.AddOrUpdate(TKey,T)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,KeyValueUpdate)
Boolean SynchronizedDictionary.TryRemove(TKey,TValue)
Boolean SynchronizedDictionary.TryRemove(TKey,KeyValuePredicate)
Boolean SynchronizedDictionary.TryRemove(TKey,T)
IList SynchronizedList.ReplaceStorage(IList)
Int32 SynchronizedList.Add(T)
SynchronizedList.Insert(Int32,T)
Boolean SynchronizedList.Remove(T)
SynchronizedList.RemoveAt(Int32)
SynchronizedList.Clear()

Source Code

Library/Synchronization/WriteLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Acquire Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriteLock Structure : Acquire Method

lck
timeout

Glossary Item Box

Acquires the lock within the timeout or throws TimeoutException

Syntax

Visual Basic (Declaration)
Public Shared Function Acquire( _
   ByVal lck As ILockStrategy, _
   ByVal timeout As Integer _
) As WriteLock
C#
public static WriteLock Acquire(
   ILockStrategy lck,
   int timeout
)

Parameters

lck
timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriteLock Structure
WriteLock Members
ILockStrategy

Used By

WriteLock ReservedWriteLocking.Write()
WriteLock ReservedWriteLocking.Write(Int32)
WriteLock DebugLocking.Write(Int32)
WriteLock DebugLocking.Write()
WriteLock ExclusiveLocking.Write()
WriteLock ExclusiveLocking.Write(Int32)
WriteLock ReaderWriterLocking.Write()
WriteLock ReaderWriterLocking.Write(Int32)
WriteLock SimpleReadWriteLocking.Write()
WriteLock SimpleReadWriteLocking.Write(Int32)
WriteLock WriterOnlyLocking.Write()
WriteLock WriterOnlyLocking.Write(Int32)

Source Code

Library/Synchronization/WriteLock.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
WriteLock Structure Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : WriteLock Structure

Glossary Item Box

For a list of all members of this type, see WriteLock members.

Public Properties

 | Name | Description
Public Property | HasWriteLock | Returns true if write access is locked
Top

See Also

Reference

WriteLock Structure
CSharpTest.Net.Synchronization Namespace
WriteLock ILockStrategy.Write()
WriteLock ILockStrategy.Write(Int32)
WriteLock ReservedWriteLocking.Write()
WriteLock ReservedWriteLocking.Write(Int32)
WriteLock DebugLocking.Write(Int32)
WriteLock DebugLocking.Write()
WriteLock ExclusiveLocking.Write()
WriteLock ExclusiveLocking.Write(Int32)
WriteLock IgnoreLocking.Write()
WriteLock IgnoreLocking.Write(Int32)
WriteLock ReaderWriterLocking.Write()
WriteLock ReaderWriterLocking.Write(Int32)
WriteLock SimpleReadWriteLocking.Write()
WriteLock SimpleReadWriteLocking.Write(Int32)
WriteLock WriterOnlyLocking.Write()
WriteLock WriterOnlyLocking.Write(Int32)

Used By

BPlusTree.Rollback()
BPlusTree.UnloadCache()
BPlusTree.Clear()
ThreadedBTreeTest.TestCallLevelLocking()
IDictionary SynchronizedDictionary.ReplaceStorage(IDictionary)
SynchronizedDictionary.Add(TKey,TValue)
Boolean SynchronizedDictionary.Remove(TKey)
SynchronizedDictionary.Clear()
TValue SynchronizedDictionary.GetOrAdd(TKey,TValue)
TValue SynchronizedDictionary.GetOrAdd(TKey,Converter)
Boolean SynchronizedDictionary.TryAdd(TKey,TValue)
Boolean SynchronizedDictionary.TryAdd(TKey,Converter)
TValue SynchronizedDictionary.AddOrUpdate(TKey,TValue,KeyValueUpdate)
TValue SynchronizedDictionary.AddOrUpdate(TKey,Converter,KeyValueUpdate)
Boolean SynchronizedDictionary.AddOrUpdate(TKey,T)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,KeyValueUpdate)
Boolean SynchronizedDictionary.TryRemove(TKey,TValue)
Boolean SynchronizedDictionary.TryRemove(TKey,KeyValuePredicate)
Boolean SynchronizedDictionary.TryRemove(TKey,T)
IList SynchronizedList.ReplaceStorage(IList)
Int32 SynchronizedList.Add(T)
SynchronizedList.Insert(Int32,T)
Boolean SynchronizedList.Remove(T)
SynchronizedList.RemoveAt(Int32)
SynchronizedList.Clear()

Source Code

Library/Synchronization/WriteLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HasWriteLock Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > WriteLock Structure : HasWriteLock Property

Glossary Item Box

Returns true if write access is locked

Syntax

Visual Basic (Declaration)
Public ReadOnly Property HasWriteLock As Boolean
C#
public bool HasWriteLock {get;}

Example

Library/Library.Test/LockingTests/TestLockingStructs.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (new ThreadedWriter(l))
using (WriteLock w = new WriteLock(l, 0))
    Assert.IsFalse(w.HasWriteLock);
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using New ThreadedWriter(l)
        Using w As New WriteLock(l, 0)
            Assert.IsFalse(w.HasWriteLock)
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WriteLock Structure
WriteLock Members

Source Code

Library/Synchronization/WriteLock.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ILockFactory Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ILockFactory Interface

Glossary Item Box

A factory that produces instances of ILockStrategy to aquire/release read/write locks

Syntax

Visual Basic (Declaration)
Public Interface ILockFactory
   Inherits CSharpTest.Net.Interfaces.IFactory(Of ILockStrategy)
C#
public interface ILockFactory : CSharpTest.Net.Interfaces.IFactory<ILockStrategy>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockFactory Members
CSharpTest.Net.Synchronization Namespace
ILockFactory BPlusTreeOptions.LockingFactory


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ILockFactory Interface Members
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ILockFactory Interface

Glossary Item Box

The following tables list the members exposed by ILockFactory.

See Also

Reference

ILockFactory Interface
CSharpTest.Net.Synchronization Namespace
ILockFactory BPlusTreeOptions.LockingFactory


%%PageItemTitle%%

[image]
CSharpTest.Net
ILockStrategy Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ILockStrategy Interface

Glossary Item Box

An interface that allows reader/writer locking with the using() statement

Syntax

Visual Basic (Declaration)
Public Interface ILockStrategy
C#
public interface ILockStrategy

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Members
CSharpTest.Net.Synchronization Namespace
ILockStrategy BPlusTree.CallLevelLock
ILockStrategy BPlusTreeOptions.CallLevelLock
ILockStrategy BPlusTree.OptionsV2.CallLevelLock
ILockStrategy SynchronizedDictionary.Lock
ILockStrategy SynchronizedList.Lock
ILockStrategy LockCounterFactory.Create()
ILockStrategy DebugLockFactory.Create()
ILockStrategy IgnoreLockFactory.Create()
ILockStrategy LockFactory.Create()
ReadLock ReadLock.Acquire(ILockStrategy,Int32)
WriteLock WriteLock.Acquire(ILockStrategy,Int32)

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ILockStrategy Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ILockStrategy Interface

Glossary Item Box

The following tables list the members exposed by ILockStrategy.

Public Properties

 | Name | Description
Property | WriteVersion | The the current writer sequence number
Top

Public Methods

 | Name | Description
Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Method | ReleaseRead | Releases a read lock
Method | ReleaseWrite | Releases a writer lock
Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

ILockStrategy Interface
CSharpTest.Net.Synchronization Namespace
ILockStrategy BPlusTree.CallLevelLock
ILockStrategy BPlusTreeOptions.CallLevelLock
ILockStrategy BPlusTree.OptionsV2.CallLevelLock
ILockStrategy SynchronizedDictionary.Lock
ILockStrategy SynchronizedList.Lock
ILockStrategy LockCounterFactory.Create()
ILockStrategy DebugLockFactory.Create()
ILockStrategy IgnoreLockFactory.Create()
ILockStrategy LockFactory.Create()
ReadLock ReadLock.Acquire(ILockStrategy,Int32)
WriteLock WriteLock.Acquire(ILockStrategy,Int32)

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ILockStrategy Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ILockStrategy Interface

Glossary Item Box

For a list of all members of this type, see ILockStrategy members.

Public Methods

 | Name | Description
Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock
Method | ReleaseRead | Releases a read lock
Method | ReleaseWrite | Releases a writer lock
Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified
Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified
Method | Write | Overloaded. Returns a read and write lock
Top

See Also

Reference

ILockStrategy Interface
CSharpTest.Net.Synchronization Namespace
ILockStrategy BPlusTree.CallLevelLock
ILockStrategy BPlusTreeOptions.CallLevelLock
ILockStrategy BPlusTree.OptionsV2.CallLevelLock
ILockStrategy SynchronizedDictionary.Lock
ILockStrategy SynchronizedList.Lock
ILockStrategy LockCounterFactory.Create()
ILockStrategy DebugLockFactory.Create()
ILockStrategy IgnoreLockFactory.Create()
ILockStrategy LockFactory.Create()
ReadLock ReadLock.Acquire(ILockStrategy,Int32)
WriteLock WriteLock.Acquire(ILockStrategy,Int32)

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface : Read Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Overload List

Overload | Description
Read() | Returns a reader lock that can be elevated to a write lock
Read(Int32) | Returns a reader lock that can be elevated to a write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Read() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface > Read Method : Read() Method

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Overloads Function Read() As ReadLock
C#
ReadLock Read()

Example

Library/Library.Test/LockingTests/TestReaderWriterLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (l.Read())
    Assert.IsFalse(l.TryWrite(10));
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using l.Read()
        Assert.IsFalse(l.TryWrite(10))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members
Overload List
ReadLock

Used By

ThreadedBTreeTest.TestCallLevelLocking()
Boolean SynchronizedDictionary.ContainsKey(TKey)
Boolean SynchronizedDictionary.TryGetValue(TKey,TValue)
SynchronizedDictionary.CopyTo(KeyValuePair[],Int32)
Boolean SynchronizedList.Contains(T)
Int32 SynchronizedList.IndexOf(T)
SynchronizedList.CopyTo(T[],Int32)

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Read(Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface > Read Method : Read(Int32) Method

timeout

Glossary Item Box

Returns a reader lock that can be elevated to a write lock

Syntax

Visual Basic (Declaration)
Overloads Function Read( _
   ByVal timeout As Integer _
) As ReadLock
C#
ReadLock Read(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/LockingTests/BaseLockTest.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    using (l.Write(0))
    { }
    using (l.Read(0))
    { }
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using l.Write(0)
    End Using
    Using l.Read(0)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members
Overload List
ReadLock

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseRead Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface : ReleaseRead Method

Glossary Item Box

Releases a read lock

Syntax

Visual Basic (Declaration)
Sub ReleaseRead()
C#
void ReleaseRead()

Example

Library/Library.Test/LockingTests/TestReservedWriteLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    Assert.AreEqual(0, l.WriteVersion);

    Assert.IsTrue(l.TryRead(0));
    l.ReleaseRead();
    Assert.AreEqual(0, l.WriteVersion);

    Assert.IsTrue(l.TryWrite(0));
    Assert.AreEqual(0, l.WriteVersion);
    l.ReleaseWrite();
    Assert.AreEqual(0, l.WriteVersion);

    using (l.Write())
    {
        Assert.AreEqual(0, l.WriteVersion);
        Assert.IsTrue(l.TryWrite(0));
        // Once a nested write lock is acquired the real lock is obtained.
        Assert.AreEqual(1, l.WriteVersion);
        l.ReleaseWrite();
        Assert.AreEqual(1, l.WriteVersion);
    }

    Assert.IsTrue(l.TryWrite(0));
    l.ReleaseWrite();
    Assert.AreEqual(1, l.WriteVersion);
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Assert.AreEqual(0, l.WriteVersion)

    Assert.IsTrue(l.TryRead(0))
    l.ReleaseRead()
    Assert.AreEqual(0, l.WriteVersion)

    Assert.IsTrue(l.TryWrite(0))
    Assert.AreEqual(0, l.WriteVersion)
    l.ReleaseWrite()
    Assert.AreEqual(0, l.WriteVersion)

    Using l.Write()
        Assert.AreEqual(0, l.WriteVersion)
        Assert.IsTrue(l.TryWrite(0))
        ' Once a nested write lock is acquired the real lock is obtained.
        Assert.AreEqual(1, l.WriteVersion)
        l.ReleaseWrite()
        Assert.AreEqual(1, l.WriteVersion)
    End Using

    Assert.IsTrue(l.TryWrite(0))
    l.ReleaseWrite()
    Assert.AreEqual(1, l.WriteVersion)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members

Source Code

Library/Synchronization/ILockStrategy.cs

Used By

ReservedWriteLocking.ReleaseRead()
DebugLocking.ReleaseRead()


%%PageItemTitle%%

[image]
CSharpTest.Net
ReleaseWrite Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface : ReleaseWrite Method

Glossary Item Box

Releases a writer lock

Syntax

Visual Basic (Declaration)
Sub ReleaseWrite()
C#
void ReleaseWrite()

Example

Library/Library.Test/LockingTests/TestReservedWriteLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    Assert.AreEqual(0, l.WriteVersion);

    Assert.IsTrue(l.TryRead(0));
    l.ReleaseRead();
    Assert.AreEqual(0, l.WriteVersion);

    Assert.IsTrue(l.TryWrite(0));
    Assert.AreEqual(0, l.WriteVersion);
    l.ReleaseWrite();
    Assert.AreEqual(0, l.WriteVersion);

    using (l.Write())
    {
        Assert.AreEqual(0, l.WriteVersion);
        Assert.IsTrue(l.TryWrite(0));
        // Once a nested write lock is acquired the real lock is obtained.
        Assert.AreEqual(1, l.WriteVersion);
        l.ReleaseWrite();
        Assert.AreEqual(1, l.WriteVersion);
    }

    Assert.IsTrue(l.TryWrite(0));
    l.ReleaseWrite();
    Assert.AreEqual(1, l.WriteVersion);
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Assert.AreEqual(0, l.WriteVersion)

    Assert.IsTrue(l.TryRead(0))
    l.ReleaseRead()
    Assert.AreEqual(0, l.WriteVersion)

    Assert.IsTrue(l.TryWrite(0))
    Assert.AreEqual(0, l.WriteVersion)
    l.ReleaseWrite()
    Assert.AreEqual(0, l.WriteVersion)

    Using l.Write()
        Assert.AreEqual(0, l.WriteVersion)
        Assert.IsTrue(l.TryWrite(0))
        ' Once a nested write lock is acquired the real lock is obtained.
        Assert.AreEqual(1, l.WriteVersion)
        l.ReleaseWrite()
        Assert.AreEqual(1, l.WriteVersion)
    End Using

    Assert.IsTrue(l.TryWrite(0))
    l.ReleaseWrite()
    Assert.AreEqual(1, l.WriteVersion)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members

Used By

BPlusTree.Dispose()
ReservedWriteLocking.ReleaseWrite()
DebugLocking.ReleaseWrite()

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryRead Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface : TryRead Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Function TryRead( _
   ByVal timeout As Integer _
) As Boolean
C#
bool TryRead(
   int timeout
)

Parameters

timeout

Example

Library/Library.Test/LockingTests/TestReservedWriteLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    Assert.AreEqual(0, l.WriteVersion);

    Assert.IsTrue(l.TryRead(0));
    l.ReleaseRead();
    Assert.AreEqual(0, l.WriteVersion);

    Assert.IsTrue(l.TryWrite(0));
    Assert.AreEqual(0, l.WriteVersion);
    l.ReleaseWrite();
    Assert.AreEqual(0, l.WriteVersion);

    using (l.Write())
    {
        Assert.AreEqual(0, l.WriteVersion);
        Assert.IsTrue(l.TryWrite(0));
        // Once a nested write lock is acquired the real lock is obtained.
        Assert.AreEqual(1, l.WriteVersion);
        l.ReleaseWrite();
        Assert.AreEqual(1, l.WriteVersion);
    }

    Assert.IsTrue(l.TryWrite(0));
    l.ReleaseWrite();
    Assert.AreEqual(1, l.WriteVersion);
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Assert.AreEqual(0, l.WriteVersion)

    Assert.IsTrue(l.TryRead(0))
    l.ReleaseRead()
    Assert.AreEqual(0, l.WriteVersion)

    Assert.IsTrue(l.TryWrite(0))
    Assert.AreEqual(0, l.WriteVersion)
    l.ReleaseWrite()
    Assert.AreEqual(0, l.WriteVersion)

    Using l.Write()
        Assert.AreEqual(0, l.WriteVersion)
        Assert.IsTrue(l.TryWrite(0))
        ' Once a nested write lock is acquired the real lock is obtained.
        Assert.AreEqual(1, l.WriteVersion)
        l.ReleaseWrite()
        Assert.AreEqual(1, l.WriteVersion)
    End Using

    Assert.IsTrue(l.TryWrite(0))
    l.ReleaseWrite()
    Assert.AreEqual(1, l.WriteVersion)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members

Source Code

Library/Synchronization/ILockStrategy.cs

Used By

Boolean ReservedWriteLocking.TryRead(Int32)
Boolean DebugLocking.TryRead(Int32)
ReadLock ReadLock.Acquire(ILockStrategy,Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
TryWrite Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface : TryWrite Method

timeout

Glossary Item Box

Returns true if the lock was successfully obtained within the timeout specified

Syntax

Visual Basic (Declaration)
Function TryWrite( _
   ByVal timeout As Integer _
) As Boolean
C#
bool TryWrite(
   int timeout
)

Parameters

timeout

Example

Library/Library.Test/LockingTests/TestReaderWriterLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
using (l.Read())
    Assert.IsFalse(l.TryWrite(10));
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using l.Read()
        Assert.IsFalse(l.TryWrite(10))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members

Used By

BPlusTree.Dispose()
Boolean ReservedWriteLocking.TryWrite(Int32)
Boolean DebugLocking.TryWrite(Int32)
WriteLock WriteLock.Acquire(ILockStrategy,Int32)

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface : Write Method

Glossary Item Box

Returns a read and write lock

Overload List

Overload | Description
Write() | Returns a read and write lock
Write(Int32) | Returns a read and write lock

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Overloads Function Write() As WriteLock
C#
WriteLock Write()

Example

Library/Library.Test/LockingTests/TestIgnoreLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    Assert.AreEqual(0, l.WriteVersion);
    using(l.Write())
        Assert.AreEqual(0, l.WriteVersion);
    Assert.AreEqual(0, l.WriteVersion);
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Assert.AreEqual(0, l.WriteVersion)
    Using l.Write()
        Assert.AreEqual(0, l.WriteVersion)
    End Using
    Assert.AreEqual(0, l.WriteVersion)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members
Overload List
WriteLock

Used By

ThreadedBTreeTest.TestCallLevelLocking()
IDictionary SynchronizedDictionary.ReplaceStorage(IDictionary)
SynchronizedDictionary.Add(TKey,TValue)
Boolean SynchronizedDictionary.Remove(TKey)
SynchronizedDictionary.Clear()
TValue SynchronizedDictionary.GetOrAdd(TKey,TValue)
TValue SynchronizedDictionary.GetOrAdd(TKey,Converter)
Boolean SynchronizedDictionary.TryAdd(TKey,TValue)
Boolean SynchronizedDictionary.TryAdd(TKey,Converter)
TValue SynchronizedDictionary.AddOrUpdate(TKey,TValue,KeyValueUpdate)
TValue SynchronizedDictionary.AddOrUpdate(TKey,Converter,KeyValueUpdate)
Boolean SynchronizedDictionary.AddOrUpdate(TKey,T)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,TValue,TValue)
Boolean SynchronizedDictionary.TryUpdate(TKey,KeyValueUpdate)
Boolean SynchronizedDictionary.TryRemove(TKey,TValue)
Boolean SynchronizedDictionary.TryRemove(TKey,KeyValuePredicate)
Boolean SynchronizedDictionary.TryRemove(TKey,T)
IList SynchronizedList.ReplaceStorage(IList)
Int32 SynchronizedList.Add(T)
SynchronizedList.Insert(Int32,T)
Boolean SynchronizedList.Remove(T)
SynchronizedList.RemoveAt(Int32)
SynchronizedList.Clear()

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface > Write Method : Write(Int32) Method

timeout

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration)
Overloads Function Write( _
   ByVal timeout As Integer _
) As WriteLock
C#
WriteLock Write(
   int timeout
)

Parameters

timeout

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/LockingTests/BaseLockTest.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    using (l.Write(0))
    { }
    using (l.Read(0))
    { }
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Using l.Write(0)
    End Using
    Using l.Read(0)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members
Overload List
WriteLock

Used By

BPlusTree.Rollback()
BPlusTree.UnloadCache()
BPlusTree.Clear()

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ILockStrategy Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ILockStrategy Interface

Glossary Item Box

For a list of all members of this type, see ILockStrategy members.

Public Properties

 | Name | Description
Property | WriteVersion | The the current writer sequence number
Top

See Also

Reference

ILockStrategy Interface
CSharpTest.Net.Synchronization Namespace
ILockStrategy BPlusTree.CallLevelLock
ILockStrategy BPlusTreeOptions.CallLevelLock
ILockStrategy BPlusTree.OptionsV2.CallLevelLock
ILockStrategy SynchronizedDictionary.Lock
ILockStrategy SynchronizedList.Lock
ILockStrategy LockCounterFactory.Create()
ILockStrategy DebugLockFactory.Create()
ILockStrategy IgnoreLockFactory.Create()
ILockStrategy LockFactory.Create()
ReadLock ReadLock.Acquire(ILockStrategy,Int32)
WriteLock WriteLock.Acquire(ILockStrategy,Int32)

Source Code

Library/Synchronization/ILockStrategy.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteVersion Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > ILockStrategy Interface : WriteVersion Property

Glossary Item Box

The the current writer sequence number

Syntax

Visual Basic (Declaration)
ReadOnly Property WriteVersion As Integer
C#
int WriteVersion {get;}

Example

Library/Library.Test/LockingTests/TestIgnoreLocking.cs

C# Copy Code
using (ILockStrategy l = LockFactory.Create())
{
    Assert.AreEqual(0, l.WriteVersion);
    using(l.Write())
        Assert.AreEqual(0, l.WriteVersion);
    Assert.AreEqual(0, l.WriteVersion);
}
VB.NET Copy Code
Using l As ILockStrategy = LockFactory.Create()
    Assert.AreEqual(0, l.WriteVersion)
    Using l.Write()
        Assert.AreEqual(0, l.WriteVersion)
    End Using
    Assert.AreEqual(0, l.WriteVersion)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ILockStrategy Interface
ILockStrategy Members

Source Code

Library/Synchronization/ILockStrategy.cs


%%ItemTitle%%

CSharpTest.Net.Threading Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Threading Namespace

Glossary Item Box

Classes

 | Class | Description
Class | CallsPerSecondCounter | A low-precision, but fast, counter that estimates how often the Increment() method is being called on this instance. The precision is roughly +/- 1.7% for every 1000 calls/sec; so at 20000 calls/second expect the Value property to be +/- 34%. If you looking for something cheap to use to 'push-back' on overbearing clients this should suite most needs. If more accuracy is desired at higher volumes, specify the sampleFreq to scale the data samples under 1000/sec.
Class | UsageCounter | Provides a counter that fires a delegate on first usage and last release. For the counts to be maintained someone must hold an instance of one or more of these objects.
Class | WaitAndContinueList | Represents a set of queued IWorkAndContinue items that can be processed
Class | WaitAndContinueWorker | Represents a single worker thread that processes IWaitAndContinue work items
Class | WorkQueue | An extremely basic WorkQueue using a fixed number of threads to execute Action() or Action<T> delegates
Class | WorkQueue<T> | An extremely basic WorkQueue using a fixed number of threads to execute Action<T> over the enqueued instances of type T, aggregates an instance of WorkQueue()

Interfaces

 | Interface | Description
Interface | IWaitAndContinue | Describes a set of WaitHandles that, when signaled, trigger a process to continue
Interface | IWorkQueue<T> | Provides an interface for a simple WorkQueue

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
CallsPerSecondCounter Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : CallsPerSecondCounter Class

Glossary Item Box

A low-precision, but fast, counter that estimates how often the Increment() method is being called on this instance. The precision is roughly +/- 1.7% for every 1000 calls/sec; so at 20000 calls/second expect the Value property to be +/- 34%. If you looking for something cheap to use to 'push-back' on overbearing clients this should suite most needs. If more accuracy is desired at higher volumes, specify the sampleFreq to scale the data samples under 1000/sec.

Syntax

Visual Basic (Declaration)
Public Class CallsPerSecondCounter
C#
public class CallsPerSecondCounter

Remarks

Yes you can build this with a Stopwatch.GetTimestamp() instead of DateTime.UtcNow; hoewever the Stopwatch API is 100x slower than using DateTime.UtcNow and although more precise, it generally does not provide significant gains in the sub 50k call range. Generally you can just increase sampleFreq to make up for the lack of precision in DateTime.UtcNow.

Inheritance Hierarchy

System.Object
CSharpTest.Net.Threading.CallsPerSecondCounter

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CallsPerSecondCounter Members
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/CallsPerSecondCounter.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
CallsPerSecondCounter Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : CallsPerSecondCounter Class

Glossary Item Box

The following tables list the members exposed by CallsPerSecondCounter.

Public Constructors

 | Name | Description
Public Constructor | CallsPerSecondCounter Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Value | Returns an estimated number of times per second the Increment() call is being used.
Top

Public Methods

 | Name | Description
Public Method | Increment | Called to increment the usage by 1.
Top

See Also

Reference

CallsPerSecondCounter Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/CallsPerSecondCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CallsPerSecondCounter Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > CallsPerSecondCounter Class : CallsPerSecondCounter Constructor

Glossary Item Box

Overload List

Overload | Description
CallsPerSecondCounter Constructor(Int32) | Creates a CallsPerSecondCounter with a specified sample size. A reasonable sample size is 100, although even as low as 25 will often yeild reasonable results. The higher the sample size, the longer it takes for Value to drop to zero, for a sample size of 100 the counter value will reach zero aprox 50 seconds after the last activity.
CallsPerSecondCounter Constructor(Int32,Int32) | Creates a CallsPerSecondCounter with a specified sample size and freqency of collection. A reasonable sample size is 100, although even as low as 25 will often yeild reasonable results. The higher the sample size, the longer it takes for Value to drop to zero, for a sample size of 100 the counter value will reach zero aprox 50 seconds after the last activity. The sampleFreq defines how often a sample is taken, for instance a value of 5 means to collect a sample only every 5th call to Increment() whereas a value of 1 will collect on every call. For high sampling rates this value can be increased to improve accuracy; however, it will also multiply the warm-up and cool-down time required for the Value property to move off of zero or move to zero.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CallsPerSecondCounter Class
CallsPerSecondCounter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
CallsPerSecondCounter Constructor(Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > CallsPerSecondCounter Class > CallsPerSecondCounter Constructor : CallsPerSecondCounter Constructor(Int32)

sampleSize

Glossary Item Box

Creates a CallsPerSecondCounter with a specified sample size. A reasonable sample size is 100, although even as low as 25 will often yeild reasonable results. The higher the sample size, the longer it takes for Value to drop to zero, for a sample size of 100 the counter value will reach zero aprox 50 seconds after the last activity.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal sampleSize As Integer _
)
C#
public CallsPerSecondCounter(
   int sampleSize
)

Parameters

sampleSize

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CallsPerSecondCounter Class
CallsPerSecondCounter Members
Overload List

Source Code

Library/Threading/CallsPerSecondCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CallsPerSecondCounter Constructor(Int32,Int32)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > CallsPerSecondCounter Class > CallsPerSecondCounter Constructor : CallsPerSecondCounter Constructor(Int32,Int32)

sampleSize
sampleFreq

Glossary Item Box

Creates a CallsPerSecondCounter with a specified sample size and freqency of collection. A reasonable sample size is 100, although even as low as 25 will often yeild reasonable results. The higher the sample size, the longer it takes for Value to drop to zero, for a sample size of 100 the counter value will reach zero aprox 50 seconds after the last activity. The sampleFreq defines how often a sample is taken, for instance a value of 5 means to collect a sample only every 5th call to Increment() whereas a value of 1 will collect on every call. For high sampling rates this value can be increased to improve accuracy; however, it will also multiply the warm-up and cool-down time required for the Value property to move off of zero or move to zero.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal sampleSize As Integer, _
   ByVal sampleFreq As Integer _
)
C#
public CallsPerSecondCounter(
   int sampleSize,
   int sampleFreq
)

Parameters

sampleSize
sampleFreq

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CallsPerSecondCounter Class
CallsPerSecondCounter Members
Overload List

Source Code

Library/Threading/CallsPerSecondCounter.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
CallsPerSecondCounter Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : CallsPerSecondCounter Class

Glossary Item Box

For a list of all members of this type, see CallsPerSecondCounter members.

Public Methods

 | Name | Description
Public Method | Increment | Called to increment the usage by 1.
Top

See Also

Reference

CallsPerSecondCounter Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/CallsPerSecondCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Increment Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > CallsPerSecondCounter Class : Increment Method

Glossary Item Box

Called to increment the usage by 1.

Syntax

Visual Basic (Declaration)
Public Sub Increment()
C#
public void Increment()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CallsPerSecondCounter Class
CallsPerSecondCounter Members

Source Code

Library/Threading/CallsPerSecondCounter.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
CallsPerSecondCounter Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : CallsPerSecondCounter Class

Glossary Item Box

For a list of all members of this type, see CallsPerSecondCounter members.

Public Properties

 | Name | Description
Public Property | Value | Returns an estimated number of times per second the Increment() call is being used.
Top

See Also

Reference

CallsPerSecondCounter Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/CallsPerSecondCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > CallsPerSecondCounter Class : Value Property

Glossary Item Box

Returns an estimated number of times per second the Increment() call is being used.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Value As Long
C#
public long Value {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CallsPerSecondCounter Class
CallsPerSecondCounter Members

Source Code

Library/Threading/CallsPerSecondCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UsageCounter Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : UsageCounter Class

Glossary Item Box

Provides a counter that fires a delegate on first usage and last release. For the counts to be maintained someone must hold an instance of one or more of these objects.

Syntax

Visual Basic (Declaration)
Public Class UsageCounter
C#
public class UsageCounter

Example

Library/Library.Test/TestUsageCounter.cs

C# Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
    Assert.AreEqual("some global name", counter.Name);
using (UsageCounter counter = new UsageCounter(@"{0}\Item-{1}", "Global", 1))
    Assert.AreEqual(@"Global\Item-1", counter.Name);
VB.NET Copy Code
Using counter As New UsageCounter("some global name")
    Assert.AreEqual("some global name", counter.Name)
End Using
Using counter As New UsageCounter("{0}\Item-{1}", "Global", 1)
    Assert.AreEqual("Global\Item-1", counter.Name)
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Threading.UsageCounter

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Members
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
UsageCounter Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : UsageCounter Class

Glossary Item Box

The following tables list the members exposed by UsageCounter.

Public Constructors

 | Name | Description
Public Constructor | UsageCounter Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | InstanceCount | Returns the number of times Increment() has been called on this instance
Public Property | Name | Returns the name specified when this instance was created
Top

Public Methods

 | Name | Description
Public Method | Decrement | Overloaded. Decrements the counter by one
Public Method | Dispose | Releases the resources but does not decrement counts
Public Method | Increment | Overloaded. Increments the counter by one
Public Method | TotalCount | Calls the provided delegate inside lock with the current count value
Top

See Also

Reference

UsageCounter Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UsageCounter Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class : UsageCounter Constructor

Glossary Item Box

Overload List

Overload | Description
UsageCounter Constructor(String,Object[]) | Creates a composite name with the format and arguments specified
UsageCounter Constructor(String) | The name used for the global object

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
UsageCounter Constructor(String,Object[])
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > UsageCounter Constructor : UsageCounter Constructor(String,Object[])

nameFormat
arguments

Glossary Item Box

Creates a composite name with the format and arguments specified

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal nameFormat As String, _
   ByVal ParamArray arguments() As Object _
)
C#
public UsageCounter(
   string nameFormat,
   params object[] arguments
)

Parameters

nameFormat
arguments

Example

Library/Library.Test/TestUsageCounter.cs

C# Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
    Assert.AreEqual("some global name", counter.Name);
using (UsageCounter counter = new UsageCounter(@"{0}\Item-{1}", "Global", 1))
    Assert.AreEqual(@"Global\Item-1", counter.Name);
VB.NET Copy Code
Using counter As New UsageCounter("some global name")
    Assert.AreEqual("some global name", counter.Name)
End Using
Using counter As New UsageCounter("{0}\Item-{1}", "Global", 1)
    Assert.AreEqual("Global\Item-1", counter.Name)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members
Overload List

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UsageCounter Constructor(String)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > UsageCounter Constructor : UsageCounter Constructor(String)

name

Glossary Item Box

The name used for the global object

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal name As String _
)
C#
public UsageCounter(
   string name
)

Parameters

name

Example

Library/Library.Test/TestUsageCounter.cs

C# Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
    Assert.AreEqual("some global name", counter.Name);
using (UsageCounter counter = new UsageCounter(@"{0}\Item-{1}", "Global", 1))
    Assert.AreEqual(@"Global\Item-1", counter.Name);
VB.NET Copy Code
Using counter As New UsageCounter("some global name")
    Assert.AreEqual("some global name", counter.Name)
End Using
Using counter As New UsageCounter("{0}\Item-{1}", "Global", 1)
    Assert.AreEqual("Global\Item-1", counter.Name)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members
Overload List

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
UsageCounter Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : UsageCounter Class

Glossary Item Box

For a list of all members of this type, see UsageCounter members.

Public Methods

 | Name | Description
Public Method | Decrement | Overloaded. Decrements the counter by one
Public Method | Dispose | Releases the resources but does not decrement counts
Public Method | Increment | Overloaded. Increments the counter by one
Public Method | TotalCount | Calls the provided delegate inside lock with the current count value
Top

See Also

Reference

UsageCounter Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrement Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class : Decrement Method

Glossary Item Box

Decrements the counter by one

Overload List

Overload | Description
Decrement() | Decrements the counter by one
Decrement<T>(Action<T>,T) | Delegate fired inside lock if the Decrement() count reaches zero
Decrement(ThreadStart) | Delegate fired inside lock if the Decrement() count reaches zero

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrement() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > Decrement Method : Decrement() Method

Glossary Item Box

Decrements the counter by one

Syntax

Visual Basic (Declaration)
Public Overloads Sub Decrement()
C#
public void Decrement()

Example

Library/Library.Test/TestUsageCounter.cs

C# Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
{
    Assert.AreEqual(0, counter.InstanceCount);
    counter.Increment();
    Assert.AreEqual(1, counter.InstanceCount);
    counter.Increment();
    Assert.AreEqual(2, counter.InstanceCount);
    using (UsageCounter copy = new UsageCounter("some global name"))
        Assert.AreEqual(0, copy.InstanceCount);
    counter.Decrement();
    Assert.AreEqual(1, counter.InstanceCount);
    counter.Decrement();
    Assert.AreEqual(0, counter.InstanceCount);
}
VB.NET Copy Code
Using counter As New UsageCounter("some global name")
    Assert.AreEqual(0, counter.InstanceCount)
    counter.Increment()
    Assert.AreEqual(1, counter.InstanceCount)
    counter.Increment()
    Assert.AreEqual(2, counter.InstanceCount)
    Using copy As New UsageCounter("some global name")
        Assert.AreEqual(0, copy.InstanceCount)
    End Using
    counter.Decrement()
    Assert.AreEqual(1, counter.InstanceCount)
    counter.Decrement()
    Assert.AreEqual(0, counter.InstanceCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members
Overload List

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Decrement<T>(Action<T>,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > Decrement Method : Decrement<T>(Action<T>,T) Method

e
arg

Glossary Item Box

Delegate fired inside lock if the Decrement() count reaches zero

Syntax

Visual Basic (Declaration)
Public Overloads Sub Decrement(Of T)( _
   ByVal e As Action(Of T), _
   ByVal arg As T _
)
C#
public void Decrement<T>(
   Action<T> e,
   T arg
)

Parameters

e
arg

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members
Overload List

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Decrement(ThreadStart) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > Decrement Method : Decrement(ThreadStart) Method

endUsage

Glossary Item Box

Delegate fired inside lock if the Decrement() count reaches zero

Syntax

Visual Basic (Declaration)
Public Overloads Sub Decrement( _
   ByVal endUsage As ThreadStart _
)
C#
public void Decrement(
   ThreadStart endUsage
)

Parameters

endUsage

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members
Overload List

Used By

UsageCounter.Decrement()
UsageCounter.Decrement(Action,T)

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class : Dispose Method

Glossary Item Box

Releases the resources but does not decrement counts

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Increment Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class : Increment Method

Glossary Item Box

Increments the counter by one

Overload List

Overload | Description
Increment() | Increments the counter by one
Increment<T>(Action<T>,T) | Delegate fired inside lock if this is the first Increment() call on the name provided
Increment(ThreadStart) | Delegate fired inside lock if this is the first Increment() call on the name provided

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Increment() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > Increment Method : Increment() Method

Glossary Item Box

Increments the counter by one

Syntax

Visual Basic (Declaration)
Public Overloads Sub Increment()
C#
public void Increment()

Example

Library/Library.Test/TestUsageCounter.cs

C# Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
{
    Assert.AreEqual(0, counter.InstanceCount);
    counter.Increment();
    Assert.AreEqual(1, counter.InstanceCount);
    counter.Increment();
    Assert.AreEqual(2, counter.InstanceCount);
    using (UsageCounter copy = new UsageCounter("some global name"))
        Assert.AreEqual(0, copy.InstanceCount);
    counter.Decrement();
    Assert.AreEqual(1, counter.InstanceCount);
    counter.Decrement();
    Assert.AreEqual(0, counter.InstanceCount);
}
VB.NET Copy Code
Using counter As New UsageCounter("some global name")
    Assert.AreEqual(0, counter.InstanceCount)
    counter.Increment()
    Assert.AreEqual(1, counter.InstanceCount)
    counter.Increment()
    Assert.AreEqual(2, counter.InstanceCount)
    Using copy As New UsageCounter("some global name")
        Assert.AreEqual(0, copy.InstanceCount)
    End Using
    counter.Decrement()
    Assert.AreEqual(1, counter.InstanceCount)
    counter.Decrement()
    Assert.AreEqual(0, counter.InstanceCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members
Overload List

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Increment<T>(Action<T>,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > Increment Method : Increment<T>(Action<T>,T) Method

e
arg

Glossary Item Box

Delegate fired inside lock if this is the first Increment() call on the name provided

Syntax

Visual Basic (Declaration)
Public Overloads Sub Increment(Of T)( _
   ByVal e As Action(Of T), _
   ByVal arg As T _
)
C#
public void Increment<T>(
   Action<T> e,
   T arg
)

Parameters

e
arg

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members
Overload List

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Increment(ThreadStart) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > Increment Method : Increment(ThreadStart) Method

beginUsage

Glossary Item Box

Delegate fired inside lock if this is the first Increment() call on the name provided

Syntax

Visual Basic (Declaration)
Public Overloads Sub Increment( _
   ByVal beginUsage As ThreadStart _
)
C#
public void Increment(
   ThreadStart beginUsage
)

Parameters

beginUsage

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members
Overload List

Used By

UsageCounter.Increment()
UsageCounter.Increment(Action,T)

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TotalCount Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class : TotalCount Method

action

Glossary Item Box

Calls the provided delegate inside lock with the current count value

Syntax

Visual Basic (Declaration)
Public Sub TotalCount( _
   ByVal action As Action(Of Integer) _
)
C#
public void TotalCount(
   Action<int> action
)

Parameters

action

Exceptions

Exception | Description
System.TimeoutException | The exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/TestUsageCounter.cs

C# Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
{
    using (UsageCounter counter2 = new UsageCounter("some global name"))
        counter2.Increment();
    counter.TotalCount(delegate(int count) { Assert.AreEqual(1, count); });

    using (UsageCounter counter2 = new UsageCounter("some global name"))
    {
        counter2.TotalCount(delegate(int count) { Assert.AreEqual(1, count); });
        counter2.Decrement();
    }
    counter.TotalCount(delegate(int count) { Assert.AreEqual(0, count); });
}
VB.NET Copy Code
Using counter As New UsageCounter("some global name")
    Using counter2 As New UsageCounter("some global name")
        counter2.Increment()
    End Using
    counter.TotalCount(Function(count As Integer) Do
        Assert.AreEqual(1, count)
    End Function)

    Using counter2 As New UsageCounter("some global name")
        counter2.TotalCount(Function(count As Integer) Do
            Assert.AreEqual(1, count)
        End Function)
        counter2.Decrement()
    End Using
    counter.TotalCount(Function(count As Integer) Do
        Assert.AreEqual(0, count)
    End Function)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
UsageCounter Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : UsageCounter Class

Glossary Item Box

For a list of all members of this type, see UsageCounter members.

Public Properties

 | Name | Description
Public Property | InstanceCount | Returns the number of times Increment() has been called on this instance
Public Property | Name | Returns the name specified when this instance was created
Top

See Also

Reference

UsageCounter Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
InstanceCount Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class : InstanceCount Property

Glossary Item Box

Returns the number of times Increment() has been called on this instance

Syntax

Visual Basic (Declaration)
Public ReadOnly Property InstanceCount As Integer
C#
public int InstanceCount {get;}

Example

Library/Library.Test/TestUsageCounter.cs

C# Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
{
    Assert.AreEqual(0, counter.InstanceCount);
    counter.Increment();
    Assert.AreEqual(1, counter.InstanceCount);
    counter.Increment();
    Assert.AreEqual(2, counter.InstanceCount);
    using (UsageCounter copy = new UsageCounter("some global name"))
        Assert.AreEqual(0, copy.InstanceCount);
    counter.Decrement();
    Assert.AreEqual(1, counter.InstanceCount);
    counter.Decrement();
    Assert.AreEqual(0, counter.InstanceCount);
}
VB.NET Copy Code
Using counter As New UsageCounter("some global name")
    Assert.AreEqual(0, counter.InstanceCount)
    counter.Increment()
    Assert.AreEqual(1, counter.InstanceCount)
    counter.Increment()
    Assert.AreEqual(2, counter.InstanceCount)
    Using copy As New UsageCounter("some global name")
        Assert.AreEqual(0, copy.InstanceCount)
    End Using
    counter.Decrement()
    Assert.AreEqual(1, counter.InstanceCount)
    counter.Decrement()
    Assert.AreEqual(0, counter.InstanceCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class : Name Property

Glossary Item Box

Returns the name specified when this instance was created

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Name As String
C#
public string Name {get;}

Example

Library/Library.Test/TestUsageCounter.cs

C# Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
    Assert.AreEqual("some global name", counter.Name);
using (UsageCounter counter = new UsageCounter(@"{0}\Item-{1}", "Global", 1))
    Assert.AreEqual(@"Global\Item-1", counter.Name);
VB.NET Copy Code
Using counter As New UsageCounter("some global name")
    Assert.AreEqual("some global name", counter.Name)
End Using
Using counter As New UsageCounter("{0}\Item-{1}", "Global", 1)
    Assert.AreEqual("Global\Item-1", counter.Name)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UsageCounter Class
UsageCounter Members

Source Code

Library/Threading/UsageCounter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitAndContinueList Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueList Class

Glossary Item Box

Represents a set of queued IWorkAndContinue items that can be processed

Syntax

Visual Basic (Declaration)
Public Class WaitAndContinueList
C#
public class WaitAndContinueList

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
WaitAndContinueList work = new WaitAndContinueList();
SampleWork item = new SampleWork();

Assert.IsFalse(item.Disposed);
work.AddWork(item);

Assert.IsFalse(work.PerformWork(0));
item.Dispose();

Assert.IsFalse(work.PerformWork(0));

item.Completed = true;//Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0));

Assert.IsTrue(work.IsEmpty);
Assert.IsTrue(item.Disposed);
VB.NET Copy Code
Dim work As New WaitAndContinueList()
Dim item As New SampleWork()

Assert.IsFalse(item.Disposed)
work.AddWork(item)

Assert.IsFalse(work.PerformWork(0))
item.Dispose()

Assert.IsFalse(work.PerformWork(0))

item.Completed = True
'Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0))

Assert.IsTrue(work.IsEmpty)
Assert.IsTrue(item.Disposed)

Inheritance Hierarchy

System.Object
CSharpTest.Net.Threading.WaitAndContinueList

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Members
CSharpTest.Net.Threading Namespace
WaitAndContinueWorker.AddWork(WaitAndContinueList)

Source Code

Library/Threading/WaitAndContinueList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
WaitAndContinueList Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueList Class

Glossary Item Box

The following tables list the members exposed by WaitAndContinueList.

Public Constructors

 | Name | Description
Public Constructor | WaitAndContinueList Constructor | Constructs an empty WaitAndContinueList
Top

Public Properties

 | Name | Description
Public Property | Count | Returns the number of work queue items
Public Property | IsEmpty | Returns true if the work queue is empty
Top

Public Methods

 | Name | Description
Public Method | AddWork | Overloaded. Adds a unit of work to the list
Public Method | Dispose | Disposes of the list and all it's contents
Public Method | PerformWork | Overloaded. Returns true if a unit of work was processed within the timeout, or false if the timeout expired prior to a unit of work completion.
Top

See Also

Reference

WaitAndContinueList Class
CSharpTest.Net.Threading Namespace
WaitAndContinueWorker.AddWork(WaitAndContinueList)

Source Code

Library/Threading/WaitAndContinueList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitAndContinueList Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class : WaitAndContinueList Constructor

Glossary Item Box

Constructs an empty WaitAndContinueList

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public WaitAndContinueList()

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
WaitAndContinueList work = new WaitAndContinueList();
SampleWork item = new SampleWork();

Assert.IsFalse(item.Disposed);
work.AddWork(item);

Assert.IsFalse(work.PerformWork(0));
item.Dispose();

Assert.IsFalse(work.PerformWork(0));

item.Completed = true;//Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0));

Assert.IsTrue(work.IsEmpty);
Assert.IsTrue(item.Disposed);
VB.NET Copy Code
Dim work As New WaitAndContinueList()
Dim item As New SampleWork()

Assert.IsFalse(item.Disposed)
work.AddWork(item)

Assert.IsFalse(work.PerformWork(0))
item.Dispose()

Assert.IsFalse(work.PerformWork(0))

item.Completed = True
'Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0))

Assert.IsTrue(work.IsEmpty)
Assert.IsTrue(item.Disposed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members

Source Code

Library/Threading/WaitAndContinueList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
WaitAndContinueList Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueList Class

Glossary Item Box

For a list of all members of this type, see WaitAndContinueList members.

Public Methods

 | Name | Description
Public Method | AddWork | Overloaded. Adds a unit of work to the list
Public Method | Dispose | Disposes of the list and all it's contents
Public Method | PerformWork | Overloaded. Returns true if a unit of work was processed within the timeout, or false if the timeout expired prior to a unit of work completion.
Top

See Also

Reference

WaitAndContinueList Class
CSharpTest.Net.Threading Namespace
WaitAndContinueWorker.AddWork(WaitAndContinueList)

Source Code

Library/Threading/WaitAndContinueList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddWork Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class : AddWork Method

Glossary Item Box

Adds a unit of work to the list

Overload List

Overload | Description
AddWork(IWaitAndContinue) | Adds a unit of work to the list
AddWork(WaitAndContinueList) | Moves the work in the other list into this list

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddWork(IWaitAndContinue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class > AddWork Method : AddWork(IWaitAndContinue) Method

item

Glossary Item Box

Adds a unit of work to the list

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddWork( _
   ByVal item As IWaitAndContinue _
)
C#
public void AddWork(
   IWaitAndContinue item
)

Parameters

item

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
WaitAndContinueList work = new WaitAndContinueList();
SampleWork item = new SampleWork();

Assert.IsFalse(item.Disposed);
work.AddWork(item);

Assert.IsFalse(work.PerformWork(0));
item.Dispose();

Assert.IsFalse(work.PerformWork(0));

item.Completed = true;//Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0));

Assert.IsTrue(work.IsEmpty);
Assert.IsTrue(item.Disposed);
VB.NET Copy Code
Dim work As New WaitAndContinueList()
Dim item As New SampleWork()

Assert.IsFalse(item.Disposed)
work.AddWork(item)

Assert.IsFalse(work.PerformWork(0))
item.Dispose()

Assert.IsFalse(work.PerformWork(0))

item.Completed = True
'Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0))

Assert.IsTrue(work.IsEmpty)
Assert.IsTrue(item.Disposed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members
Overload List
IWaitAndContinue

Source Code

Library/Threading/WaitAndContinueList.cs

Used By

WaitAndContinueWorker.AddWork(IWaitAndContinue)


%%PageItemTitle%%

[image]
CSharpTest.Net
AddWork(WaitAndContinueList) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class > AddWork Method : AddWork(WaitAndContinueList) Method

other

Glossary Item Box

Moves the work in the other list into this list

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddWork( _
   ByVal other As WaitAndContinueList _
)
C#
public void AddWork(
   WaitAndContinueList other
)

Parameters

other

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members
Overload List

Source Code

Library/Threading/WaitAndContinueList.cs

Used By

WaitAndContinueWorker.AddWork(WaitAndContinueList)


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class : Dispose Method

Glossary Item Box

Disposes of the list and all it's contents

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members

Source Code

Library/Threading/WaitAndContinueList.cs

Used By

Boolean WaitAndContinueWorker.Complete(Boolean,Int32)
WaitAndContinueWorker.Abort()


%%PageItemTitle%%

[image]
CSharpTest.Net
PerformWork Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class : PerformWork Method

Glossary Item Box

Returns true if a unit of work was processed within the timeout, or false if the timeout expired prior to a unit of work completion.

Overload List

Overload | Description
PerformWork(Int32) | Returns true if a unit of work was processed within the timeout, or false if the timeout expired prior to a unit of work completion.
PerformWork(Int32,IWaitAndContinue) | Returns true if a unit of work was processed within the timeout, or false if the timeout expired prior to a unit of work completion. itemProcessed will be set to the instance of the item process when the result is true.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
PerformWork(Int32) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class > PerformWork Method : PerformWork(Int32) Method

timeout

Glossary Item Box

Returns true if a unit of work was processed within the timeout, or false if the timeout expired prior to a unit of work completion.

Syntax

Visual Basic (Declaration)
Public Overloads Function PerformWork( _
   ByVal timeout As Integer _
) As Boolean
C#
public bool PerformWork(
   int timeout
)

Parameters

timeout

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
WaitAndContinueList work = new WaitAndContinueList();
SampleWork item = new SampleWork();

Assert.IsFalse(item.Disposed);
work.AddWork(item);

Assert.IsFalse(work.PerformWork(0));
item.Dispose();

Assert.IsFalse(work.PerformWork(0));

item.Completed = true;//Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0));

Assert.IsTrue(work.IsEmpty);
Assert.IsTrue(item.Disposed);
VB.NET Copy Code
Dim work As New WaitAndContinueList()
Dim item As New SampleWork()

Assert.IsFalse(item.Disposed)
work.AddWork(item)

Assert.IsFalse(work.PerformWork(0))
item.Dispose()

Assert.IsFalse(work.PerformWork(0))

item.Completed = True
'Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0))

Assert.IsTrue(work.IsEmpty)
Assert.IsTrue(item.Disposed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members
Overload List

Source Code

Library/Threading/WaitAndContinueList.cs

Used By

Boolean WaitAndContinueWorker.Complete(Boolean,Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
PerformWork(Int32,IWaitAndContinue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class > PerformWork Method : PerformWork(Int32,IWaitAndContinue) Method

timeout
itemProcessed

Glossary Item Box

Returns true if a unit of work was processed within the timeout, or false if the timeout expired prior to a unit of work completion. itemProcessed will be set to the instance of the item process when the result is true.

Syntax

Visual Basic (Declaration)
Public Overloads Function PerformWork( _
   ByVal timeout As Integer, _
   ByRef itemProcessed As IWaitAndContinue _
) As Boolean
C#
public bool PerformWork(
   int timeout,
   out IWaitAndContinue itemProcessed
)

Parameters

timeout
itemProcessed

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
WaitAndContinueList work = new WaitAndContinueList();
SampleWork item1, item2;
IWaitAndContinue signaled;

work.AddWork(item1 = new SampleWork());
work.AddWork(item2 = new SampleWork());

Assert.AreEqual(2, work.Count);
Assert.IsFalse(work.IsEmpty);

//normally done as a loop: while(work.Perform(timeout)) { }
Assert.IsFalse(work.PerformWork(1));
item2.Ready.Set();
Assert.IsTrue(work.PerformWork(0));
Assert.IsTrue(item2.Completed);
Assert.IsTrue(item2.Disposed);

Assert.IsFalse(work.PerformWork(1));
item1.Cancel.Set();
Assert.IsTrue(work.PerformWork(0, out signaled));
Assert.IsTrue(ReferenceEquals(signaled, item1));
Assert.IsTrue(item1.Completed);
Assert.IsTrue(item1.Cancelled);
Assert.IsTrue(item1.Disposed);

Assert.IsTrue(work.IsEmpty);
Assert.AreEqual(0, work.Count);
Assert.IsFalse(work.PerformWork(1));
VB.NET Copy Code
Dim work As New WaitAndContinueList()
Dim item1 As SampleWork, item2 As SampleWork
Dim signaled As IWaitAndContinue

work.AddWork(item1 = New SampleWork())
work.AddWork(item2 = New SampleWork())

Assert.AreEqual(2, work.Count)
Assert.IsFalse(work.IsEmpty)

'normally done as a loop: while(work.Perform(timeout)) { }
Assert.IsFalse(work.PerformWork(1))
item2.Ready.[Set]()
Assert.IsTrue(work.PerformWork(0))
Assert.IsTrue(item2.Completed)
Assert.IsTrue(item2.Disposed)

Assert.IsFalse(work.PerformWork(1))
item1.Cancel.[Set]()
Assert.IsTrue(work.PerformWork(0, signaled))
Assert.IsTrue(ReferenceEquals(signaled, item1))
Assert.IsTrue(item1.Completed)
Assert.IsTrue(item1.Cancelled)
Assert.IsTrue(item1.Disposed)

Assert.IsTrue(work.IsEmpty)
Assert.AreEqual(0, work.Count)
Assert.IsFalse(work.PerformWork(1))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members
Overload List
IWaitAndContinue

Used By

Boolean WaitAndContinueList.PerformWork(Int32)

Source Code

Library/Threading/WaitAndContinueList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
WaitAndContinueList Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueList Class

Glossary Item Box

For a list of all members of this type, see WaitAndContinueList members.

Public Properties

 | Name | Description
Public Property | Count | Returns the number of work queue items
Public Property | IsEmpty | Returns true if the work queue is empty
Top

See Also

Reference

WaitAndContinueList Class
CSharpTest.Net.Threading Namespace
WaitAndContinueWorker.AddWork(WaitAndContinueList)

Source Code

Library/Threading/WaitAndContinueList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class : Count Property

Glossary Item Box

Returns the number of work queue items

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
WaitAndContinueList work = new WaitAndContinueList();
SampleWork item1, item2;
IWaitAndContinue signaled;

work.AddWork(item1 = new SampleWork());
work.AddWork(item2 = new SampleWork());

Assert.AreEqual(2, work.Count);
Assert.IsFalse(work.IsEmpty);

//normally done as a loop: while(work.Perform(timeout)) { }
Assert.IsFalse(work.PerformWork(1));
item2.Ready.Set();
Assert.IsTrue(work.PerformWork(0));
Assert.IsTrue(item2.Completed);
Assert.IsTrue(item2.Disposed);

Assert.IsFalse(work.PerformWork(1));
item1.Cancel.Set();
Assert.IsTrue(work.PerformWork(0, out signaled));
Assert.IsTrue(ReferenceEquals(signaled, item1));
Assert.IsTrue(item1.Completed);
Assert.IsTrue(item1.Cancelled);
Assert.IsTrue(item1.Disposed);

Assert.IsTrue(work.IsEmpty);
Assert.AreEqual(0, work.Count);
Assert.IsFalse(work.PerformWork(1));
VB.NET Copy Code
Dim work As New WaitAndContinueList()
Dim item1 As SampleWork, item2 As SampleWork
Dim signaled As IWaitAndContinue

work.AddWork(item1 = New SampleWork())
work.AddWork(item2 = New SampleWork())

Assert.AreEqual(2, work.Count)
Assert.IsFalse(work.IsEmpty)

'normally done as a loop: while(work.Perform(timeout)) { }
Assert.IsFalse(work.PerformWork(1))
item2.Ready.[Set]()
Assert.IsTrue(work.PerformWork(0))
Assert.IsTrue(item2.Completed)
Assert.IsTrue(item2.Disposed)

Assert.IsFalse(work.PerformWork(1))
item1.Cancel.[Set]()
Assert.IsTrue(work.PerformWork(0, signaled))
Assert.IsTrue(ReferenceEquals(signaled, item1))
Assert.IsTrue(item1.Completed)
Assert.IsTrue(item1.Cancelled)
Assert.IsTrue(item1.Disposed)

Assert.IsTrue(work.IsEmpty)
Assert.AreEqual(0, work.Count)
Assert.IsFalse(work.PerformWork(1))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members

Source Code

Library/Threading/WaitAndContinueList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsEmpty Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class : IsEmpty Property

Glossary Item Box

Returns true if the work queue is empty

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsEmpty As Boolean
C#
public bool IsEmpty {get;}

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
WaitAndContinueList work = new WaitAndContinueList();
SampleWork item = new SampleWork();

Assert.IsFalse(item.Disposed);
work.AddWork(item);

Assert.IsFalse(work.PerformWork(0));
item.Dispose();

Assert.IsFalse(work.PerformWork(0));

item.Completed = true;//Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0));

Assert.IsTrue(work.IsEmpty);
Assert.IsTrue(item.Disposed);
VB.NET Copy Code
Dim work As New WaitAndContinueList()
Dim item As New SampleWork()

Assert.IsFalse(item.Disposed)
work.AddWork(item)

Assert.IsFalse(work.PerformWork(0))
item.Dispose()

Assert.IsFalse(work.PerformWork(0))

item.Completed = True
'Normally this would be set in the Dispose method of the WorkItem, but we are testing
Assert.IsFalse(work.PerformWork(0))

Assert.IsTrue(work.IsEmpty)
Assert.IsTrue(item.Disposed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueList Class
WaitAndContinueList Members

Source Code

Library/Threading/WaitAndContinueList.cs

Used By

Boolean WaitAndContinueWorker.Complete(Boolean,Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitAndContinueWorker Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueWorker Class

Glossary Item Box

Represents a single worker thread that processes IWaitAndContinue work items

Syntax

Visual Basic (Declaration)
Public Class WaitAndContinueWorker
C#
public class WaitAndContinueWorker

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
    SampleWork item = new SampleWork();
    item.WorkThrows = true;
    work.AddWork(item);

    ManualResetEvent mreError = new ManualResetEvent(false);
    Exception error = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { error = e.GetException(); mreError.Set(); };

    item.Ready.Set();
    Assert.IsTrue(mreError.WaitOne(1000, false));
    Assert.IsTrue(error is ArgumentOutOfRangeException);
    Assert.IsTrue(((ArgumentOutOfRangeException)error).ParamName == "WorkThrows");
}
VB.NET Copy Code
Using work As New WaitAndContinueWorker()
    Dim item As New SampleWork()
    item.WorkThrows = True
    work.AddWork(item)

    Dim mreError As New ManualResetEvent(False)
    Dim [error] As Exception = Nothing
    work.OnError += Function(o As Object, e As ErrorEventArgs) Do
        [error] = e.GetException()
        mreError.[Set]()
    End Function

    item.Ready.[Set]()
    Assert.IsTrue(mreError.WaitOne(1000, False))
    Assert.IsTrue(TypeOf [error] Is ArgumentOutOfRangeException)
    Assert.IsTrue((DirectCast([error], ArgumentOutOfRangeException)).ParamName = "WorkThrows")
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Threading.WaitAndContinueWorker

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Members
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
WaitAndContinueWorker Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueWorker Class

Glossary Item Box

The following tables list the members exposed by WaitAndContinueWorker.

Public Constructors

 | Name | Description
Public Constructor | WaitAndContinueWorker Constructor | Constructs a thread to process IWaitAndContinue work items
Top

Public Properties

 | Name | Description
Public Property | IsEmpty | Returns true if the work queue is empty
Top

Public Methods

 | Name | Description
Public Method | Abort | Terminates all work by aborting the worker thread even if work is in progress
Public Method | AddWork | Overloaded. Adds a unit of work to the list
Public Method | Complete | Exits the worker thread and, if complete is true, waits for the remaining tasks to complete
Public Method | Dispose | Disposes of the worker thread and all pending work
Top

Public Events

 | Name | Description
Public Event | OnError | Raised when an uncaught exception is thrown while processing the work queue
Top

See Also

Reference

WaitAndContinueWorker Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitAndContinueWorker Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class : WaitAndContinueWorker Constructor

Glossary Item Box

Constructs a thread to process IWaitAndContinue work items

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public WaitAndContinueWorker()

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
    SampleWork item = new SampleWork();
    item.WorkThrows = true;
    work.AddWork(item);

    ManualResetEvent mreError = new ManualResetEvent(false);
    Exception error = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { error = e.GetException(); mreError.Set(); };

    item.Ready.Set();
    Assert.IsTrue(mreError.WaitOne(1000, false));
    Assert.IsTrue(error is ArgumentOutOfRangeException);
    Assert.IsTrue(((ArgumentOutOfRangeException)error).ParamName == "WorkThrows");
}
VB.NET Copy Code
Using work As New WaitAndContinueWorker()
    Dim item As New SampleWork()
    item.WorkThrows = True
    work.AddWork(item)

    Dim mreError As New ManualResetEvent(False)
    Dim [error] As Exception = Nothing
    work.OnError += Function(o As Object, e As ErrorEventArgs) Do
        [error] = e.GetException()
        mreError.[Set]()
    End Function

    item.Ready.[Set]()
    Assert.IsTrue(mreError.WaitOne(1000, False))
    Assert.IsTrue(TypeOf [error] Is ArgumentOutOfRangeException)
    Assert.IsTrue((DirectCast([error], ArgumentOutOfRangeException)).ParamName = "WorkThrows")
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members

Used By

IpcEventChannel.EnableAsyncSend()

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
WaitAndContinueWorker Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueWorker Class

Glossary Item Box

For a list of all members of this type, see WaitAndContinueWorker members.

Public Methods

 | Name | Description
Public Method | Abort | Terminates all work by aborting the worker thread even if work is in progress
Public Method | AddWork | Overloaded. Adds a unit of work to the list
Public Method | Complete | Exits the worker thread and, if complete is true, waits for the remaining tasks to complete
Public Method | Dispose | Disposes of the worker thread and all pending work
Top

See Also

Reference

WaitAndContinueWorker Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Abort Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class : Abort Method

Glossary Item Box

Terminates all work by aborting the worker thread even if work is in progress

Syntax

Visual Basic (Declaration)
Public Sub Abort()
C#
public void Abort()

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
    work.OnError += delegate(object o, ErrorEventArgs e) { throw new Exception("Failed.", e.GetException()); };

    SampleWork item = new SampleWork();
    item.SleepForever = true;
    work.AddWork(item);

    item.Ready.Set();
    Assert.IsTrue(item.Sleeping.WaitOne(1000, false));
    work.Abort();

    Assert.IsFalse(item.Completed);
    Assert.IsTrue(item.Disposed);
}
VB.NET Copy Code
Using work As New WaitAndContinueWorker()
    work.OnError += Function(o As Object, e As ErrorEventArgs) Do
        Throw New Exception("Failed.", e.GetException())
    End Function

    Dim item As New SampleWork()
    item.SleepForever = True
    work.AddWork(item)

    item.Ready.[Set]()
    Assert.IsTrue(item.Sleeping.WaitOne(1000, False))
    work.Abort()

    Assert.IsFalse(item.Completed)
    Assert.IsTrue(item.Disposed)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddWork Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class : AddWork Method

Glossary Item Box

Adds a unit of work to the list

Overload List

Overload | Description
AddWork(IWaitAndContinue) | Adds a unit of work to the list
AddWork(WaitAndContinueList) | Adds a unit of work to the list

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddWork(IWaitAndContinue) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class > AddWork Method : AddWork(IWaitAndContinue) Method

item

Glossary Item Box

Adds a unit of work to the list

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddWork( _
   ByVal item As IWaitAndContinue _
)
C#
public void AddWork(
   IWaitAndContinue item
)

Parameters

item

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
    SampleWork item = new SampleWork();
    item.WorkThrows = true;
    work.AddWork(item);

    ManualResetEvent mreError = new ManualResetEvent(false);
    Exception error = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { error = e.GetException(); mreError.Set(); };

    item.Ready.Set();
    Assert.IsTrue(mreError.WaitOne(1000, false));
    Assert.IsTrue(error is ArgumentOutOfRangeException);
    Assert.IsTrue(((ArgumentOutOfRangeException)error).ParamName == "WorkThrows");
}
VB.NET Copy Code
Using work As New WaitAndContinueWorker()
    Dim item As New SampleWork()
    item.WorkThrows = True
    work.AddWork(item)

    Dim mreError As New ManualResetEvent(False)
    Dim [error] As Exception = Nothing
    work.OnError += Function(o As Object, e As ErrorEventArgs) Do
        [error] = e.GetException()
        mreError.[Set]()
    End Function

    item.Ready.[Set]()
    Assert.IsTrue(mreError.WaitOne(1000, False))
    Assert.IsTrue(TypeOf [error] Is ArgumentOutOfRangeException)
    Assert.IsTrue((DirectCast([error], ArgumentOutOfRangeException)).ParamName = "WorkThrows")
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members
Overload List
IWaitAndContinue

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddWork(WaitAndContinueList) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class > AddWork Method : AddWork(WaitAndContinueList) Method

list

Glossary Item Box

Adds a unit of work to the list

Syntax

Visual Basic (Declaration)
Public Overloads Sub AddWork( _
   ByVal list As WaitAndContinueList _
)
C#
public void AddWork(
   WaitAndContinueList list
)

Parameters

list

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members
Overload List
WaitAndContinueList

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Complete Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class : Complete Method

complete
timeout

Glossary Item Box

Exits the worker thread and, if complete is true, waits for the remaining tasks to complete

Syntax

Visual Basic (Declaration)
Public Function Complete( _
   ByVal complete As Boolean, _
   ByVal timeout As Integer _
) As Boolean
C#
public bool Complete(
   bool complete,
   int timeout
)

Parameters

complete
timeout

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
    work.OnError += delegate(object o, ErrorEventArgs e) { throw new Exception("Failed.", e.GetException()); };

    SampleWork item = new SampleWork();
    work.AddWork(item);

    Assert.IsFalse(work.IsEmpty);
    work.Complete(true, 10);

    Assert.IsFalse(item.Completed);
    Assert.IsTrue(item.Disposed);
}
VB.NET Copy Code
Using work As New WaitAndContinueWorker()
    work.OnError += Function(o As Object, e As ErrorEventArgs) Do
        Throw New Exception("Failed.", e.GetException())
    End Function

    Dim item As New SampleWork()
    work.AddWork(item)

    Assert.IsFalse(work.IsEmpty)
    work.Complete(True, 10)

    Assert.IsFalse(item.Completed)
    Assert.IsTrue(item.Disposed)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members

Used By

IpcEventChannel.StopAsyncSending(Boolean,Int32)
WaitAndContinueWorker.Dispose()

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class : Dispose Method

Glossary Item Box

Disposes of the worker thread and all pending work

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members

Used By

IpcEventChannel.Dispose()

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
WaitAndContinueWorker Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueWorker Class

Glossary Item Box

For a list of all members of this type, see WaitAndContinueWorker members.

Public Properties

 | Name | Description
Public Property | IsEmpty | Returns true if the work queue is empty
Top

See Also

Reference

WaitAndContinueWorker Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsEmpty Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class : IsEmpty Property

Glossary Item Box

Returns true if the work queue is empty

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsEmpty As Boolean
C#
public bool IsEmpty {get;}

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
    work.OnError += delegate(object o, ErrorEventArgs e) { throw new Exception("Failed.", e.GetException()); };

    SampleWork item = new SampleWork();
    work.AddWork(item);

    Assert.IsFalse(work.IsEmpty);
    work.Abort();

    Assert.IsFalse(item.Completed);
    Assert.IsTrue(item.Disposed);
}
VB.NET Copy Code
Using work As New WaitAndContinueWorker()
    work.OnError += Function(o As Object, e As ErrorEventArgs) Do
        Throw New Exception("Failed.", e.GetException())
    End Function

    Dim item As New SampleWork()
    work.AddWork(item)

    Assert.IsFalse(work.IsEmpty)
    work.Abort()

    Assert.IsFalse(item.Completed)
    Assert.IsTrue(item.Disposed)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
WaitAndContinueWorker Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WaitAndContinueWorker Class

Glossary Item Box

For a list of all members of this type, see WaitAndContinueWorker members.

Public Events

 | Name | Description
Public Event | OnError | Raised when an uncaught exception is thrown while processing the work queue
Top

See Also

Reference

WaitAndContinueWorker Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnError Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueWorker Class : OnError Event

Glossary Item Box

Raised when an uncaught exception is thrown while processing the work queue

Syntax

Visual Basic (Declaration)
Public Event OnError As ErrorEventHandler
C#
public event ErrorEventHandler OnError

Example

Library/Library.Test/TestWaitAndContinue.cs

C# Copy Code
using (WaitAndContinueWorker work = new WaitAndContinueWorker())
{
    SampleWork item = new SampleWork();
    item.WorkThrows = true;
    work.AddWork(item);

    ManualResetEvent mreError = new ManualResetEvent(false);
    Exception error = null;
    work.OnError += delegate(object o, ErrorEventArgs e) { error = e.GetException(); mreError.Set(); };

    item.Ready.Set();
    Assert.IsTrue(mreError.WaitOne(1000, false));
    Assert.IsTrue(error is ArgumentOutOfRangeException);
    Assert.IsTrue(((ArgumentOutOfRangeException)error).ParamName == "WorkThrows");
}
VB.NET Copy Code
Using work As New WaitAndContinueWorker()
    Dim item As New SampleWork()
    item.WorkThrows = True
    work.AddWork(item)

    Dim mreError As New ManualResetEvent(False)
    Dim [error] As Exception = Nothing
    work.OnError += Function(o As Object, e As ErrorEventArgs) Do
        [error] = e.GetException()
        mreError.[Set]()
    End Function

    item.Ready.[Set]()
    Assert.IsTrue(mreError.WaitOne(1000, False))
    Assert.IsTrue(TypeOf [error] Is ArgumentOutOfRangeException)
    Assert.IsTrue((DirectCast([error], ArgumentOutOfRangeException)).ParamName = "WorkThrows")
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WaitAndContinueWorker Class
WaitAndContinueWorker Members

Source Code

Library/Threading/WaitAndContinueWorker.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WorkQueue Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WorkQueue Class

Glossary Item Box

An extremely basic WorkQueue using a fixed number of threads to execute Action() or Action<T> delegates

Syntax

Visual Basic (Declaration)
Public Class WorkQueue
   Inherits CSharpTest.Net.Threading.WorkQueue(Of Action)
   Implements CSharpTest.Net.Threading.IWorkQueue(Of Action)
C#
public class WorkQueue : CSharpTest.Net.Threading.WorkQueue<Action>, CSharpTest.Net.Threading.IWorkQueue<Action>

Example

Library/Library.Test/TestWorkQueue.cs

C# Copy Code
using (ManualResetEvent finished = new ManualResetEvent(false))
using (WorkQueue worker = new WorkQueue(2))
{
    worker.Enqueue(delegate() { finished.Set(); });
    Assert.IsTrue(finished.WaitOne(100, false));
}
VB.NET Copy Code
Using finished As New ManualResetEvent(False)
    Using worker As New WorkQueue(2)
        worker.Enqueue(Function() Do
            finished.[Set]()
        End Function)
        Assert.IsTrue(finished.WaitOne(100, False))
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.Threading.WorkQueue<T>
CSharpTest.Net.Threading.WorkQueue

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue Members
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
WorkQueue Class Members
See Also Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WorkQueue Class

Glossary Item Box

The following tables list the members exposed by WorkQueue.

Public Constructors

 | Name | Description
Public Constructor | WorkQueue Constructor | Constructs the Work Queue with the specified number of threads.
Top

Public Methods

 | Name | Description
Public Method | Complete | Waits for all executing tasks to complete and then exists all threads, If completePending is false no more tasks will begin, if true threads will continue to pick up tasks and run until the queue is empty. The timeout period is used to join each thread in turn, if the timeout expires that thread will be aborted. (Inherited from CSharpTest.Net.Threading.WorkQueue<Action>)
Public Method | Enqueue | Overloaded. Enqueues a task with a parameter of type T
Top

Public Events

 | Name | Description
Public Event | OnError | Raised when a task fails to handle an error (Inherited from CSharpTest.Net.Threading.WorkQueue<Action>)
Top

See Also

Reference

WorkQueue Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WorkQueue Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WorkQueue Class : WorkQueue Constructor

nThreads

Glossary Item Box

Constructs the Work Queue with the specified number of threads.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal nThreads As Integer _
)
C#
public WorkQueue(
   int nThreads
)

Parameters

nThreads

Example

Library/Library.Test/TestWorkQueue.cs

C# Copy Code
using (ManualResetEvent finished = new ManualResetEvent(false))
using (WorkQueue worker = new WorkQueue(2))
{
    worker.Enqueue(delegate() { finished.Set(); });
    Assert.IsTrue(finished.WaitOne(100, false));
}
VB.NET Copy Code
Using finished As New ManualResetEvent(False)
    Using worker As New WorkQueue(2)
        worker.Enqueue(Function() Do
            finished.[Set]()
        End Function)
        Assert.IsTrue(finished.WaitOne(100, False))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue Class
WorkQueue Members

Used By

ThreadedBTreeTest.TestAtomicUpdate()
ThreadedBTreeTest.TestErrorsOnInsertAndDelete()
ThreadedBTreeTest.TestConcurrentCreateReadUpdateDelete8000()
Boolean SecureTransfer.Client.Upload(String,Int64,Stream)

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
WorkQueue Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WorkQueue Class

Glossary Item Box

For a list of all members of this type, see WorkQueue members.

Public Methods

 | Name | Description
Public Method | Complete | Waits for all executing tasks to complete and then exists all threads, If completePending is false no more tasks will begin, if true threads will continue to pick up tasks and run until the queue is empty. The timeout period is used to join each thread in turn, if the timeout expires that thread will be aborted. (Inherited from CSharpTest.Net.Threading.WorkQueue<Action>)
Public Method | Enqueue | Overloaded. Enqueues a task with a parameter of type T
Top

See Also

Reference

WorkQueue Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Enqueue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WorkQueue Class : Enqueue Method

Glossary Item Box

Enqueues a task with a parameter of type T

Overload List

Overload | Description
Enqueue<T>(Action<T>,T) | Enqueues a task with a parameter of type T
Enqueue | Enqueues a task (Inherited from CSharpTest.Net.Threading.WorkQueue<Action>)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue Class
WorkQueue Members


%%PageItemTitle%%

T
[image]
CSharpTest.Net
Enqueue<T>(Action<T>,T) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WorkQueue Class > Enqueue Method : Enqueue<T>(Action<T>,T) Method

process
instance

Glossary Item Box

Enqueues a task with a parameter of type T

Syntax

Visual Basic (Declaration)
Public Overloads Sub Enqueue(Of T)( _
   ByVal process As Action(Of T), _
   ByVal instance As T _
)
C#
public void Enqueue<T>(
   Action<T> process,
   T instance
)

Parameters

process
instance

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue Class
WorkQueue Members
Overload List

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
WorkQueue<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WorkQueue<T> Class

Glossary Item Box

An extremely basic WorkQueue using a fixed number of threads to execute Action<T> over the enqueued instances of type T, aggregates an instance of WorkQueue()

Syntax

Visual Basic (Declaration)
Public Class WorkQueue(Of T)
   Implements IWorkQueue(Of T)
C#
public class WorkQueue<T> : IWorkQueue<T>

Type Parameters

T

Example

Library/Library.Test/TestWorkQueue.cs

C# Copy Code
int[] counter = new int[1];
using (WorkQueue<int[]> worker = new WorkQueue<int[]>(ProcessOne, Math.Max(2, Environment.ProcessorCount)))
{
    for (int i = 0; i < 1000; i++)
        worker.Enqueue(counter);
    worker.Complete(false, 10);
}
Assert.AreNotEqual(0, counter[0]);
VB.NET Copy Code
Dim counter As Integer() = New Integer(1) {}
Using worker As New WorkQueue(Of Integer())(ProcessOne, Math.Max(2, Environment.ProcessorCount))
    Dim i As Integer = 0
    While i < 1000
        worker.Enqueue(counter)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    worker.Complete(False, 10)
End Using
Assert.AreNotEqual(0, counter(0))

Inheritance Hierarchy

System.Object
CSharpTest.Net.Threading.WorkQueue<T>
CSharpTest.Net.Threading.WorkQueue

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue<T> Members
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
WorkQueue<T> Class Members
See Also Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WorkQueue<T> Class

Glossary Item Box

The following tables list the members exposed by WorkQueue<T>.

Public Constructors

 | Name | Description
Public Constructor | WorkQueue<T> Constructor | Constructs the Work Queue with the specified number of threads.
Top

Public Methods

 | Name | Description
Public Method | Complete | Waits for all executing tasks to complete and then exists all threads, If completePending is false no more tasks will begin, if true threads will continue to pick up tasks and run until the queue is empty. The timeout period is used to join each thread in turn, if the timeout expires that thread will be aborted.
Public Method | Enqueue | Enqueues a task
Top

Public Events

 | Name | Description
Public Event | OnError | Raised when a task fails to handle an error
Top

See Also

Reference

WorkQueue<T> Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WorkQueue<T> Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WorkQueue<T> Class : WorkQueue<T> Constructor

process
nThreads

Glossary Item Box

Constructs the Work Queue with the specified number of threads.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal process As Action(Of T), _
   ByVal nThreads As Integer _
)
C#
public WorkQueue<T>(
   Action<T> process,
   int nThreads
)

Parameters

process
nThreads

Example

Library/Library.Test/TestWorkQueue.cs

C# Copy Code
int[] counter = new int[1];
using (WorkQueue<int[]> worker = new WorkQueue<int[]>(ProcessOne, Math.Max(2, Environment.ProcessorCount)))
{
    for (int i = 0; i < 1000; i++)
        worker.Enqueue(counter);
    worker.Complete(false, 10);
}
Assert.AreNotEqual(0, counter[0]);
VB.NET Copy Code
Dim counter As Integer() = New Integer(1) {}
Using worker As New WorkQueue(Of Integer())(ProcessOne, Math.Max(2, Environment.ProcessorCount))
    Dim i As Integer = 0
    While i < 1000
        worker.Enqueue(counter)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    worker.Complete(False, 10)
End Using
Assert.AreNotEqual(0, counter(0))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue<T> Class
WorkQueue<T> Members

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
WorkQueue<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WorkQueue<T> Class

Glossary Item Box

For a list of all members of this type, see WorkQueue<T> members.

Public Methods

 | Name | Description
Public Method | Complete | Waits for all executing tasks to complete and then exists all threads, If completePending is false no more tasks will begin, if true threads will continue to pick up tasks and run until the queue is empty. The timeout period is used to join each thread in turn, if the timeout expires that thread will be aborted.
Public Method | Enqueue | Enqueues a task
Top

See Also

Reference

WorkQueue<T> Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Complete Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WorkQueue<T> Class : Complete Method

completePending
True to complete enqueued activities
timeout
The timeout to wait for a thread before Abort() is called

Glossary Item Box

Waits for all executing tasks to complete and then exists all threads, If completePending is false no more tasks will begin, if true threads will continue to pick up tasks and run until the queue is empty. The timeout period is used to join each thread in turn, if the timeout expires that thread will be aborted.

Syntax

Visual Basic (Declaration)
Public Function Complete( _
   ByVal completePending As Boolean, _
   ByVal timeout As Integer _
) As Boolean
C#
public bool Complete(
   bool completePending,
   int timeout
)

Parameters

completePending
True to complete enqueued activities
timeout
The timeout to wait for a thread before Abort() is called

Exceptions

Exception | Description
System.ApplicationException | The exception that is thrown when a non-fatal application error occurs.

Example

Library/Library.Test/TestWorkQueue.cs

C# Copy Code
int[] counter = new int[1];
using (WorkQueue<int[]> worker = new WorkQueue<int[]>(ProcessOne, Math.Max(2, Environment.ProcessorCount)))
{
    for (int i = 0; i < 1000; i++)
        worker.Enqueue(counter);
    worker.Complete(false, 10);
}
Assert.AreNotEqual(0, counter[0]);
VB.NET Copy Code
Dim counter As Integer() = New Integer(1) {}
Using worker As New WorkQueue(Of Integer())(ProcessOne, Math.Max(2, Environment.ProcessorCount))
    Dim i As Integer = 0
    While i < 1000
        worker.Enqueue(counter)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    worker.Complete(False, 10)
End Using
Assert.AreNotEqual(0, counter(0))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue<T> Class
WorkQueue<T> Members

Used By

ThreadedBTreeTest.TestAtomicUpdate()
ThreadedBTreeTest.TestErrorsOnInsertAndDelete()
ThreadedBTreeTest.TestConcurrentCreateReadUpdateDelete8000()
Boolean SecureTransfer.Client.Upload(String,Int64,Stream)

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Enqueue Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WorkQueue<T> Class : Enqueue Method

instance

Glossary Item Box

Enqueues a task

Syntax

Visual Basic (Declaration)
Public Sub Enqueue( _
   ByVal instance As T _
)
C#
public void Enqueue(
   T instance
)

Parameters

instance

Exceptions

Exception | Description
System.ObjectDisposedException | The exception that is thrown when an operation is performed on a disposed object.

Example

Library/Library.Test/TestWorkQueue.cs

C# Copy Code
int[] counter = new int[1];
using (WorkQueue<int[]> worker = new WorkQueue<int[]>(ProcessOne, Math.Max(2, Environment.ProcessorCount)))
{
    for (int i = 0; i < 1000; i++)
        worker.Enqueue(counter);
    worker.Complete(false, 10);
}
Assert.AreNotEqual(0, counter[0]);
VB.NET Copy Code
Dim counter As Integer() = New Integer(1) {}
Using worker As New WorkQueue(Of Integer())(ProcessOne, Math.Max(2, Environment.ProcessorCount))
    Dim i As Integer = 0
    While i < 1000
        worker.Enqueue(counter)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    worker.Complete(False, 10)
End Using
Assert.AreNotEqual(0, counter(0))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue<T> Class
WorkQueue<T> Members

Used By

ThreadedBTreeTest.TestErrorsOnInsertAndDelete()
ThreadedBTreeTest.TestConcurrentCreateReadUpdateDelete8000()
Boolean SecureTransfer.Client.Upload(String,Int64,Stream)
WorkQueue.Enqueue(Action,T)

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
WorkQueue<T> Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WorkQueue<T> Class

Glossary Item Box

For a list of all members of this type, see WorkQueue<T> members.

Public Events

 | Name | Description
Public Event | OnError | Raised when a task fails to handle an error
Top

See Also

Reference

WorkQueue<T> Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnError Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WorkQueue<T> Class : OnError Event

Glossary Item Box

Raised when a task fails to handle an error

Syntax

Visual Basic (Declaration)
Public Event OnError As ErrorEventHandler
C#
public event ErrorEventHandler OnError

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C# Copy Code
using (TempFile temp = new TempFile())
using (ManualResetEvent stop = new ManualResetEvent(false))
using (TempFile copy = new TempFile())
using (TransactedCompoundFile test = new TransactedCompoundFile(
    new TransactedCompoundFile.Options(temp.TempPath) {BlockSize = 512, CreateNew = true}))
using (WorkQueue workers = new WorkQueue(5))
{
    bool failed = false;
    workers.OnError += (o, e) => failed = true;
    for(int i=0; i < 5; i++)
        workers.Enqueue(() => ExersizeFile(stop, test));

    do
    {
        System.Threading.Thread.Sleep(1000);
        test.Commit();
        File.Copy(temp.TempPath, copy.TempPath, true);
        Assert.AreEqual(0, copy.Length%512);
        int hcount = (int)(copy.Length/512);

        using (TransactedCompoundFile verify = new TransactedCompoundFile(
            new TransactedCompoundFile.Options(copy.TempPath) {BlockSize = 512, CreateNew = false}))
        {
            OrdinalList free = new OrdinalList();
            free.Ceiling = hcount;
            for(int i=0; i < hcount; i++)
            {
                uint h = verify.Create();
                free.Add((int)h);
                if (h >= hcount)
                    break;
            }

            int verifiedCount = 0;
            OrdinalList used = free.Invert(hcount);
            foreach (uint h in used)
            {
                // skip reserved offsets.
                if (h % (512 / 4) == 0 || (h + 1) % (512 / 4) == 0)
                    continue;

                IOStream.ReadAllBytes(verify.Read(h));
                verifiedCount++;
            }
            System.Diagnostics.Trace.WriteLine("Verified handle count: " + verifiedCount);
        }

    } while (!failed && System.Diagnostics.Debugger.IsAttached);

    stop.Set();
    workers.Complete(false, 1000);
    Assert.IsFalse(failed);
}
VB.NET Copy Code
Using temp As New TempFile()
    Using [stop] As New ManualResetEvent(False)
        Using copy As New TempFile()
            Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
                Key .BlockSize = 512, _
                Key .CreateNew = True _
            })
                Using workers As New WorkQueue(5)
                    Dim failed As Boolean = False
                    workers.OnError += Function(o, e) failed = True
                    Dim i As Integer = 0
                    While i < 5
                        workers.Enqueue(Function() ExersizeFile([stop], test))
                        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                    End While

                    Do
                        System.Threading.Thread.Sleep(1000)
                        test.Commit()
                        File.Copy(temp.TempPath, copy.TempPath, True)
                        Assert.AreEqual(0, copy.Length Mod 512)
                        Dim hcount As Integer = DirectCast((copy.Length / 512), Integer)

                        Using verify As New TransactedCompoundFile(New TransactedCompoundFile.Options(copy.TempPath) With { _
                            Key .BlockSize = 512, _
                            Key .CreateNew = False _
                        })
                            Dim free As New OrdinalList()
                            free.Ceiling = hcount
                            Dim i As Integer = 0
                            While i < hcount
                                Dim h As UInteger = verify.Create()
                                free.Add(DirectCast(h, Integer))
                                If h >= hcount Then
                                    Exit While
                                End If
                                System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
                            End While

                            Dim verifiedCount As Integer = 0
                            Dim used As OrdinalList = free.Invert(hcount)
                            For Each h As UInteger In used
                                ' skip reserved offsets.
                                If h Mod (512 / 4) = 0 OrElse (h + 1) Mod (512 / 4) = 0 Then
                                    Continue For
                                End If

                                IOStream.ReadAllBytes(verify.Read(h))
                                System.Math.Max(System.Threading.Interlocked.Increment(verifiedCount),verifiedCount - 1)
                            Next
                            System.Diagnostics.Trace.WriteLine("Verified handle count: " + verifiedCount)

                        End Using
                    Loop While Not failed AndAlso System.Diagnostics.Debugger.IsAttached

                    [stop].[Set]()
                    workers.Complete(False, 1000)
                    Assert.IsFalse(failed)
                End Using
            End Using
        End Using
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue<T> Class
WorkQueue<T> Members

Used By

ThreadedBTreeTest.TestErrorsOnInsertAndDelete()
ThreadedBTreeTest.TestConcurrentCreateReadUpdateDelete8000()
Boolean SecureTransfer.Client.Upload(String,Int64,Stream)

Source Code

Library/Threading/WorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IWaitAndContinue Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : IWaitAndContinue Interface

Glossary Item Box

Describes a set of WaitHandles that, when signaled, trigger a process to continue

Syntax

Visual Basic (Declaration)
Public Interface IWaitAndContinue
C#
public interface IWaitAndContinue

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWaitAndContinue Members
CSharpTest.Net.Threading Namespace
WaitAndContinueList.AddWork(IWaitAndContinue)
Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)
WaitAndContinueWorker.AddWork(IWaitAndContinue)

Source Code

Library/Threading/IWaitAndContinue.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IWaitAndContinue Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : IWaitAndContinue Interface

Glossary Item Box

The following tables list the members exposed by IWaitAndContinue.

Public Properties

 | Name | Description
Property | Completed | Returns true when the task is complete, this value may change between calls; however, the HandleCount can not change except inside a call to ContinueProcessing.
Property | HandleCount | Returns the number of handles that will be copied when CopyHandles is called, this value is invariant except inside a call to ContinueProcessing. Must not return 0 unless Completed is also true.
Top

Public Methods

 | Name | Description
Method | ContinueProcessing | Called after one of the wait handles is signaled, providing the wait handle that was signaled. For a Mutex, this may also occur when AbandonedMutexException is raised.
Method | CopyHandles | Copies the wait handles that will signal that this object is ready to continue processing
Top

See Also

Reference

IWaitAndContinue Interface
CSharpTest.Net.Threading Namespace
WaitAndContinueList.AddWork(IWaitAndContinue)
Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)
WaitAndContinueWorker.AddWork(IWaitAndContinue)

Source Code

Library/Threading/IWaitAndContinue.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IWaitAndContinue Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : IWaitAndContinue Interface

Glossary Item Box

For a list of all members of this type, see IWaitAndContinue members.

Public Methods

 | Name | Description
Method | ContinueProcessing | Called after one of the wait handles is signaled, providing the wait handle that was signaled. For a Mutex, this may also occur when AbandonedMutexException is raised.
Method | CopyHandles | Copies the wait handles that will signal that this object is ready to continue processing
Top

See Also

Reference

IWaitAndContinue Interface
CSharpTest.Net.Threading Namespace
WaitAndContinueList.AddWork(IWaitAndContinue)
Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)
WaitAndContinueWorker.AddWork(IWaitAndContinue)

Source Code

Library/Threading/IWaitAndContinue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ContinueProcessing Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > IWaitAndContinue Interface : ContinueProcessing Method

handleSignaled

Glossary Item Box

Called after one of the wait handles is signaled, providing the wait handle that was signaled. For a Mutex, this may also occur when AbandonedMutexException is raised.

Syntax

Visual Basic (Declaration)
Sub ContinueProcessing( _
   ByVal handleSignaled As WaitHandle _
)
C#
void ContinueProcessing(
   WaitHandle handleSignaled
)

Parameters

handleSignaled

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWaitAndContinue Interface
IWaitAndContinue Members

Source Code

Library/Threading/IWaitAndContinue.cs

Used By

Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)


%%PageItemTitle%%

[image]
CSharpTest.Net
CopyHandles Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > IWaitAndContinue Interface : CopyHandles Method

array
offset

Glossary Item Box

Copies the wait handles that will signal that this object is ready to continue processing

Syntax

Visual Basic (Declaration)
Sub CopyHandles( _
   ByVal array() As WaitHandle, _
   ByVal offset As Integer _
)
C#
void CopyHandles(
   WaitHandle[] array,
   int offset
)

Parameters

array
offset

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWaitAndContinue Interface
IWaitAndContinue Members

Source Code

Library/Threading/IWaitAndContinue.cs

Used By

Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IWaitAndContinue Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : IWaitAndContinue Interface

Glossary Item Box

For a list of all members of this type, see IWaitAndContinue members.

Public Properties

 | Name | Description
Property | Completed | Returns true when the task is complete, this value may change between calls; however, the HandleCount can not change except inside a call to ContinueProcessing.
Property | HandleCount | Returns the number of handles that will be copied when CopyHandles is called, this value is invariant except inside a call to ContinueProcessing. Must not return 0 unless Completed is also true.
Top

See Also

Reference

IWaitAndContinue Interface
CSharpTest.Net.Threading Namespace
WaitAndContinueList.AddWork(IWaitAndContinue)
Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)
WaitAndContinueWorker.AddWork(IWaitAndContinue)

Source Code

Library/Threading/IWaitAndContinue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Completed Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > IWaitAndContinue Interface : Completed Property

Glossary Item Box

Returns true when the task is complete, this value may change between calls; however, the HandleCount can not change except inside a call to ContinueProcessing.

Syntax

Visual Basic (Declaration)
ReadOnly Property Completed As Boolean
C#
bool Completed {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWaitAndContinue Interface
IWaitAndContinue Members

Source Code

Library/Threading/IWaitAndContinue.cs

Used By

WaitAndContinueList.AddWork(IWaitAndContinue)
Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)


%%PageItemTitle%%

[image]
CSharpTest.Net
HandleCount Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > IWaitAndContinue Interface : HandleCount Property

Glossary Item Box

Returns the number of handles that will be copied when CopyHandles is called, this value is invariant except inside a call to ContinueProcessing. Must not return 0 unless Completed is also true.

Syntax

Visual Basic (Declaration)
ReadOnly Property HandleCount As Integer
C#
int HandleCount {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWaitAndContinue Interface
IWaitAndContinue Members

Source Code

Library/Threading/IWaitAndContinue.cs

Used By

Boolean WaitAndContinueList.PerformWork(Int32,IWaitAndContinue)


%%PageItemTitle%%

T
[image]
CSharpTest.Net
IWorkQueue<T> Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : IWorkQueue<T> Interface

Glossary Item Box

Provides an interface for a simple WorkQueue

Syntax

Visual Basic (Declaration)
Public Interface IWorkQueue(Of T)
C#
public interface IWorkQueue<T>

Type Parameters

T

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWorkQueue<T> Members
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/IWorkQueue.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IWorkQueue<T> Interface Members
See Also Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : IWorkQueue<T> Interface

Glossary Item Box

The following tables list the members exposed by IWorkQueue<T>.

Public Methods

 | Name | Description
Method | Complete | Waits for all queued tasks to complete and then exists all threads
Method | Enqueue | Enqueues a task
Top

Public Events

 | Name | Description
Event | OnError | Raised when a task fails to handle an error
Top

See Also

Reference

IWorkQueue<T> Interface
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/IWorkQueue.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IWorkQueue<T> Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : IWorkQueue<T> Interface

Glossary Item Box

For a list of all members of this type, see IWorkQueue<T> members.

Public Methods

 | Name | Description
Method | Complete | Waits for all queued tasks to complete and then exists all threads
Method | Enqueue | Enqueues a task
Top

See Also

Reference

IWorkQueue<T> Interface
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/IWorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Complete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > IWorkQueue<T> Interface : Complete Method

completePending
timeout

Glossary Item Box

Waits for all queued tasks to complete and then exists all threads

Syntax

Visual Basic (Declaration)
Function Complete( _
   ByVal completePending As Boolean, _
   ByVal timeout As Integer _
) As Boolean
C#
bool Complete(
   bool completePending,
   int timeout
)

Parameters

completePending
timeout

Return Value

Returns true if all pending tasks were completed before the timeout expired.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWorkQueue<T> Interface
IWorkQueue<T> Members

Source Code

Library/Threading/IWorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Enqueue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > IWorkQueue<T> Interface : Enqueue Method

instance

Glossary Item Box

Enqueues a task

Syntax

Visual Basic (Declaration)
Sub Enqueue( _
   ByVal instance As T _
)
C#
void Enqueue(
   T instance
)

Parameters

instance

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWorkQueue<T> Interface
IWorkQueue<T> Members

Source Code

Library/Threading/IWorkQueue.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
IWorkQueue<T> Interface Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : IWorkQueue<T> Interface

Glossary Item Box

For a list of all members of this type, see IWorkQueue<T> members.

Public Events

 | Name | Description
Event | OnError | Raised when a task fails to handle an error
Top

See Also

Reference

IWorkQueue<T> Interface
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/IWorkQueue.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnError Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > IWorkQueue<T> Interface : OnError Event

Glossary Item Box

Raised when a task fails to handle an error

Syntax

Visual Basic (Declaration)
Event OnError As ErrorEventHandler
C#
event ErrorEventHandler OnError

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IWorkQueue<T> Interface
IWorkQueue<T> Members

Source Code

Library/Threading/IWorkQueue.cs


%%ItemTitle%%

CSharpTest.Net.Utils Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Utils Namespace

Glossary Item Box

Classes

 | Class | Description
Class | ArgumentList | This is a private class as the means of sharing is to simply include the source file not reference a library.
Class | ArgumentList.Item | This is a single named argument within an argument list collection, this can be implicitly assigned to a string, or a string[] array
Class | FileList | A utility class for gathering files
Class | FileList.FileFoundEventArgs | Event args passed to the FileFound event
Class | FileUtils | Provides utilities related to files and file paths
Class | ObjectKeepAlive | Provides a means of forcing the garbage collector to wait on objects aquired from permanent storage while only holding WeakReference's of the object. Essentially uses a simple lockless algorithm to track the most recently loaded objects so that they will stay alive longer.
Class | ProcessInfo | Utility class for obtaining information about the currently running process and AppDomain
Class | RegexPatterns | A collection of common regular expression patterns
Class | StringConverter | Handles the conversion of data to and from strings for serialization. Can alternatly be configured to provide other transforms for display or other outputs.
Class | StringUtils | Various routines for string manipulations
Class | WeakReference<T> | A strong-typed derivation of the WeakReference class
Class | XmlConfiguration<T> | This is basically a big hack on the whole configuration system, it's purpose is to avoid the entire thing. Where argument T is any [XmlSerializable] object this class can deserialize it from the configuration file. It looks for an xsd either embeded into typeof(T).Assembly or in the local filesystem. The Xsd must be named typeof(T).FullName + ".xsd" to be found by this class. If found validation will occur durring the deserialization process and an exception of type XmlException() will be raised on errors. Optionally, you can directly set the schema via the static XmlSchema property.

Interfaces

 | Interface | Description
Interface | IObjectKeepAlive | Provides an interface for tracking a limited number of references to objects for use in a WeakReference cache.

Delegates

 | Delegate | Description
Delegate | StringConverter.TryParseMethod<TYPE> | The delegate type used to try and parse a string

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentList Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ArgumentList Class

Glossary Item Box

This is a private class as the means of sharing is to simply include the source file not reference a library.

Object Model

ArgumentList ClassArgumentList.Item Class

Syntax

Visual Basic (Declaration)
Public Class ArgumentList
   Inherits System.Collections.ObjectModel.KeyedCollection(Of String,ArgumentList.Item)
C#
public class ArgumentList : System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>

Inheritance Hierarchy

System.Object
System.Collections.ObjectModel.Collection<T>
System.Collections.ObjectModel.KeyedCollection<TKey,TItem>
CSharpTest.Net.Utils.ArgumentList

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Members
CSharpTest.Net.Utils Namespace

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ArgumentList Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ArgumentList Class

Glossary Item Box

The following tables list the members exposed by ArgumentList.

Public Constructors

 | Name | Description
Public Constructor | ArgumentList Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Comparer | Gets the generic equality comparer that is used to determine equality of keys in the collection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Public Property | Count | Gets the number of elements actually contained in the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
static (Shared in Visual Basic) | DefaultComparison | Controls the default string comparer used for this class
Public Property | Item | Overloaded. Gets the element with the specified key. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Public Property | Keys | A string collection of all keys in the arguments
static (Shared in Visual Basic) | NameDelimeters | Controls the allowable delimeter characters seperate argument names from values
static (Shared in Visual Basic) | PrefixChars | Controls the allowable prefix characters that will preceed named arguments
Public Property | Unnamed | Returns a list of arguments that did not start with a character in the PrefixChars static collection. These arguments can be modified by the methods on the returned collection, or you set this property to a new collection (a copy is made).
Top

Protected Properties

 | Name | Description
Protected Property | Dictionary | Gets the lookup dictionary of the KeyedCollection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Protected Property | Items | Gets a IList wrapper around the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Top

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds a name/value pair to the collection of arguments, if value is null the name is added with no values.
Public Method | AddRange | Parses the strings provided for switch names and optionally values, by default in one of the following forms: "/name=value", "/name:value", "-name=value", "-name:value"
Public Method | Clear | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Public Method | Contains | Overloaded. Determines whether an element is in the Collection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Public Method | CopyTo | Copies the entire Collection to a compatible one-dimensional System.Array, starting at the specified index of the target array. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
static (Shared in Visual Basic) | EscapeArguments | The 'more' correct escape/join for arguments
Public Method | GetEnumerator | Returns an enumerator that iterates through the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Public Method | IndexOf | Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Public Method | Insert | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
static (Shared in Visual Basic) | Parse | Parses the individual arguments from the given input string.
static (Shared in Visual Basic) | Remove | Overloaded. Searches the arguments until it finds a switch or value by the name in find and if found it will: A) Remove the item from the arguments B) Set the out parameter value to any value found, or null if just '/name' C) Returns true that it was found and removed.
Public Method | RemoveAt | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Public Method | SafeGet | Returns an Item of name even if it does not exist
Public Method | TryGetValue | Overloaded. Returns true if the value was found by that name and set the output value
static (Shared in Visual Basic) | TryParseNameValue | Attempts to parse a name value pair from '/name=value' format
Top

Protected Methods

 | Name | Description
Protected Method | ChangeItemKey | Changes the key associated with the specified element in the lookup dictionary. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Protected Method | ClearItems | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Protected Method | GetKeyForItem | Overridden. Abract override for extracting key
Protected Method | InsertItem | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Protected Method | RemoveItem | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Protected Method | SetItem | Replaces the element at the specified index. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Top

See Also

Reference

ArgumentList Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentList Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : ArgumentList Constructor

Glossary Item Box

Overload List

Overload | Description
ArgumentList Constructor(String[]) | Initializes a new instance of the ArgumentList class using the argument list provided
ArgumentList Constructor(StringComparer,String[]) | Initializes a new instance of the ArgumentList class using the argument list provided and using the string comparer provided, by default this is case-insensitive

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentList Constructor(String[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class > ArgumentList Constructor : ArgumentList Constructor(String[])

arguments

Glossary Item Box

Initializes a new instance of the ArgumentList class using the argument list provided

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray arguments() As String _
)
C#
public ArgumentList(
   params string[] arguments
)

Parameters

arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members
Overload List

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentList Constructor(StringComparer,String[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class > ArgumentList Constructor : ArgumentList Constructor(StringComparer,String[])

comparer
arguments

Glossary Item Box

Initializes a new instance of the ArgumentList class using the argument list provided and using the string comparer provided, by default this is case-insensitive

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal comparer As StringComparer, _
   ByVal ParamArray arguments() As String _
)
C#
public ArgumentList(
   StringComparer comparer,
   params string[] arguments
)

Parameters

comparer
arguments

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members
Overload List

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ArgumentList Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ArgumentList Class

Glossary Item Box

For a list of all members of this type, see ArgumentList members.

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds a name/value pair to the collection of arguments, if value is null the name is added with no values.
Public Method | AddRange | Parses the strings provided for switch names and optionally values, by default in one of the following forms: "/name=value", "/name:value", "-name=value", "-name:value"
Public Method | Clear | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Public Method | Contains | Overloaded. Determines whether an element is in the Collection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Public Method | CopyTo | Copies the entire Collection to a compatible one-dimensional System.Array, starting at the specified index of the target array. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
static (Shared in Visual Basic) | EscapeArguments | The 'more' correct escape/join for arguments
Public Method | GetEnumerator | Returns an enumerator that iterates through the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Public Method | IndexOf | Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Public Method | Insert | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
static (Shared in Visual Basic) | Parse | Parses the individual arguments from the given input string.
static (Shared in Visual Basic) | Remove | Overloaded. Searches the arguments until it finds a switch or value by the name in find and if found it will: A) Remove the item from the arguments B) Set the out parameter value to any value found, or null if just '/name' C) Returns true that it was found and removed.
Public Method | RemoveAt | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Public Method | SafeGet | Returns an Item of name even if it does not exist
Public Method | TryGetValue | Overloaded. Returns true if the value was found by that name and set the output value
static (Shared in Visual Basic) | TryParseNameValue | Attempts to parse a name value pair from '/name=value' format
Top

Protected Methods

 | Name | Description
Protected Method | ChangeItemKey | Changes the key associated with the specified element in the lookup dictionary. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Protected Method | ClearItems | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Protected Method | GetKeyForItem | Overridden. Abract override for extracting key
Protected Method | InsertItem | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Protected Method | RemoveItem | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Protected Method | SetItem | Replaces the element at the specified index. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Top

See Also

Reference

ArgumentList Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : Add Method

Glossary Item Box

Adds a name/value pair to the collection of arguments, if value is null the name is added with no values.

Overload List

Overload | Description
Add(String,String) | Adds a name/value pair to the collection of arguments, if value is null the name is added with no values.
Add(Item) | Adds an object to the end of the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class > Add Method : Add(String,String) Method

name
value

Glossary Item Box

Adds a name/value pair to the collection of arguments, if value is null the name is added with no values.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal name As String, _
   ByVal value As String _
)
C#
public void Add(
   string name,
   string value
)

Parameters

name
value

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members
Overload List

Used By

ArgumentList.AddRange(String[])

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : AddRange Method

arguments

Glossary Item Box

Parses the strings provided for switch names and optionally values, by default in one of the following forms: "/name=value", "/name:value", "-name=value", "-name:value"

Syntax

Visual Basic (Declaration)
Public Sub AddRange( _
   ByVal ParamArray arguments() As String _
)
C#
public void AddRange(
   params string[] arguments
)

Parameters

arguments

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EscapeArguments Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : EscapeArguments Method

args

Glossary Item Box

The 'more' correct escape/join for arguments

Syntax

Visual Basic (Declaration)
Public Shared Function EscapeArguments( _
   ByVal ParamArray args() As String _
) As String
C#
public static string EscapeArguments(
   params string[] args
)

Parameters

args

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Source Code

Shared/ArgumentList.cs

Used By

ServiceCommands.Installation.InstallService(String,String,ServiceStartMode,ServiceAccount,String,String[],ICommandInterpreter,String)
String ProcessRunner.ToString()
SvcControlManager.SetServiceExeArgs(String,String[])
SvcControlManager SvcControlManager.Create(String,String,Boolean,ServiceStartMode,String,String[],String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
GetKeyForItem Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : GetKeyForItem Method

item

Glossary Item Box

Abract override for extracting key

Syntax

Visual Basic (Declaration)
Protected Overrides Function GetKeyForItem( _
   ByVal item As ArgumentList.Item _
) As String
C#
protected override string GetKeyForItem(
   ArgumentList.Item item
)

Parameters

item

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members
Base Implementation in GetKeyForItem


%%PageItemTitle%%

[image]
CSharpTest.Net
Parse Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : Parse Method

rawtext

Glossary Item Box

Parses the individual arguments from the given input string.

Syntax

Visual Basic (Declaration)
Public Shared Function Parse( _
   ByVal rawtext As String _
) As String()
C#
public static string[] Parse(
   string rawtext
)

Parameters

rawtext

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Source Code

Shared/ArgumentList.cs

Used By

CommandInterpreter.Run(TextReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : Remove Method

Glossary Item Box

Searches the arguments until it finds a switch or value by the name in find and if found it will: A) Remove the item from the arguments B) Set the out parameter value to any value found, or null if just '/name' C) Returns true that it was found and removed.

Overload List

Overload | Description
Remove(String[],String,String) | Searches the arguments until it finds a switch or value by the name in find and if found it will: A) Remove the item from the arguments B) Set the out parameter value to any value found, or null if just '/name' C) Returns true that it was found and removed.
Remove(String) | (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Remove(Item) | Removes the first occurrence of a specific object from the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove(String[],String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class > Remove Method : Remove(String[],String,String) Method

arguments
find
value

Glossary Item Box

Searches the arguments until it finds a switch or value by the name in find and if found it will: A) Remove the item from the arguments B) Set the out parameter value to any value found, or null if just '/name' C) Returns true that it was found and removed.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Remove( _
   ByRef arguments As String(), _
   ByVal find As String, _
   ByRef value As String _
) As Boolean
C#
public static bool Remove(
   ref string[] arguments,
   string find,
   out string value
)

Parameters

arguments
find
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members
Overload List

Source Code

Shared/ArgumentList.cs

Used By

ServiceCommands.RunAsService(ICommandInterpreter,String,String[])


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeGet Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : SafeGet Method

name

Glossary Item Box

Returns an Item of name even if it does not exist

Syntax

Visual Basic (Declaration)
Public Function SafeGet( _
   ByVal name As String _
) As ArgumentList.Item
C#
public ArgumentList.Item SafeGet(
   string name
)

Parameters

name

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members
ArgumentList.Item

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : TryGetValue Method

Glossary Item Box

Returns true if the value was found by that name and set the output value

Overload List

Overload | Description
TryGetValue(String,Item) | Returns true if the value was found by that name and set the output value
TryGetValue(String,String) | Returns true if the value was found by that name and set the output value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,Item) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class > TryGetValue Method : TryGetValue(String,Item) Method

name
value

Glossary Item Box

Returns true if the value was found by that name and set the output value

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As ArgumentList.Item _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out ArgumentList.Item value
)

Parameters

name
value

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members
Overload List
ArgumentList.Item

Used By

ArgumentList.Add(String,String)
ArgumentList.Item ArgumentList.SafeGet(String)

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetValue(String,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class > TryGetValue Method : TryGetValue(String,String) Method

name
value

Glossary Item Box

Returns true if the value was found by that name and set the output value

Syntax

Visual Basic (Declaration)
Public Overloads Function TryGetValue( _
   ByVal name As String, _
   ByRef value As String _
) As Boolean
C#
public bool TryGetValue(
   string name,
   out string value
)

Parameters

name
value

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members
Overload List

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryParseNameValue Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : TryParseNameValue Method

argument
name
value

Glossary Item Box

Attempts to parse a name value pair from '/name=value' format

Syntax

Visual Basic (Declaration)
Public Shared Function TryParseNameValue( _
   ByVal argument As String, _
   ByRef name As String, _
   ByRef value As String _
) As Boolean
C#
public static bool TryParseNameValue(
   string argument,
   out string name,
   out string value
)

Parameters

argument
name
value

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Used By

ArgumentList.AddRange(String[])
Boolean ArgumentList.Remove(String[],String,String)

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ArgumentList Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ArgumentList Class

Glossary Item Box

For a list of all members of this type, see ArgumentList members.

Public Properties

 | Name | Description
Public Property | Comparer | Gets the generic equality comparer that is used to determine equality of keys in the collection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Public Property | Count | Gets the number of elements actually contained in the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
static (Shared in Visual Basic) | DefaultComparison | Controls the default string comparer used for this class
Public Property | Item | Overloaded. Gets the element with the specified key. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Public Property | Keys | A string collection of all keys in the arguments
static (Shared in Visual Basic) | NameDelimeters | Controls the allowable delimeter characters seperate argument names from values
static (Shared in Visual Basic) | PrefixChars | Controls the allowable prefix characters that will preceed named arguments
Public Property | Unnamed | Returns a list of arguments that did not start with a character in the PrefixChars static collection. These arguments can be modified by the methods on the returned collection, or you set this property to a new collection (a copy is made).
Top

Protected Properties

 | Name | Description
Protected Property | Dictionary | Gets the lookup dictionary of the KeyedCollection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,ArgumentList.Item>)
Protected Property | Items | Gets a IList wrapper around the Collection. (Inherited from System.Collections.ObjectModel.Collection<ArgumentList.Item>)
Top

See Also

Reference

ArgumentList Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultComparison Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : DefaultComparison Property

Glossary Item Box

Controls the default string comparer used for this class

Syntax

Visual Basic (Declaration)
Public Shared Property DefaultComparison As StringComparer
C#
public static StringComparer DefaultComparison {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Keys Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : Keys Property

Glossary Item Box

A string collection of all keys in the arguments

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Keys As String()
C#
public string[] Keys {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
NameDelimeters Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : NameDelimeters Property

Glossary Item Box

Controls the allowable delimeter characters seperate argument names from values

Syntax

Visual Basic (Declaration)
Public Shared Property NameDelimeters As Char()
C#
public static char[] NameDelimeters {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
PrefixChars Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : PrefixChars Property

Glossary Item Box

Controls the allowable prefix characters that will preceed named arguments

Syntax

Visual Basic (Declaration)
Public Shared Property PrefixChars As Char()
C#
public static char[] PrefixChars {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Unnamed Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList Class : Unnamed Property

Glossary Item Box

Returns a list of arguments that did not start with a character in the PrefixChars static collection. These arguments can be modified by the methods on the returned collection, or you set this property to a new collection (a copy is made).

Syntax

Visual Basic (Declaration)
Public Property Unnamed As IList(Of String)
C#
public IList<string> Unnamed {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList Class
ArgumentList Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentList.Item Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ArgumentList.Item Class

Glossary Item Box

This is a single named argument within an argument list collection, this can be implicitly assigned to a string, or a string[] array

Object Model

ArgumentList.Item ClassString Class

Syntax

Visual Basic (Declaration)
Public Class ArgumentList.Item
   Inherits System.Collections.ObjectModel.Collection(Of String)
C#
public class ArgumentList.Item : System.Collections.ObjectModel.Collection<string>

Inheritance Hierarchy

System.Object
System.Collections.ObjectModel.Collection<T>
CSharpTest.Net.Utils.ArgumentList.Item

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Members
CSharpTest.Net.Utils Namespace
Boolean ArgumentList.TryGetValue(String,ArgumentList.Item)
ArgumentList.Item ArgumentList.SafeGet(String)

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ArgumentList.Item Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ArgumentList.Item Class

Glossary Item Box

The following tables list the members exposed by ArgumentList.Item.

Public Constructors

 | Name | Description
Public Constructor | ArgumentList.Item Constructor | Constructs an item for the name and values provided.
Top

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements actually contained in the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Property | Item | Gets or sets the element at the specified index. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Property | Name | Returns the name of this item
Public Property | Value | Returns the first value of this named item or null if one doesn't exist
Public Property | Values | Returns the collection of items in this named slot
Top

Protected Properties

 | Name | Description
Protected Property | Items | Gets a IList wrapper around the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Top

Public Methods

 | Name | Description
Public Method | Add | Adds an object to the end of the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | AddRange | Add one or more values to this named item
Public Method | Clear | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | Contains | Determines whether an element is in the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | CopyTo | Copies the entire Collection to a compatible one-dimensional System.Array, starting at the specified index of the target array. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | IndexOf | Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | Insert | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | Remove | Removes the first occurrence of a specific object from the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | RemoveAt | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | ToArray | Same as the .Values property, returns the collection of items in this named slot
Top

Protected Methods

 | Name | Description
Protected Method | ClearItems | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Protected Method | InsertItem | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<string>)
Protected Method | RemoveItem | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Protected Method | SetItem | Replaces the element at the specified index. (Inherited from System.Collections.ObjectModel.Collection<string>)
Top

Public Operators

public Operator Implicit Type Conversion Overloaded. Converts this item to key-value pair to rem to a dictionary
Top

See Also

Reference

ArgumentList.Item Class
CSharpTest.Net.Utils Namespace
Boolean ArgumentList.TryGetValue(String,ArgumentList.Item)
ArgumentList.Item ArgumentList.SafeGet(String)

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentList.Item Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class : ArgumentList.Item Constructor

name
items

Glossary Item Box

Constructs an item for the name and values provided.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal name As String, _
   ByVal ParamArray items() As String _
)
C#
public ArgumentList.Item(
   string name,
   params string[] items
)

Parameters

name
items

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members

Used By

ArgumentList.Add(String,String)
ArgumentList.Item ArgumentList.SafeGet(String)

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ArgumentList.Item Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ArgumentList.Item Class

Glossary Item Box

For a list of all members of this type, see ArgumentList.Item members.

Public Methods

 | Name | Description
Public Method | Add | Adds an object to the end of the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | AddRange | Add one or more values to this named item
Public Method | Clear | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | Contains | Determines whether an element is in the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | CopyTo | Copies the entire Collection to a compatible one-dimensional System.Array, starting at the specified index of the target array. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | IndexOf | Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | Insert | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | Remove | Removes the first occurrence of a specific object from the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | RemoveAt | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Method | ToArray | Same as the .Values property, returns the collection of items in this named slot
Top

Protected Methods

 | Name | Description
Protected Method | ClearItems | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Protected Method | InsertItem | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<string>)
Protected Method | RemoveItem | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Protected Method | SetItem | Replaces the element at the specified index. (Inherited from System.Collections.ObjectModel.Collection<string>)
Top

See Also

Reference

ArgumentList.Item Class
CSharpTest.Net.Utils Namespace
Boolean ArgumentList.TryGetValue(String,ArgumentList.Item)
ArgumentList.Item ArgumentList.SafeGet(String)

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class : AddRange Method

items

Glossary Item Box

Add one or more values to this named item

Syntax

Visual Basic (Declaration)
Public Sub AddRange( _
   ByVal items As IEnumerable(Of String) _
)
C#
public void AddRange(
   IEnumerable<string> items
)

Parameters

items

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class : ToArray Method

Glossary Item Box

Same as the .Values property, returns the collection of items in this named slot

Syntax

Visual Basic (Declaration)
Public Function ToArray() As String()
C#
public string[] ToArray()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ArgumentList.Item Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ArgumentList.Item Class

Glossary Item Box

For a list of all members of this type, see ArgumentList.Item members.

Public Properties

 | Name | Description
Public Property | Count | Gets the number of elements actually contained in the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Property | Item | Gets or sets the element at the specified index. (Inherited from System.Collections.ObjectModel.Collection<string>)
Public Property | Name | Returns the name of this item
Public Property | Value | Returns the first value of this named item or null if one doesn't exist
Public Property | Values | Returns the collection of items in this named slot
Top

Protected Properties

 | Name | Description
Protected Property | Items | Gets a IList wrapper around the Collection. (Inherited from System.Collections.ObjectModel.Collection<string>)
Top

See Also

Reference

ArgumentList.Item Class
CSharpTest.Net.Utils Namespace
Boolean ArgumentList.TryGetValue(String,ArgumentList.Item)
ArgumentList.Item ArgumentList.SafeGet(String)

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Name Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class : Name Property

Glossary Item Box

Returns the name of this item

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Name As String
C#
public string Name {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Value Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class : Value Property

Glossary Item Box

Returns the first value of this named item or null if one doesn't exist

Syntax

Visual Basic (Declaration)
Public Property Value As String
C#
public string Value {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members

Used By

Boolean ArgumentList.TryGetValue(String,String)

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Values Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class : Values Property

Glossary Item Box

Returns the collection of items in this named slot

Syntax

Visual Basic (Declaration)
Public Property Values As String()
C#
public string[] Values {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members

Source Code

Shared/ArgumentList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Implicit Type Conversion Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class : Implicit Type Conversion Operator

Glossary Item Box

Converts this item to key-value pair to rem to a dictionary

Overload List

Overload | Description
Implicit Type Conversion(KeyValuePair<String,String[]>,Item) | Converts this item to key-value pair to rem to a dictionary
Implicit Type Conversion(String,Item) | Converts this item to a string by getting the first value or null if none
Implicit Type Conversion(String[],Item) | Converts this item to array of strings

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Implicit Type Conversion(KeyValuePair<String,String[]>,Item) Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class > Implicit Type Conversion Operator : Implicit Type Conversion(KeyValuePair<String,String[]>,Item) Operator

item

Glossary Item Box

Converts this item to key-value pair to rem to a dictionary

Syntax

Visual Basic (Declaration)
Overloads Public Operator Widening CType( _
   ByVal item As ArgumentList.Item _
) As KeyValuePair(Of String,String())
C#
public KeyValuePair<string,string[]> operator implicit(
   ArgumentList.Item item
)

Parameters

item

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
Implicit Type Conversion(String,Item) Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class > Implicit Type Conversion Operator : Implicit Type Conversion(String,Item) Operator

item

Glossary Item Box

Converts this item to a string by getting the first value or null if none

Syntax

Visual Basic (Declaration)
Overloads Public Operator Widening CType( _
   ByVal item As ArgumentList.Item _
) As String
C#
public string operator implicit(
   ArgumentList.Item item
)

Parameters

item

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
Implicit Type Conversion(String[],Item) Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class > Implicit Type Conversion Operator : Implicit Type Conversion(String[],Item) Operator

item

Glossary Item Box

Converts this item to array of strings

Syntax

Visual Basic (Declaration)
Overloads Public Operator Widening CType( _
   ByVal item As ArgumentList.Item _
) As String()
C#
public string[] operator implicit(
   ArgumentList.Item item
)

Parameters

item

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
FileList Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileList Class

Glossary Item Box

A utility class for gathering files

Object Model

FileList ClassFileInfo Class

Syntax

Visual Basic (Declaration)
Public Class FileList
   Inherits System.Collections.ObjectModel.KeyedCollection(Of String,FileInfo)
C#
public class FileList : System.Collections.ObjectModel.KeyedCollection<string,FileInfo>

Inheritance Hierarchy

System.Object
System.Collections.ObjectModel.Collection<T>
System.Collections.ObjectModel.KeyedCollection<TKey,TItem>
CSharpTest.Net.Utils.FileList

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Members
CSharpTest.Net.Utils Namespace

Source Code

Shared/FileList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FileList Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileList Class

Glossary Item Box

The following tables list the members exposed by FileList.

Public Constructors

 | Name | Description
Public Constructor | FileList Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Comparer | Gets the generic equality comparer that is used to determine equality of keys in the collection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Public Property | Count | Gets the number of elements actually contained in the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Property | IgnoreFolderAttributes | Setting this will greatly improve performance at the cost of not evaluating filters on directories
Public Property | Item | Overloaded. Gets the element with the specified key. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Public Property | ProhibitedAttributes | Set this to the set of attributes that if a directory or file contains should be skipped. For example when set to FileAttributes.Hidden, hidden files and folders will be ignored.
Public Property | RecurseFolders | Gets or sets a value that allows traversal of all directories added.
Top

Protected Properties

 | Name | Description
Protected Property | Dictionary | Gets the lookup dictionary of the KeyedCollection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Protected Property | Items | Gets a IList wrapper around the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Top

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds a set of items to the collection, see Add(string) for details.
Public Method | AddRange | Adds one or files to the collection
Public Method | Clear | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | Contains | Overloaded. Returns true if the given file is in the collection
Public Method | CopyTo | Copies the entire Collection to a compatible one-dimensional System.Array, starting at the specified index of the target array. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | GetFileNames | Converts all FileInfo elements into their fully-qualified file names
Public Method | IndexOf | Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | Insert | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | Remove | Overloaded. Remove the files specified if they exist in the collection
Public Method | RemoveAt | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | ToArray | Returns the collection of FileInfo as an array
Top

Protected Methods

 | Name | Description
Protected Method | ChangeItemKey | Changes the key associated with the specified element in the lookup dictionary. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Protected Method | ClearItems | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Protected Method | GetKeyForItem | Overridden. The key for the specified element.
Protected Method | InsertItem | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Protected Method | RemoveItem | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Protected Method | SetItem | Replaces the element at the specified index. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Top

Public Events

 | Name | Description
Public Event | FileFound | Raised when a new file is about to be added to the collection, set e.Ignore to true will cancel the addition of this file.
Top

See Also

Reference

FileList Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileList Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : FileList Constructor

Glossary Item Box

Overload List

Overload | Description
FileList Constructor() | Creates an empty FileList
FileList Constructor(String[]) | Constructs a FileList containing the files specified or found within the directories specified. See Add(string) for more details.
FileList Constructor(FileAttributes,String[]) | Constructs a FileList containing the files specified or found within the directories specified. See Add(string) for more details. Files and directories that contain the attribtes defined in prohibitedAttributes will be ignored, use '0' for everything.
FileList Constructor(FileInfo[]) | Creates a list containing the specified FileInfo records.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
FileList Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class > FileList Constructor : FileList Constructor()

Glossary Item Box

Creates an empty FileList

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public FileList()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Overload List

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileList Constructor(String[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class > FileList Constructor : FileList Constructor(String[])

filesOrDirectories

Glossary Item Box

Constructs a FileList containing the files specified or found within the directories specified. See Add(string) for more details.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray filesOrDirectories() As String _
)
C#
public FileList(
   params string[] filesOrDirectories
)

Parameters

filesOrDirectories

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Overload List

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileList Constructor(FileAttributes,String[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class > FileList Constructor : FileList Constructor(FileAttributes,String[])

prohibitedAttributes
filesOrDirectories

Glossary Item Box

Constructs a FileList containing the files specified or found within the directories specified. See Add(string) for more details. Files and directories that contain the attribtes defined in prohibitedAttributes will be ignored, use '0' for everything.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal prohibitedAttributes As FileAttributes, _
   ByVal ParamArray filesOrDirectories() As String _
)
C#
public FileList(
   FileAttributes prohibitedAttributes,
   params string[] filesOrDirectories
)

Parameters

prohibitedAttributes
filesOrDirectories

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Overload List

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileList Constructor(FileInfo[])
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class > FileList Constructor : FileList Constructor(FileInfo[])

copyFrom

Glossary Item Box

Creates a list containing the specified FileInfo records.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray copyFrom() As FileInfo _
)
C#
public FileList(
   params FileInfo[] copyFrom
)

Parameters

copyFrom

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Overload List

Source Code

Shared/FileList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
FileList Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileList Class

Glossary Item Box

For a list of all members of this type, see FileList members.

Public Methods

 | Name | Description
Public Method | Add | Overloaded. Adds a set of items to the collection, see Add(string) for details.
Public Method | AddRange | Adds one or files to the collection
Public Method | Clear | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | Contains | Overloaded. Returns true if the given file is in the collection
Public Method | CopyTo | Copies the entire Collection to a compatible one-dimensional System.Array, starting at the specified index of the target array. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | GetFileNames | Converts all FileInfo elements into their fully-qualified file names
Public Method | IndexOf | Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | Insert | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | Remove | Overloaded. Remove the files specified if they exist in the collection
Public Method | RemoveAt | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Method | ToArray | Returns the collection of FileInfo as an array
Top

Protected Methods

 | Name | Description
Protected Method | ChangeItemKey | Changes the key associated with the specified element in the lookup dictionary. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Protected Method | ClearItems | Removes all elements from the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Protected Method | GetKeyForItem | Overridden. The key for the specified element.
Protected Method | InsertItem | Inserts an element into the Collection at the specified index. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Protected Method | RemoveItem | Removes the element at the specified index of the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Protected Method | SetItem | Replaces the element at the specified index. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Top

See Also

Reference

FileList Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : Add Method

Glossary Item Box

Adds a set of items to the collection, see Add(string) for details.

Overload List

Overload | Description
Add(String[]) | Adds a set of items to the collection, see Add(string) for details.
Add(String) | Adds the specified file to the collection. If the item specified is a directory that directory will be crawled for files, and optionally (RecurseFolders) child directories. If the name part of the path contains wild-cards they will be considered throughout the folder tree, i.e: C:\Temp\*.tmp will yeild all files having an extension of .tmp. Again if RecurseFolders is true you will get all .tmp files anywhere in the C:\Temp folder.
Add(FileInfo) | Adds an object to the end of the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(String[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class > Add Method : Add(String[]) Method

filesOrDirectories

Glossary Item Box

Adds a set of items to the collection, see Add(string) for details.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal ParamArray filesOrDirectories() As String _
)
C#
public void Add(
   params string[] filesOrDirectories
)

Parameters

filesOrDirectories

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Overload List

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class > Add Method : Add(String) Method

fileOrDirectory

Glossary Item Box

Adds the specified file to the collection. If the item specified is a directory that directory will be crawled for files, and optionally (RecurseFolders) child directories. If the name part of the path contains wild-cards they will be considered throughout the folder tree, i.e: C:\Temp\*.tmp will yeild all files having an extension of .tmp. Again if RecurseFolders is true you will get all .tmp files anywhere in the C:\Temp folder.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal fileOrDirectory As String _
)
C#
public void Add(
   string fileOrDirectory
)

Parameters

fileOrDirectory

Exceptions

Exception | Description
System.ArgumentNullException | The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
System.IO.FileNotFoundException | The exception that is thrown when an attempt to access a file that does not exist on disk fails.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Overload List

Used By

FileList.Add(String[])

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddRange Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : AddRange Method

files

Glossary Item Box

Adds one or files to the collection

Syntax

Visual Basic (Declaration)
Public Sub AddRange( _
   ByVal ParamArray files() As FileInfo _
)
C#
public void AddRange(
   params FileInfo[] files
)

Parameters

files

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : Contains Method

Glossary Item Box

Returns true if the given file is in the collection

Overload List

Overload | Description
Contains(FileInfo) | Returns true if the given file is in the collection
Contains(String) | (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Contains(FileInfo) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class > Contains Method : Contains(FileInfo) Method

file

Glossary Item Box

Returns true if the given file is in the collection

Syntax

Visual Basic (Declaration)
Public Overloads Shadows Function Contains( _
   ByVal file As FileInfo _
) As Boolean
C#
public new bool Contains(
   FileInfo file
)

Parameters

file

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Overload List

Used By

FileList.AddRange(FileInfo[])

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetFileNames Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : GetFileNames Method

Glossary Item Box

Converts all FileInfo elements into their fully-qualified file names

Syntax

Visual Basic (Declaration)
Public Function GetFileNames() As String()
C#
public string[] GetFileNames()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetKeyForItem Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : GetKeyForItem Method

item

Glossary Item Box

The key for the specified element.

Syntax

Visual Basic (Declaration)
Protected Overrides NotOverridable Function GetKeyForItem( _
   ByVal item As FileInfo _
) As String
C#
protected override string GetKeyForItem(
   FileInfo item
)

Parameters

item

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Base Implementation in GetKeyForItem


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : Remove Method

Glossary Item Box

Remove the files specified if they exist in the collection

Overload List

Overload | Description
Remove(FileInfo[]) | Remove the files specified if they exist in the collection
Remove(String) | (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Remove(FileInfo) | Removes the first occurrence of a specific object from the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove(FileInfo[]) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class > Remove Method : Remove(FileInfo[]) Method

files

Glossary Item Box

Remove the files specified if they exist in the collection

Syntax

Visual Basic (Declaration)
Public Overloads Sub Remove( _
   ByVal ParamArray files() As FileInfo _
)
C#
public void Remove(
   params FileInfo[] files
)

Parameters

files

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members
Overload List

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : ToArray Method

Glossary Item Box

Returns the collection of FileInfo as an array

Syntax

Visual Basic (Declaration)
Public Function ToArray() As FileInfo()
C#
public FileInfo[] ToArray()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members

Source Code

Shared/FileList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
FileList Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileList Class

Glossary Item Box

For a list of all members of this type, see FileList members.

Public Properties

 | Name | Description
Public Property | Comparer | Gets the generic equality comparer that is used to determine equality of keys in the collection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Public Property | Count | Gets the number of elements actually contained in the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Public Property | IgnoreFolderAttributes | Setting this will greatly improve performance at the cost of not evaluating filters on directories
Public Property | Item | Overloaded. Gets the element with the specified key. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Public Property | ProhibitedAttributes | Set this to the set of attributes that if a directory or file contains should be skipped. For example when set to FileAttributes.Hidden, hidden files and folders will be ignored.
Public Property | RecurseFolders | Gets or sets a value that allows traversal of all directories added.
Top

Protected Properties

 | Name | Description
Protected Property | Dictionary | Gets the lookup dictionary of the KeyedCollection. (Inherited from System.Collections.ObjectModel.KeyedCollection<string,FileInfo>)
Protected Property | Items | Gets a IList wrapper around the Collection. (Inherited from System.Collections.ObjectModel.Collection<FileInfo>)
Top

See Also

Reference

FileList Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnoreFolderAttributes Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : IgnoreFolderAttributes Property

Glossary Item Box

Setting this will greatly improve performance at the cost of not evaluating filters on directories

Syntax

Visual Basic (Declaration)
Public Property IgnoreFolderAttributes As Boolean
C#
public bool IgnoreFolderAttributes {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProhibitedAttributes Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : ProhibitedAttributes Property

Glossary Item Box

Set this to the set of attributes that if a directory or file contains should be skipped. For example when set to FileAttributes.Hidden, hidden files and folders will be ignored.

Syntax

Visual Basic (Declaration)
Public Property ProhibitedAttributes As FileAttributes
C#
public FileAttributes ProhibitedAttributes {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RecurseFolders Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : RecurseFolders Property

Glossary Item Box

Gets or sets a value that allows traversal of all directories added.

Syntax

Visual Basic (Declaration)
Public Property RecurseFolders As Boolean
C#
public bool RecurseFolders {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members

Used By

FileList.Add(String)

Source Code

Shared/FileList.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
FileList Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileList Class

Glossary Item Box

For a list of all members of this type, see FileList members.

Public Events

 | Name | Description
Public Event | FileFound | Raised when a new file is about to be added to the collection, set e.Ignore to true will cancel the addition of this file.
Top

See Also

Reference

FileList Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileFound Event
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList Class : FileFound Event

Glossary Item Box

Raised when a new file is about to be added to the collection, set e.Ignore to true will cancel the addition of this file.

Syntax

Visual Basic (Declaration)
Public Event FileFound As EventHandler(Of FileList.FileFoundEventArgs)
C#
public event EventHandler<FileList.FileFoundEventArgs> FileFound

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList Class
FileList Members

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileList.FileFoundEventArgs Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileList.FileFoundEventArgs Class

Glossary Item Box

Event args passed to the FileFound event

Syntax

Visual Basic (Declaration)
Public Class FileList.FileFoundEventArgs
   Inherits System.EventArgs
C#
public class FileList.FileFoundEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Utils.FileList.FileFoundEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList.FileFoundEventArgs Members
CSharpTest.Net.Utils Namespace

Source Code

Shared/FileList.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FileList.FileFoundEventArgs Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileList.FileFoundEventArgs Class

Glossary Item Box

The following tables list the members exposed by FileList.FileFoundEventArgs.

Public Constructors

 | Name | Description
Public Constructor | FileList.FileFoundEventArgs Constructor | Constructs the event args
Top

Public Fields

 | Name | Description
Public Field | File | Provides access to the FileInfo of this item
Public Field | Ignore | Allows manually filtering a file by setting Ignore=true;
Top

See Also

Reference

FileList.FileFoundEventArgs Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileList.FileFoundEventArgs Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList.FileFoundEventArgs Class : FileList.FileFoundEventArgs Constructor

ignore
file

Glossary Item Box

Constructs the event args

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ignore As Boolean, _
   ByVal file As FileInfo _
)
C#
public FileList.FileFoundEventArgs(
   bool ignore,
   FileInfo file
)

Parameters

ignore
file

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList.FileFoundEventArgs Class
FileList.FileFoundEventArgs Members

Source Code

Shared/FileList.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
FileList.FileFoundEventArgs Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileList.FileFoundEventArgs Class

Glossary Item Box

For a list of all members of this type, see FileList.FileFoundEventArgs members.

Public Fields

 | Name | Description
Public Field | File | Provides access to the FileInfo of this item
Public Field | Ignore | Allows manually filtering a file by setting Ignore=true;
Top

See Also

Reference

FileList.FileFoundEventArgs Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
File Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList.FileFoundEventArgs Class : File Field

Glossary Item Box

Provides access to the FileInfo of this item

Syntax

Visual Basic (Declaration)
Public ReadOnly File As FileInfo
C#
public readonly FileInfo File

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList.FileFoundEventArgs Class
FileList.FileFoundEventArgs Members

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Ignore Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileList.FileFoundEventArgs Class : Ignore Field

Glossary Item Box

Allows manually filtering a file by setting Ignore=true;

Syntax

Visual Basic (Declaration)
Public Ignore As Boolean
C#
public bool Ignore

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileList.FileFoundEventArgs Class
FileList.FileFoundEventArgs Members

Source Code

Shared/FileList.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileUtils Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileUtils Class

Glossary Item Box

Provides utilities related to files and file paths

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class FileUtils
C#
public static class FileUtils

Inheritance Hierarchy

System.Object
CSharpTest.Net.Utils.FileUtils

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Members
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
FileUtils Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileUtils Class

Glossary Item Box

The following tables list the members exposed by FileUtils.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | ExpandEnvironment | Expands environment variables into text, i.e. SystemRoot, or ProgramFiles
static (Shared in Visual Basic) | FindFullPath | Returns the fully qualified path to the file if it is fully-qualified, exists in the current directory, or in the environment path, otherwise generates a FileNotFoundException exception.
static (Shared in Visual Basic) | GetPermissions | Returns the rights assigned to the given SID for this file's ACL
static (Shared in Visual Basic) | GrantFullControlForFile | Overloaded. Grants the user FullControl for the file, returns true if modified, false if already present
static (Shared in Visual Basic) | IsValidExtension | Returns true if the extension provided contains only one '.' at the beginning of the string and does not contain any path or invalid filename characters.
static (Shared in Visual Basic) | IsValidFileName | Returns true if the name provided contains only valid filename characters
static (Shared in Visual Basic) | MakeRelativePath | For this to work for a directory the argument should end with a '\' character
static (Shared in Visual Basic) | MakeValidFileName | Overloaded. Creates a valid filename by removing all invalid characters.
static (Shared in Visual Basic) | ReplacePermissions | Removes any existing access for the user SID supplied and adds the specified rights
static (Shared in Visual Basic) | TrySearchPath | Returns true if the file is fully-qualified, exists in the current directory, or in the environment path, otherwise generates a FileNotFoundException exception. Will not propagate errors.
Top

See Also

Reference

FileUtils Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
FileUtils Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : FileUtils Class

Glossary Item Box

For a list of all members of this type, see FileUtils members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | ExpandEnvironment | Expands environment variables into text, i.e. SystemRoot, or ProgramFiles
static (Shared in Visual Basic) | FindFullPath | Returns the fully qualified path to the file if it is fully-qualified, exists in the current directory, or in the environment path, otherwise generates a FileNotFoundException exception.
static (Shared in Visual Basic) | GetPermissions | Returns the rights assigned to the given SID for this file's ACL
static (Shared in Visual Basic) | GrantFullControlForFile | Overloaded. Grants the user FullControl for the file, returns true if modified, false if already present
static (Shared in Visual Basic) | IsValidExtension | Returns true if the extension provided contains only one '.' at the beginning of the string and does not contain any path or invalid filename characters.
static (Shared in Visual Basic) | IsValidFileName | Returns true if the name provided contains only valid filename characters
static (Shared in Visual Basic) | MakeRelativePath | For this to work for a directory the argument should end with a '\' character
static (Shared in Visual Basic) | MakeValidFileName | Overloaded. Creates a valid filename by removing all invalid characters.
static (Shared in Visual Basic) | ReplacePermissions | Removes any existing access for the user SID supplied and adds the specified rights
static (Shared in Visual Basic) | TrySearchPath | Returns true if the file is fully-qualified, exists in the current directory, or in the environment path, otherwise generates a FileNotFoundException exception. Will not propagate errors.
Top

See Also

Reference

FileUtils Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExpandEnvironment Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : ExpandEnvironment Method

input

Glossary Item Box

Expands environment variables into text, i.e. SystemRoot, or ProgramFiles

Syntax

Visual Basic (Declaration)
Public Shared Function ExpandEnvironment( _
   ByVal input As String _
) As String
C#
public static string ExpandEnvironment(
   string input
)

Parameters

input

Example

Library/Library.Test/TestFileUtils.cs

C# Copy Code
Assert.AreEqual(
    Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Test")),
    Path.GetFullPath(FileUtils.ExpandEnvironment(@"PROGRAMFILES\Test"))
    );
VB.NET Copy Code
Assert.AreEqual(Path.GetFullPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Test")), Path.GetFullPath(FileUtils.ExpandEnvironment("PROGRAMFILES\Test")))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FindFullPath Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : FindFullPath Method

location

Glossary Item Box

Returns the fully qualified path to the file if it is fully-qualified, exists in the current directory, or in the environment path, otherwise generates a FileNotFoundException exception.

Syntax

Visual Basic (Declaration)
Public Shared Function FindFullPath( _
   ByVal location As String _
) As String
C#
public static string FindFullPath(
   string location
)

Parameters

location

Exceptions

Exception | Description
System.IO.FileNotFoundException | The exception that is thrown when an attempt to access a file that does not exist on disk fails.

Example

Library/Library.Test/TestProcessRunner.cs

C# Copy Code
string tempfile = Path.GetTempFileName();
try
{
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"));
    ProcessRunner runner = new ProcessRunner("cmd.exe");
    Assert.IsFalse(runner.IsRunning);
    runner.Kill(); // always safe to call

    runner.Start("/K", "ECHO Hello > " + tempfile);
    Assert.IsTrue(runner.IsRunning);

    try //make sure we can't start twice.
    {
        runner.Start("/C", "ECHO", "HELO");
        Assert.Fail();
    }
    catch (InvalidOperationException)
    { }

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), false));
    runner.Kill();
    string output = File.ReadAllText(tempfile).Trim();
    Assert.AreEqual("Hello", output);
}
finally
{ File.Delete(tempfile); }
VB.NET Copy Code
Dim tempfile As String = Path.GetTempFileName()
Try
    Environment.CurrentDirectory = Path.GetDirectoryName(FileUtils.FindFullPath("cmd.exe"))
    Dim runner As New ProcessRunner("cmd.exe")
    Assert.IsFalse(runner.IsRunning)
    runner.Kill()
    ' always safe to call
    runner.Start("/K", "ECHO Hello > " + tempfile)
    Assert.IsTrue(runner.IsRunning)

    Try
        'make sure we can't start twice.
        runner.Start("/C", "ECHO", "HELO")
        Assert.Fail()
    Catch generatedExceptionName As InvalidOperationException
    End Try

    Assert.IsFalse(runner.WaitForExit(TimeSpan.FromSeconds(1), False))
    runner.Kill()
    Dim output As String = File.ReadAllText(tempfile).Trim()
    Assert.AreEqual("Hello", output)
Finally
    File.Delete(tempfile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetPermissions Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : GetPermissions Method

filepath
sidType

Glossary Item Box

Returns the rights assigned to the given SID for this file's ACL

Syntax

Visual Basic (Declaration)
Public Shared Function GetPermissions( _
   ByVal filepath As String, _
   ByVal sidType As WellKnownSidType _
) As FileSystemRights
C#
public static FileSystemRights GetPermissions(
   string filepath,
   WellKnownSidType sidType
)

Parameters

filepath
sidType

Example

Library/Library.Test/TestFileUtils.cs

C# Copy Code
string tempFile = Path.GetTempFileName();
FileSystemRights rights;
try
{
    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read & rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(0, (int)rights);

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.FullControl, rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read & rights);

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.FullControl, rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(0, (int)rights);
}
finally
{
    File.Delete(tempFile);
}
VB.NET Copy Code
Dim tempFile As String = Path.GetTempFileName()
Dim rights As FileSystemRights
Try
    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read And rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(0, DirectCast(rights, Integer))

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.FullControl, rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read And rights)

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.FullControl, rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(0, DirectCast(rights, Integer))
Finally
    File.Delete(tempFile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GrantFullControlForFile Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : GrantFullControlForFile Method

Glossary Item Box

Grants the user FullControl for the file, returns true if modified, false if already present

Overload List

Overload | Description
GrantFullControlForFile(String,WellKnownSidType) | Grants the user FullControl for the file, returns true if modified, false if already present
GrantFullControlForFile(String,WellKnownSidType,SecurityIdentifier) | Grants the user FullControl for the file, returns true if modified, false if already present

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members


%%PageItemTitle%%

[image]
CSharpTest.Net
GrantFullControlForFile(String,WellKnownSidType) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class > GrantFullControlForFile Method : GrantFullControlForFile(String,WellKnownSidType) Method

filepath
sidType

Glossary Item Box

Grants the user FullControl for the file, returns true if modified, false if already present

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function GrantFullControlForFile( _
   ByVal filepath As String, _
   ByVal sidType As WellKnownSidType _
) As Boolean
C#
public static bool GrantFullControlForFile(
   string filepath,
   WellKnownSidType sidType
)

Parameters

filepath
sidType

Example

Library/Library.Test/TestFileUtils.cs

C# Copy Code
string tempFile = Path.GetTempFileName();
FileSystemRights rights;
try
{
    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read & rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(0, (int)rights);

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.FullControl, rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read & rights);

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.FullControl, rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(0, (int)rights);
}
finally
{
    File.Delete(tempFile);
}
VB.NET Copy Code
Dim tempFile As String = Path.GetTempFileName()
Dim rights As FileSystemRights
Try
    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read And rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(0, DirectCast(rights, Integer))

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.FullControl, rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read And rights)

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.FullControl, rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(0, DirectCast(rights, Integer))
Finally
    File.Delete(tempFile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members
Overload List

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GrantFullControlForFile(String,WellKnownSidType,SecurityIdentifier) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class > GrantFullControlForFile Method : GrantFullControlForFile(String,WellKnownSidType,SecurityIdentifier) Method

filepath
sidType
domain

Glossary Item Box

Grants the user FullControl for the file, returns true if modified, false if already present

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function GrantFullControlForFile( _
   ByVal filepath As String, _
   ByVal sidType As WellKnownSidType, _
   ByVal domain As SecurityIdentifier _
) As Boolean
C#
public static bool GrantFullControlForFile(
   string filepath,
   WellKnownSidType sidType,
   SecurityIdentifier domain
)

Parameters

filepath
sidType
domain

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members
Overload List

Used By

Boolean FileUtils.GrantFullControlForFile(String,WellKnownSidType)

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsValidExtension Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : IsValidExtension Method

fileExt

Glossary Item Box

Returns true if the extension provided contains only one '.' at the beginning of the string and does not contain any path or invalid filename characters.

Syntax

Visual Basic (Declaration)
Public Shared Function IsValidExtension( _
   ByVal fileExt As String _
) As Boolean
C#
public static bool IsValidExtension(
   string fileExt
)

Parameters

fileExt

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsValidFileName Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : IsValidFileName Method

filename

Glossary Item Box

Returns true if the name provided contains only valid filename characters

Syntax

Visual Basic (Declaration)
Public Shared Function IsValidFileName( _
   ByVal filename As String _
) As Boolean
C#
public static bool IsValidFileName(
   string filename
)

Parameters

filename

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members

Source Code

Library/Utils/FileUtils.cs

Used By

String FileUtils.MakeValidFileName(String,String)
Boolean FileUtils.TrySearchPath(String,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
MakeRelativePath Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : MakeRelativePath Method

startFile
targetFile

Glossary Item Box

For this to work for a directory the argument should end with a '\' character

Syntax

Visual Basic (Declaration)
Public Shared Function MakeRelativePath( _
   ByVal startFile As String, _
   ByVal targetFile As String _
) As String
C#
public static string MakeRelativePath(
   string startFile,
   string targetFile
)

Parameters

startFile
targetFile

Example

Library/Library.Test/TestFileUtils.cs

C# Copy Code
Assert.IsNull(FileUtils.MakeRelativePath(null, @"C:\Test\fileb.txt"));
Assert.IsNull(FileUtils.MakeRelativePath(@"C:\Test\fileb.txt", null));

Assert.AreEqual(
    @"filea.txt",
    FileUtils.MakeRelativePath(@"C:\Test\filea.txt", @"C:\Test\filea.txt")
    );
Assert.AreEqual(
    @"fileb.txt",
    FileUtils.MakeRelativePath(@"C:\Test\filea.txt", @"C:\Test\fileb.txt")
    );
Assert.AreEqual(
    @"..\fileb.txt",
    FileUtils.MakeRelativePath(@"C:\Test\filea.txt\", @"C:\Test\fileb.txt")
    );
Assert.AreEqual(
    @"..\fileb.txt\",
    FileUtils.MakeRelativePath(@"C:\Test\filea.txt\", @"C:\Test\fileb.txt\")
    );
Assert.AreEqual(
    @"fileb.txt\",
    FileUtils.MakeRelativePath(@"C:\Test\filea.txt", @"C:\Test\fileb.txt\")
    );
Assert.AreEqual(
    @"sub\fileb.txt",
    FileUtils.MakeRelativePath(@"C:\Test\filea.txt", @"C:\Test\sub\fileb.txt")
    );
Assert.AreEqual(
    @"..\fileb.txt",
    FileUtils.MakeRelativePath(@"C:\Test\sub\filea.txt", @"C:\Test\fileb.txt")
    );
Assert.AreEqual(
    @"C:\Test\sub\fileb.txt",
    FileUtils.MakeRelativePath(@"E:\Test\sub\filea.txt", @"C:\Test\sub\fileb.txt")
    );
Assert.AreEqual(
    @"..\test\fileb.txt",
    FileUtils.MakeRelativePath(@"sub\filea.txt", @"test\fileb.txt")
    );
Assert.AreEqual(
    @"..\..\test\fileb.txt",
    FileUtils.MakeRelativePath(@"..\sub\filea.txt", @"test\fileb.txt")
    );
Assert.AreEqual(
    @"fileb.txt",
    FileUtils.MakeRelativePath(@"sub\", @"sub\fileb.txt")
    );
Assert.AreEqual(
    @"sub\fileb.txt",
    FileUtils.MakeRelativePath(@"sub", @"sub\fileb.txt")
    );
Assert.AreEqual(
    @"sub\fileb.txt",
    FileUtils.MakeRelativePath(@".\sub", @"sub\fileb.txt")
    );
Assert.AreEqual(
    @"..\sub\fileb.txt",
    FileUtils.MakeRelativePath(@"sub\test", @".\sub\.\..\sub\fileb.txt")
    );
VB.NET Copy Code
Assert.IsNull(FileUtils.MakeRelativePath(Nothing, "C:\Test\fileb.txt"))
Assert.IsNull(FileUtils.MakeRelativePath("C:\Test\fileb.txt", Nothing))

Assert.AreEqual("filea.txt", FileUtils.MakeRelativePath("C:\Test\filea.txt", "C:\Test\filea.txt"))
Assert.AreEqual("fileb.txt", FileUtils.MakeRelativePath("C:\Test\filea.txt", "C:\Test\fileb.txt"))
Assert.AreEqual("..\fileb.txt", FileUtils.MakeRelativePath("C:\Test\filea.txt\", "C:\Test\fileb.txt"))
Assert.AreEqual("..\fileb.txt\", FileUtils.MakeRelativePath("C:\Test\filea.txt\", "C:\Test\fileb.txt\"))
Assert.AreEqual("fileb.txt\", FileUtils.MakeRelativePath("C:\Test\filea.txt", "C:\Test\fileb.txt\"))
Assert.AreEqual("sub\fileb.txt", FileUtils.MakeRelativePath("C:\Test\filea.txt", "C:\Test\sub\fileb.txt"))
Assert.AreEqual("..\fileb.txt", FileUtils.MakeRelativePath("C:\Test\sub\filea.txt", "C:\Test\fileb.txt"))
Assert.AreEqual("C:\Test\sub\fileb.txt", FileUtils.MakeRelativePath("E:\Test\sub\filea.txt", "C:\Test\sub\fileb.txt"))
Assert.AreEqual("..\test\fileb.txt", FileUtils.MakeRelativePath("sub\filea.txt", "test\fileb.txt"))
Assert.AreEqual("..\..\test\fileb.txt", FileUtils.MakeRelativePath("..\sub\filea.txt", "test\fileb.txt"))
Assert.AreEqual("fileb.txt", FileUtils.MakeRelativePath("sub\", "sub\fileb.txt"))
Assert.AreEqual("sub\fileb.txt", FileUtils.MakeRelativePath("sub", "sub\fileb.txt"))
Assert.AreEqual("sub\fileb.txt", FileUtils.MakeRelativePath(".\sub", "sub\fileb.txt"))
Assert.AreEqual("..\sub\fileb.txt", FileUtils.MakeRelativePath("sub\test", ".\sub\.\..\sub\fileb.txt"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MakeValidFileName Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : MakeValidFileName Method

Glossary Item Box

Creates a valid filename by removing all invalid characters.

Overload List

Overload | Description
MakeValidFileName(String) | Creates a valid filename by removing all invalid characters.
MakeValidFileName(String,String) | Creates a valid filename by replacing all invalid characters with the string provided.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members


%%PageItemTitle%%

[image]
CSharpTest.Net
MakeValidFileName(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class > MakeValidFileName Method : MakeValidFileName(String) Method

filename

Glossary Item Box

Creates a valid filename by removing all invalid characters.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function MakeValidFileName( _
   ByVal filename As String _
) As String
C#
public static string MakeValidFileName(
   string filename
)

Parameters

filename

Example

Library/Library.Test/TestFileUtils.cs

C# Copy Code
Assert.AreEqual("a...", FileUtils.MakeValidFileName("a..."));
Assert.AreEqual("a. . .", FileUtils.MakeValidFileName("a. . . "));
Assert.AreEqual("leading whitespace is bad", FileUtils.MakeValidFileName(" leading whitespace is bad"));
Assert.AreEqual("trailing whitespace is bad", FileUtils.MakeValidFileName("trailing whitespace is bad\t"));
Assert.AreEqual("a_a.txt", FileUtils.MakeValidFileName("a/a.txt", "_"));
Assert.AreEqual("a_a.txt", FileUtils.MakeValidFileName("a|a.txt", "_"));
Assert.AreEqual("a_a._txt", FileUtils.MakeValidFileName("a<|/\\*?>a.*txt", "_"));

Assert.AreEqual(".a", FileUtils.MakeValidFileName(".a"));
Assert.AreEqual(". -", FileUtils.MakeValidFileName(". -"));
Assert.AreEqual("..a", FileUtils.MakeValidFileName("..a"));
Assert.AreEqual("a..", FileUtils.MakeValidFileName("a.."));
Assert.AreEqual("No extension is fine", FileUtils.MakeValidFileName("No extension is fine"));
Assert.AreEqual(". a leading dot is ok", FileUtils.MakeValidFileName(". a leading dot is ok"));
Assert.AreEqual("really really long file extension is actually ok.", FileUtils.MakeValidFileName("really really long file extension is actually ok."));
VB.NET Copy Code
Assert.AreEqual("a...", FileUtils.MakeValidFileName("a..."))
Assert.AreEqual("a. . .", FileUtils.MakeValidFileName("a. . . "))
Assert.AreEqual("leading whitespace is bad", FileUtils.MakeValidFileName(" leading whitespace is bad"))
Assert.AreEqual("trailing whitespace is bad", FileUtils.MakeValidFileName("trailing whitespace is bad" & vbTab))
Assert.AreEqual("a_a.txt", FileUtils.MakeValidFileName("a/a.txt", "_"))
Assert.AreEqual("a_a.txt", FileUtils.MakeValidFileName("a|a.txt", "_"))
Assert.AreEqual("a_a._txt", FileUtils.MakeValidFileName("a<|/\*?>a.*txt", "_"))

Assert.AreEqual(".a", FileUtils.MakeValidFileName(".a"))
Assert.AreEqual(". -", FileUtils.MakeValidFileName(". -"))
Assert.AreEqual("..a", FileUtils.MakeValidFileName("..a"))
Assert.AreEqual("a..", FileUtils.MakeValidFileName("a.."))
Assert.AreEqual("No extension is fine", FileUtils.MakeValidFileName("No extension is fine"))
Assert.AreEqual(". a leading dot is ok", FileUtils.MakeValidFileName(". a leading dot is ok"))
Assert.AreEqual("really really long file extension is actually ok.", FileUtils.MakeValidFileName("really really long file extension is actually ok."))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members
Overload List

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MakeValidFileName(String,String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class > MakeValidFileName Method : MakeValidFileName(String,String) Method

filename
replaceWithChars

Glossary Item Box

Creates a valid filename by replacing all invalid characters with the string provided.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function MakeValidFileName( _
   ByVal filename As String, _
   ByVal replaceWithChars As String _
) As String
C#
public static string MakeValidFileName(
   string filename,
   string replaceWithChars
)

Parameters

filename
replaceWithChars

Exceptions

Exception | Description
System.ArgumentException | The exception that is thrown when one of the arguments provided to a method is not valid.

Example

Library/Library.Test/TestFileUtils.cs

C# Copy Code
Assert.AreEqual("a...", FileUtils.MakeValidFileName("a..."));
Assert.AreEqual("a. . .", FileUtils.MakeValidFileName("a. . . "));
Assert.AreEqual("leading whitespace is bad", FileUtils.MakeValidFileName(" leading whitespace is bad"));
Assert.AreEqual("trailing whitespace is bad", FileUtils.MakeValidFileName("trailing whitespace is bad\t"));
Assert.AreEqual("a_a.txt", FileUtils.MakeValidFileName("a/a.txt", "_"));
Assert.AreEqual("a_a.txt", FileUtils.MakeValidFileName("a|a.txt", "_"));
Assert.AreEqual("a_a._txt", FileUtils.MakeValidFileName("a<|/\\*?>a.*txt", "_"));

Assert.AreEqual(".a", FileUtils.MakeValidFileName(".a"));
Assert.AreEqual(". -", FileUtils.MakeValidFileName(". -"));
Assert.AreEqual("..a", FileUtils.MakeValidFileName("..a"));
Assert.AreEqual("a..", FileUtils.MakeValidFileName("a.."));
Assert.AreEqual("No extension is fine", FileUtils.MakeValidFileName("No extension is fine"));
Assert.AreEqual(". a leading dot is ok", FileUtils.MakeValidFileName(". a leading dot is ok"));
Assert.AreEqual("really really long file extension is actually ok.", FileUtils.MakeValidFileName("really really long file extension is actually ok."));
VB.NET Copy Code
Assert.AreEqual("a...", FileUtils.MakeValidFileName("a..."))
Assert.AreEqual("a. . .", FileUtils.MakeValidFileName("a. . . "))
Assert.AreEqual("leading whitespace is bad", FileUtils.MakeValidFileName(" leading whitespace is bad"))
Assert.AreEqual("trailing whitespace is bad", FileUtils.MakeValidFileName("trailing whitespace is bad" & vbTab))
Assert.AreEqual("a_a.txt", FileUtils.MakeValidFileName("a/a.txt", "_"))
Assert.AreEqual("a_a.txt", FileUtils.MakeValidFileName("a|a.txt", "_"))
Assert.AreEqual("a_a._txt", FileUtils.MakeValidFileName("a<|/\*?>a.*txt", "_"))

Assert.AreEqual(".a", FileUtils.MakeValidFileName(".a"))
Assert.AreEqual(". -", FileUtils.MakeValidFileName(". -"))
Assert.AreEqual("..a", FileUtils.MakeValidFileName("..a"))
Assert.AreEqual("a..", FileUtils.MakeValidFileName("a.."))
Assert.AreEqual("No extension is fine", FileUtils.MakeValidFileName("No extension is fine"))
Assert.AreEqual(". a leading dot is ok", FileUtils.MakeValidFileName(". a leading dot is ok"))
Assert.AreEqual("really really long file extension is actually ok.", FileUtils.MakeValidFileName("really really long file extension is actually ok."))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members
Overload List

Used By

String FileUtils.MakeValidFileName(String)

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReplacePermissions Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : ReplacePermissions Method

filepath
sidType
allow

Glossary Item Box

Removes any existing access for the user SID supplied and adds the specified rights

Syntax

Visual Basic (Declaration)
Public Shared Sub ReplacePermissions( _
   ByVal filepath As String, _
   ByVal sidType As WellKnownSidType, _
   ByVal allow As FileSystemRights _
)
C#
public static void ReplacePermissions(
   string filepath,
   WellKnownSidType sidType,
   FileSystemRights allow
)

Parameters

filepath
sidType
allow

Example

Library/Library.Test/TestFileUtils.cs

C# Copy Code
string tempFile = Path.GetTempFileName();
FileSystemRights rights;
try
{
    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read & rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(0, (int)rights);

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.FullControl, rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read & rights);

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(FileSystemRights.FullControl, rights);

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0);
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid);
    Assert.AreEqual(0, (int)rights);
}
finally
{
    File.Delete(tempFile);
}
VB.NET Copy Code
Dim tempFile As String = Path.GetTempFileName()
Dim rights As FileSystemRights
Try
    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read And rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(0, DirectCast(rights, Integer))

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.FullControl, rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, FileSystemRights.Read)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.Read, FileSystemRights.Read And rights)

    FileUtils.GrantFullControlForFile(tempFile, WellKnownSidType.WorldSid)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(FileSystemRights.FullControl, rights)

    FileUtils.ReplacePermissions(tempFile, WellKnownSidType.WorldSid, 0)
    rights = FileUtils.GetPermissions(tempFile, WellKnownSidType.WorldSid)
    Assert.AreEqual(0, DirectCast(rights, Integer))
Finally
    File.Delete(tempFile)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TrySearchPath Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > FileUtils Class : TrySearchPath Method

location
fullPath

Glossary Item Box

Returns true if the file is fully-qualified, exists in the current directory, or in the environment path, otherwise generates a FileNotFoundException exception. Will not propagate errors.

Syntax

Visual Basic (Declaration)
Public Shared Function TrySearchPath( _
   ByVal location As String, _
   ByRef fullPath As String _
) As Boolean
C#
public static bool TrySearchPath(
   string location,
   out string fullPath
)

Parameters

location
fullPath

Example

Library/Library.Test/TestFileUtils.cs

C# Copy Code
string found, test;

test = @"C:\This file hopefully doesn't exist on your hard drive!";
Assert.IsFalse(File.Exists(test));
Assert.IsFalse(FileUtils.TrySearchPath(test, out found));

test = @"*<Illegal File Name?>*";
Assert.IsFalse(FileUtils.TrySearchPath(test, out found));

test = @"*"; //<= wild-cards not allowed.
Assert.IsFalse(FileUtils.TrySearchPath(test, out found));

test = @"????????.???"; //<= wild-cards not allowed.
Assert.IsFalse(FileUtils.TrySearchPath(test, out found));
VB.NET Copy Code
Dim found As String, test As String

test = "C:\This file hopefully doesn't exist on your hard drive!"
Assert.IsFalse(File.Exists(test))
Assert.IsFalse(FileUtils.TrySearchPath(test, found))

test = "*<Illegal File Name?>*"
Assert.IsFalse(FileUtils.TrySearchPath(test, found))

test = "*"
'<= wild-cards not allowed.
Assert.IsFalse(FileUtils.TrySearchPath(test, found))

test = "????????.???"
'<= wild-cards not allowed.
Assert.IsFalse(FileUtils.TrySearchPath(test, found))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

FileUtils Class
FileUtils Members

Used By

String FileUtils.FindFullPath(String)

Source Code

Library/Utils/FileUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ObjectKeepAlive Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ObjectKeepAlive Class

Glossary Item Box

Provides a means of forcing the garbage collector to wait on objects aquired from permanent storage while only holding WeakReference's of the object. Essentially uses a simple lockless algorithm to track the most recently loaded objects so that they will stay alive longer.

Syntax

Visual Basic (Declaration)
Public Class ObjectKeepAlive
   Implements IObjectKeepAlive
C#
public class ObjectKeepAlive : IObjectKeepAlive

Example

Library/Library.Test/TestObjectKeepAlive.cs

C# Copy Code
TimeSpan timeout = TimeSpan.FromMilliseconds(25);
ObjectKeepAlive keep = new ObjectKeepAlive(100, 10000, timeout);

for (int i = 0; i < 100000; i++)
    keep.Add(i);

System.Threading.Thread.Sleep(timeout);

for (int i = 0; i < 10000; i++)
    keep.Add(i);
VB.NET Copy Code
Dim timeout As TimeSpan = TimeSpan.FromMilliseconds(25)
Dim keep As New ObjectKeepAlive(100, 10000, timeout)

Dim i As Integer = 0
While i < 100000
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

System.Threading.Thread.Sleep(timeout)

Dim i As Integer = 0
While i < 10000
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Inheritance Hierarchy

System.Object
CSharpTest.Net.Utils.ObjectKeepAlive

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectKeepAlive Members
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/ObjectKeepAlive.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ObjectKeepAlive Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ObjectKeepAlive Class

Glossary Item Box

The following tables list the members exposed by ObjectKeepAlive.

Public Constructors

 | Name | Description
Public Constructor | ObjectKeepAlive Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Add | Cleans up expired items and adds the object to the list of items to keep alive.
Public Method | Clear | Clears the entire keep-alive cache
Public Method | Tick | Can be called periodically by external threads to ensure cleanup instead of depending upon calls to Add()
Top

See Also

Reference

ObjectKeepAlive Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/ObjectKeepAlive.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ObjectKeepAlive Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class : ObjectKeepAlive Constructor

Glossary Item Box

Overload List

Overload | Description
ObjectKeepAlive Constructor(Int32,Int32,TimeSpan) | Configures the keep-alive policy for this container
ObjectKeepAlive Constructor(Int32,Int32,TimeSpan,Boolean) | Configures the keep-alive policy for this container

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectKeepAlive Class
ObjectKeepAlive Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ObjectKeepAlive Constructor(Int32,Int32,TimeSpan)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class > ObjectKeepAlive Constructor : ObjectKeepAlive Constructor(Int32,Int32,TimeSpan)

minItems
The minimum number of items desired in the list (kept event after age expires)
maxItems
The maximum number of items desired in the list (discarded even if age has not expired)
maxAge
Determines how long to keep an object if the count is between min and max

Glossary Item Box

Configures the keep-alive policy for this container

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal minItems As Integer, _
   ByVal maxItems As Integer, _
   ByVal maxAge As TimeSpan _
)
C#
public ObjectKeepAlive(
   int minItems,
   int maxItems,
   TimeSpan maxAge
)

Parameters

minItems
The minimum number of items desired in the list (kept event after age expires)
maxItems
The maximum number of items desired in the list (discarded even if age has not expired)
maxAge
Determines how long to keep an object if the count is between min and max

Example

Library/Library.Test/TestObjectKeepAlive.cs

C# Copy Code
TimeSpan timeout = TimeSpan.FromMilliseconds(25);
ObjectKeepAlive keep = new ObjectKeepAlive(100, 10000, timeout);

for (int i = 0; i < 100000; i++)
    keep.Add(i);

System.Threading.Thread.Sleep(timeout);

for (int i = 0; i < 10000; i++)
    keep.Add(i);
VB.NET Copy Code
Dim timeout As TimeSpan = TimeSpan.FromMilliseconds(25)
Dim keep As New ObjectKeepAlive(100, 10000, timeout)

Dim i As Integer = 0
While i < 100000
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

System.Threading.Thread.Sleep(timeout)

Dim i As Integer = 0
While i < 10000
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectKeepAlive Class
ObjectKeepAlive Members
Overload List

Source Code

Library/Utils/ObjectKeepAlive.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ObjectKeepAlive Constructor(Int32,Int32,TimeSpan,Boolean)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class > ObjectKeepAlive Constructor : ObjectKeepAlive Constructor(Int32,Int32,TimeSpan,Boolean)

minItems
The minimum number of items desired in the list (kept event after age expires)
maxItems
The maximum number of items desired in the list (discarded even if age has not expired)
maxAge
Determines how long to keep an object if the count is between min and max
externalTicks
True if you want to perform cleanup exclusivly on another thread by calling Tick(), otherwise false

Glossary Item Box

Configures the keep-alive policy for this container

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal minItems As Integer, _
   ByVal maxItems As Integer, _
   ByVal maxAge As TimeSpan, _
   ByVal externalTicks As Boolean _
)
C#
public ObjectKeepAlive(
   int minItems,
   int maxItems,
   TimeSpan maxAge,
   bool externalTicks
)

Parameters

minItems
The minimum number of items desired in the list (kept event after age expires)
maxItems
The maximum number of items desired in the list (discarded even if age has not expired)
maxAge
Determines how long to keep an object if the count is between min and max
externalTicks
True if you want to perform cleanup exclusivly on another thread by calling Tick(), otherwise false

Example

Library/Library.Test/TestObjectKeepAlive.cs

C# Copy Code
WeakReference r;
TimeSpan timeout = TimeSpan.FromMilliseconds(100);
ObjectKeepAlive keep = new ObjectKeepAlive(1, 10, timeout, false);

if (true)
{
    object target = new MyObject();
    r = new WeakReference(target);
    keep.Add(target);
    target = null;
}

_destroyed = false;
Assert.IsTrue(r.IsAlive);

for (int i = 0; i < 5; i++)
    keep.Add(i);

Assert.IsTrue(r.IsAlive);

GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsTrue(r.IsAlive);
Assert.IsFalse(_destroyed);

long start = DateTime.UtcNow.Ticks;
while ((start + timeout.Ticks) > DateTime.UtcNow.Ticks)
    System.Threading.Thread.SpinWait(100);

//Time has elapsed, yet it nothing is added, and Tick() is not called, it remains in memory
GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsTrue(r.IsAlive);
Assert.IsFalse(_destroyed);

//Once the collection is touched with either a call to Add or Tick, timeout will expire
keep.Add(new object());

GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsFalse(r.IsAlive);
Assert.IsTrue(_destroyed);
VB.NET Copy Code
Dim r As WeakReference
Dim timeout As TimeSpan = TimeSpan.FromMilliseconds(100)
Dim keep As New ObjectKeepAlive(1, 10, timeout, False)

If True Then
    Dim target As Object = New MyObject()
    r = New WeakReference(target)
    keep.Add(target)
    target = Nothing
End If

_destroyed = False
Assert.IsTrue(r.IsAlive)

Dim i As Integer = 0
While i < 5
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.IsTrue(r.IsAlive)

GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsTrue(r.IsAlive)
Assert.IsFalse(_destroyed)

Dim start As Long = DateTime.UtcNow.Ticks
While (start + timeout.Ticks) > DateTime.UtcNow.Ticks
    System.Threading.Thread.SpinWait(100)
End While

'Time has elapsed, yet it nothing is added, and Tick() is not called, it remains in memory
GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsTrue(r.IsAlive)
Assert.IsFalse(_destroyed)

'Once the collection is touched with either a call to Add or Tick, timeout will expire
keep.Add(New Object())

GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsFalse(r.IsAlive)
Assert.IsTrue(_destroyed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectKeepAlive Class
ObjectKeepAlive Members
Overload List

Source Code

Library/Utils/ObjectKeepAlive.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ObjectKeepAlive Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ObjectKeepAlive Class

Glossary Item Box

For a list of all members of this type, see ObjectKeepAlive members.

Public Methods

 | Name | Description
Public Method | Add | Cleans up expired items and adds the object to the list of items to keep alive.
Public Method | Clear | Clears the entire keep-alive cache
Public Method | Tick | Can be called periodically by external threads to ensure cleanup instead of depending upon calls to Add()
Top

See Also

Reference

ObjectKeepAlive Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/ObjectKeepAlive.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class : Add Method

item

Glossary Item Box

Cleans up expired items and adds the object to the list of items to keep alive.

Syntax

Visual Basic (Declaration)
Public Sub Add( _
   ByVal item As Object _
)
C#
public void Add(
   object item
)

Parameters

item

Example

Library/Library.Test/TestObjectKeepAlive.cs

C# Copy Code
TimeSpan timeout = TimeSpan.FromMilliseconds(25);
ObjectKeepAlive keep = new ObjectKeepAlive(100, 10000, timeout);

for (int i = 0; i < 100000; i++)
    keep.Add(i);

System.Threading.Thread.Sleep(timeout);

for (int i = 0; i < 10000; i++)
    keep.Add(i);
VB.NET Copy Code
Dim timeout As TimeSpan = TimeSpan.FromMilliseconds(25)
Dim keep As New ObjectKeepAlive(100, 10000, timeout)

Dim i As Integer = 0
While i < 100000
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

System.Threading.Thread.Sleep(timeout)

Dim i As Integer = 0
While i < 10000
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectKeepAlive Class
ObjectKeepAlive Members

Source Code

Library/Utils/ObjectKeepAlive.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class : Clear Method

Glossary Item Box

Clears the entire keep-alive cache

Syntax

Visual Basic (Declaration)
Public Sub Clear()
C#
public void Clear()

Example

Library/Library.Test/TestObjectKeepAlive.cs

C# Copy Code
WeakReference r;
ObjectKeepAlive keep = new ObjectKeepAlive(1, 10, TimeSpan.FromTicks(1), true);

for (int i = 0; i < 35; i++)
    keep.Add(i);

if (true)
{
    object target = new MyObject();
    r = new WeakReference(target);
    keep.Add(target);
    target = null;
}

_destroyed = false;
Assert.IsTrue(r.IsAlive);

for (int i = 0; i < 100; i++)
    keep.Tick();

Assert.IsTrue(r.IsAlive);

GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsTrue(r.IsAlive);
Assert.IsFalse(_destroyed);

System.Threading.Thread.Sleep(1);

GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsTrue(r.IsAlive);
Assert.IsFalse(_destroyed);

keep.Clear();

GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsFalse(r.IsAlive);
Assert.IsTrue(_destroyed);
VB.NET Copy Code
Dim r As WeakReference
Dim keep As New ObjectKeepAlive(1, 10, TimeSpan.FromTicks(1), True)

Dim i As Integer = 0
While i < 35
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

If True Then
    Dim target As Object = New MyObject()
    r = New WeakReference(target)
    keep.Add(target)
    target = Nothing
End If

_destroyed = False
Assert.IsTrue(r.IsAlive)

Dim i As Integer = 0
While i < 100
    keep.Tick()
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.IsTrue(r.IsAlive)

GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsTrue(r.IsAlive)
Assert.IsFalse(_destroyed)

System.Threading.Thread.Sleep(1)

GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsTrue(r.IsAlive)
Assert.IsFalse(_destroyed)

keep.Clear()

GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsFalse(r.IsAlive)
Assert.IsTrue(_destroyed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectKeepAlive Class
ObjectKeepAlive Members

Source Code

Library/Utils/ObjectKeepAlive.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Tick() Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class : Tick() Method

Glossary Item Box

Can be called periodically by external threads to ensure cleanup instead of depending upon calls to Add()

Syntax

Visual Basic (Declaration)
Public Sub Tick()
C#
public void Tick()

Example

Library/Library.Test/TestObjectKeepAlive.cs

C# Copy Code
WeakReference r;
ObjectKeepAlive keep = new ObjectKeepAlive(1, 10, TimeSpan.FromTicks(1), true);

for (int i = 0; i < 35; i++)
    keep.Add(i);

if (true)
{
    object target = new MyObject();
    r = new WeakReference(target);
    keep.Add(target);
    target = null;
}

_destroyed = false;
Assert.IsTrue(r.IsAlive);

for (int i = 0; i < 100; i++)
    keep.Tick();

Assert.IsTrue(r.IsAlive);

GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsTrue(r.IsAlive);
Assert.IsFalse(_destroyed);

System.Threading.Thread.Sleep(1);

GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsTrue(r.IsAlive);
Assert.IsFalse(_destroyed);

keep.Clear();

GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsFalse(r.IsAlive);
Assert.IsTrue(_destroyed);
VB.NET Copy Code
Dim r As WeakReference
Dim keep As New ObjectKeepAlive(1, 10, TimeSpan.FromTicks(1), True)

Dim i As Integer = 0
While i < 35
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

If True Then
    Dim target As Object = New MyObject()
    r = New WeakReference(target)
    keep.Add(target)
    target = Nothing
End If

_destroyed = False
Assert.IsTrue(r.IsAlive)

Dim i As Integer = 0
While i < 100
    keep.Tick()
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.IsTrue(r.IsAlive)

GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsTrue(r.IsAlive)
Assert.IsFalse(_destroyed)

System.Threading.Thread.Sleep(1)

GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsTrue(r.IsAlive)
Assert.IsFalse(_destroyed)

keep.Clear()

GC.GetTotalMemory(True)
GC.WaitForPendingFinalizers()
Assert.IsFalse(r.IsAlive)
Assert.IsTrue(_destroyed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectKeepAlive Class
ObjectKeepAlive Members

Source Code

Library/Utils/ObjectKeepAlive.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessInfo Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ProcessInfo Class

Glossary Item Box

Utility class for obtaining information about the currently running process and AppDomain

Syntax

Visual Basic (Declaration)
Public Class ProcessInfo
C#
public class ProcessInfo

Inheritance Hierarchy

System.Object
CSharpTest.Net.Utils.ProcessInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Members
CSharpTest.Net.Utils Namespace

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ProcessInfo Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ProcessInfo Class

Glossary Item Box

The following tables list the members exposed by ProcessInfo.

Public Constructors

 | Name | Description
Public Constructor | ProcessInfo Constructor | This is some ugly code, the intent is to be able to answer the above questions in a wide array of environments. I admit now this may fail eventually.
Top

Public Fields

 | Name | Description
Public Field | AppDomainName | Returns the current AppDomain's friendly name
Public Field | ApplicationData | Returns the roaming user profile path for the currently running software application: {SpecialFolder.ApplicationData}\{CompanyName}\{ProductName}
Public Field | CompanyName | Returns the company name of the entry assembly
Public Field | DefaultLogFile | Returns a default log file name derived as: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}\{AppDomainName}.txt
Public Field | EntryAssembly | Returns the entry-point assembly or the highest stack assembly
Public Field | IsDebugging | Returns true if a debugger is attached to the process
Public Field | LocalApplicationData | Returns the non-roaming user profile path for the currently running software application: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}
Public Field | ProcessFile | Returns the file path to the exe for this process
Public Field | ProcessId | Returns the current process id
Public Field | ProcessName | Returns the current process name without an extension
Public Field | ProductName | Returns the product name of the entry assembly
Public Field | ProductVersion | Returns the product version of the entry assembly
Public Field | RegistrySoftwarePath | Returns the HKCU or HKLM path for this software application based on the process that is running: Software\{CompanyName}\{ProductName}
Top

See Also

Reference

ProcessInfo Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessInfo Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : ProcessInfo Constructor

Glossary Item Box

This is some ugly code, the intent is to be able to answer the above questions in a wide array of environments. I admit now this may fail eventually.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public ProcessInfo()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
ProcessInfo Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : ProcessInfo Class

Glossary Item Box

For a list of all members of this type, see ProcessInfo members.

Public Fields

 | Name | Description
Public Field | AppDomainName | Returns the current AppDomain's friendly name
Public Field | ApplicationData | Returns the roaming user profile path for the currently running software application: {SpecialFolder.ApplicationData}\{CompanyName}\{ProductName}
Public Field | CompanyName | Returns the company name of the entry assembly
Public Field | DefaultLogFile | Returns a default log file name derived as: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}\{AppDomainName}.txt
Public Field | EntryAssembly | Returns the entry-point assembly or the highest stack assembly
Public Field | IsDebugging | Returns true if a debugger is attached to the process
Public Field | LocalApplicationData | Returns the non-roaming user profile path for the currently running software application: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}
Public Field | ProcessFile | Returns the file path to the exe for this process
Public Field | ProcessId | Returns the current process id
Public Field | ProcessName | Returns the current process name without an extension
Public Field | ProductName | Returns the product name of the entry assembly
Public Field | ProductVersion | Returns the product version of the entry assembly
Public Field | RegistrySoftwarePath | Returns the HKCU or HKLM path for this software application based on the process that is running: Software\{CompanyName}\{ProductName}
Top

See Also

Reference

ProcessInfo Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AppDomainName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : AppDomainName Field

Glossary Item Box

Returns the current AppDomain's friendly name

Syntax

Visual Basic (Declaration)
Public ReadOnly AppDomainName As String
C#
public readonly string AppDomainName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ApplicationData Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : ApplicationData Field

Glossary Item Box

Returns the roaming user profile path for the currently running software application: {SpecialFolder.ApplicationData}\{CompanyName}\{ProductName}

Syntax

Visual Basic (Declaration)
Public ReadOnly ApplicationData As String
C#
public readonly string ApplicationData

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CompanyName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : CompanyName Field

Glossary Item Box

Returns the company name of the entry assembly

Syntax

Visual Basic (Declaration)
Public ReadOnly CompanyName As String
C#
public readonly string CompanyName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DefaultLogFile Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : DefaultLogFile Field

Glossary Item Box

Returns a default log file name derived as: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}\{AppDomainName}.txt

Syntax

Visual Basic (Declaration)
Public ReadOnly DefaultLogFile As String
C#
public readonly string DefaultLogFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EntryAssembly Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : EntryAssembly Field

Glossary Item Box

Returns the entry-point assembly or the highest stack assembly

Syntax

Visual Basic (Declaration)
Public ReadOnly EntryAssembly As Assembly
C#
public readonly Assembly EntryAssembly

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsDebugging Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : IsDebugging Field

Glossary Item Box

Returns true if a debugger is attached to the process

Syntax

Visual Basic (Declaration)
Public ReadOnly IsDebugging As Boolean
C#
public readonly bool IsDebugging

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalApplicationData Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : LocalApplicationData Field

Glossary Item Box

Returns the non-roaming user profile path for the currently running software application: {SpecialFolder.LocalApplicationData}\{CompanyName}\{ProductName}

Syntax

Visual Basic (Declaration)
Public ReadOnly LocalApplicationData As String
C#
public readonly string LocalApplicationData

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessFile Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : ProcessFile Field

Glossary Item Box

Returns the file path to the exe for this process

Syntax

Visual Basic (Declaration)
Public ReadOnly ProcessFile As String
C#
public readonly string ProcessFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessId Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : ProcessId Field

Glossary Item Box

Returns the current process id

Syntax

Visual Basic (Declaration)
Public ReadOnly ProcessId As Integer
C#
public readonly int ProcessId

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : ProcessName Field

Glossary Item Box

Returns the current process name without an extension

Syntax

Visual Basic (Declaration)
Public ReadOnly ProcessName As String
C#
public readonly string ProcessName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProductName Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : ProductName Field

Glossary Item Box

Returns the product name of the entry assembly

Syntax

Visual Basic (Declaration)
Public ReadOnly ProductName As String
C#
public readonly string ProductName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProductVersion Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : ProductVersion Field

Glossary Item Box

Returns the product version of the entry assembly

Syntax

Visual Basic (Declaration)
Public ReadOnly ProductVersion As Version
C#
public readonly Version ProductVersion

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegistrySoftwarePath Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ProcessInfo Class : RegistrySoftwarePath Field

Glossary Item Box

Returns the HKCU or HKLM path for this software application based on the process that is running: Software\{CompanyName}\{ProductName}

Syntax

Visual Basic (Declaration)
Public ReadOnly RegistrySoftwarePath As String
C#
public readonly string RegistrySoftwarePath

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ProcessInfo Class
ProcessInfo Members

Source Code

Shared/ProcessInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RegexPatterns Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : RegexPatterns Class

Glossary Item Box

A collection of common regular expression patterns

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class RegexPatterns
C#
public static class RegexPatterns

Inheritance Hierarchy

System.Object
CSharpTest.Net.Utils.RegexPatterns

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Members
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
RegexPatterns Class Members
See Also Fields Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : RegexPatterns Class

Glossary Item Box

The following tables list the members exposed by RegexPatterns.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | CreditCard | This is generally not enought to fully validate a card, there are other ways to validate by using the build-in checksums.
static (Shared in Visual Basic) | FormatNameSpecifier | Matches a c-sharp style format specifier in a string "{Name-0,5:n}" with some additional changes. Used with StringUtils.Transform() you can provide your own String.Format(). The groups returned will be the following: "field" - An identifier may contain any alpha-numeric or one of these special characters: ('_', '-', or '.') "suffix" - Everything after the identifer and before the closing brace '}' "width" - The width part of the format is a number after a ',' and before ':' "format" - Everything after the the ':' and before the closing '}', note: escapes }} are not supported.
static (Shared in Visual Basic) | FormatSpecifier | Matches a c-sharp style format specifier in a string "{0,5:n}". The identifier may be any numeric set of characters. The groups returned will be "field", "suffix", "width", and "format". Used with StringUtils.Transform() you can provide your own String.Format().
static (Shared in Visual Basic) | FullVersion | Matches a numeric version "1.2.3.4" up to 9 digits for a value
static (Shared in Visual Basic) | Guid | Matches a guid in the common forms used with the string constructor of the System.Guid type: "ca761232ed4211cebacd00aa0057b223" "ca761232-ed42-11ce-bacd-00aa0057b223" "CA761232-ED42-11CE-BACD-00AA0057B223" "{ca761232-ed42-11ce-bacd-00aa0057b223}" "(CA761232-ED42-11CE-BACD-00AA0057B223)" The following format is NOT support: "{0xCA761232, 0xED42, 0x11CE, {0xBA, 0xCD, 0x00, 0xAA, 0x00, 0x57, 0xB2, 0x23}}"
static (Shared in Visual Basic) | HtmlEntity | Finds html/xml entity references in text, test patterns: hex = #xae6f278 decimal = #1234567890 or named = lt
static (Shared in Visual Basic) | HttpUrl | Free-form matching of urls in plain text, from http://immike.net/blog/2007/04/06/5-regular-expressions-every-web-programmer-should-know/
static (Shared in Visual Basic) | MakefileMacro | Matches a makefile macro name in text, i.e. "$(field:name=value)" where field is any alpha-numeric + ('_', '-', or '.') text identifier returned from group "field". the "replace" group contains all after the identifier and before the last ')'. "name" and "value" groups match the name/value replacement pairs.
static (Shared in Visual Basic) | Version | Matches a numeric version with 2, 3, or 4 parts: "1.2", "1.2.3", or "1.2.3.4" up to 9 digits for a value
static (Shared in Visual Basic) | VSErrorMessage | Matches VisualStudio style error/warning format. The groups returned are as follows: path = The file path (due caution should be taken to ensure this is a file path) line = The line number if any pos = The line position if any error = Was it tagged as an error? warning = Was it tagged as a warning? id = The error/warning id if provided message = The remainder of the text line
Top

See Also

Reference

RegexPatterns Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
RegexPatterns Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : RegexPatterns Class

Glossary Item Box

For a list of all members of this type, see RegexPatterns members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | CreditCard | This is generally not enought to fully validate a card, there are other ways to validate by using the build-in checksums.
static (Shared in Visual Basic) | FormatNameSpecifier | Matches a c-sharp style format specifier in a string "{Name-0,5:n}" with some additional changes. Used with StringUtils.Transform() you can provide your own String.Format(). The groups returned will be the following: "field" - An identifier may contain any alpha-numeric or one of these special characters: ('_', '-', or '.') "suffix" - Everything after the identifer and before the closing brace '}' "width" - The width part of the format is a number after a ',' and before ':' "format" - Everything after the the ':' and before the closing '}', note: escapes }} are not supported.
static (Shared in Visual Basic) | FormatSpecifier | Matches a c-sharp style format specifier in a string "{0,5:n}". The identifier may be any numeric set of characters. The groups returned will be "field", "suffix", "width", and "format". Used with StringUtils.Transform() you can provide your own String.Format().
static (Shared in Visual Basic) | FullVersion | Matches a numeric version "1.2.3.4" up to 9 digits for a value
static (Shared in Visual Basic) | Guid | Matches a guid in the common forms used with the string constructor of the System.Guid type: "ca761232ed4211cebacd00aa0057b223" "ca761232-ed42-11ce-bacd-00aa0057b223" "CA761232-ED42-11CE-BACD-00AA0057B223" "{ca761232-ed42-11ce-bacd-00aa0057b223}" "(CA761232-ED42-11CE-BACD-00AA0057B223)" The following format is NOT support: "{0xCA761232, 0xED42, 0x11CE, {0xBA, 0xCD, 0x00, 0xAA, 0x00, 0x57, 0xB2, 0x23}}"
static (Shared in Visual Basic) | HtmlEntity | Finds html/xml entity references in text, test patterns: hex = #xae6f278 decimal = #1234567890 or named = lt
static (Shared in Visual Basic) | HttpUrl | Free-form matching of urls in plain text, from http://immike.net/blog/2007/04/06/5-regular-expressions-every-web-programmer-should-know/
static (Shared in Visual Basic) | MakefileMacro | Matches a makefile macro name in text, i.e. "$(field:name=value)" where field is any alpha-numeric + ('_', '-', or '.') text identifier returned from group "field". the "replace" group contains all after the identifier and before the last ')'. "name" and "value" groups match the name/value replacement pairs.
static (Shared in Visual Basic) | Version | Matches a numeric version with 2, 3, or 4 parts: "1.2", "1.2.3", or "1.2.3.4" up to 9 digits for a value
static (Shared in Visual Basic) | VSErrorMessage | Matches VisualStudio style error/warning format. The groups returned are as follows: path = The file path (due caution should be taken to ensure this is a file path) line = The line number if any pos = The line position if any error = Was it tagged as an error? warning = Was it tagged as a warning? id = The error/warning id if provided message = The remainder of the text line
Top

See Also

Reference

RegexPatterns Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CreditCard Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : CreditCard Field

Glossary Item Box

This is generally not enought to fully validate a card, there are other ways to validate by using the build-in checksums.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly CreditCard As Regex
C#
public static readonly Regex CreditCard

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FormatNameSpecifier Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : FormatNameSpecifier Field

Glossary Item Box

Matches a c-sharp style format specifier in a string "{Name-0,5:n}" with some additional changes. Used with StringUtils.Transform() you can provide your own String.Format(). The groups returned will be the following: "field" - An identifier may contain any alpha-numeric or one of these special characters: ('_', '-', or '.') "suffix" - Everything after the identifer and before the closing brace '}' "width" - The width part of the format is a number after a ',' and before ':' "format" - Everything after the the ':' and before the closing '}', note: escapes }} are not supported.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly FormatNameSpecifier As Regex
C#
public static readonly Regex FormatNameSpecifier

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FormatSpecifier Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : FormatSpecifier Field

Glossary Item Box

Matches a c-sharp style format specifier in a string "{0,5:n}". The identifier may be any numeric set of characters. The groups returned will be "field", "suffix", "width", and "format". Used with StringUtils.Transform() you can provide your own String.Format().

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly FormatSpecifier As Regex
C#
public static readonly Regex FormatSpecifier

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FullVersion Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : FullVersion Field

Glossary Item Box

Matches a numeric version "1.2.3.4" up to 9 digits for a value

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly FullVersion As Regex
C#
public static readonly Regex FullVersion

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Used By

UserSettingsSection.UpgradeUserSettings(Configuration,UserSettingsSection)

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Guid Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : Guid Field

Glossary Item Box

Matches a guid in the common forms used with the string constructor of the System.Guid type: "ca761232ed4211cebacd00aa0057b223" "ca761232-ed42-11ce-bacd-00aa0057b223" "CA761232-ED42-11CE-BACD-00AA0057B223" "{ca761232-ed42-11ce-bacd-00aa0057b223}" "(CA761232-ED42-11CE-BACD-00AA0057B223)" The following format is NOT support: "{0xCA761232, 0xED42, 0x11CE, {0xBA, 0xCD, 0x00, 0xAA, 0x00, 0x57, 0xB2, 0x23}}"

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Guid As Regex
C#
public static readonly Regex Guid

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HtmlEntity Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : HtmlEntity Field

Glossary Item Box

Finds html/xml entity references in text, test patterns: hex = #xae6f278 decimal = #1234567890 or named = lt

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly HtmlEntity As Regex
C#
public static readonly Regex HtmlEntity

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
HttpUrl Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : HttpUrl Field

Glossary Item Box

Free-form matching of urls in plain text, from http://immike.net/blog/2007/04/06/5-regular-expressions-every-web-programmer-should-know/

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly HttpUrl As Regex
C#
public static readonly Regex HttpUrl

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MakefileMacro Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : MakefileMacro Field

Glossary Item Box

Matches a makefile macro name in text, i.e. "$(field:name=value)" where field is any alpha-numeric + ('_', '-', or '.') text identifier returned from group "field". the "replace" group contains all after the identifier and before the last ')'. "name" and "value" groups match the name/value replacement pairs.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly MakefileMacro As Regex
C#
public static readonly Regex MakefileMacro

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Version Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : Version Field

Glossary Item Box

Matches a numeric version with 2, 3, or 4 parts: "1.2", "1.2.3", or "1.2.3.4" up to 9 digits for a value

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Version As Regex
C#
public static readonly Regex Version

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
VSErrorMessage Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > RegexPatterns Class : VSErrorMessage Field

Glossary Item Box

Matches VisualStudio style error/warning format. The groups returned are as follows: path = The file path (due caution should be taken to ensure this is a file path) line = The line number if any pos = The line position if any error = Was it tagged as an error? warning = Was it tagged as a warning? id = The error/warning id if provided message = The remainder of the text line

Syntax

Visual Basic (Declaration)
Public Shared VSErrorMessage As Regex
C#
public static Regex VSErrorMessage

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RegexPatterns Class
RegexPatterns Members

Source Code

Library/Utils/RegexPatterns.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StringConverter Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : StringConverter Class

Glossary Item Box

Handles the conversion of data to and from strings for serialization. Can alternatly be configured to provide other transforms for display or other outputs.

Syntax

Visual Basic (Declaration)
Public Class StringConverter
C#
public class StringConverter

Example

Library/Library.Test/TestStringConvert.cs

C# Copy Code
DateTime date = new DateTime(2000, 1,2,3,4,5,6);
string dt = date.ToString();

StringConverter c = new StringConverter();

Assert.AreNotEqual(dt, c.ToString(date));

c.Add<DateTime>(DateTime.TryParse, delegate(DateTime value) { return value.ToString(); });

Assert.AreEqual(dt, c.ToString(date));
VB.NET Copy Code
Dim [date] As New DateTime(2000, 1, 2, 3, 4, 5, _
    6)
Dim dt As String = [date].ToString()

Dim c As New StringConverter()

Assert.AreNotEqual(dt, c.ToString([date]))

c.Add(Of DateTime)(DateTime.TryParse, Function(value As DateTime) Do
    Return value.ToString()
End Function)

Assert.AreEqual(dt, c.ToString([date]))

Inheritance Hierarchy

System.Object
CSharpTest.Net.Utils.StringConverter

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Members
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
StringConverter Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : StringConverter Class

Glossary Item Box

The following tables list the members exposed by StringConverter.

Public Constructors

 | Name | Description
Public Constructor | StringConverter Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Add<TYPE> | Adds a converter for the type TYPE that can transform the TYPE to and from a string
Public Method | FromString<TYPE> | Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type. Throws an ArgumentException if the string can not be converted.
Public Method | Remove<TYPE> | Removes the TYPE from the set of types allowed to be converted to and from strings.
Public Method | ToString | Overloaded. Converts an object to a string if the type is registered, or ArgumentOutOfRangeException is thrown if no transform is registered for that type.
Public Method | TryParse | Overloaded. Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type.
Top

See Also

Reference

StringConverter Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StringConverter Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class : StringConverter Constructor

Glossary Item Box

Overload List

Overload | Description
StringConverter Constructor() | Constructs a default StringConverter object for serialization
StringConverter Constructor(Boolean) | Constructs a StringConverter optionally populated with the default serialization transforms.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
StringConverter Constructor()
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class > StringConverter Constructor : StringConverter Constructor()

Glossary Item Box

Constructs a default StringConverter object for serialization

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public StringConverter()

Example

Library/Library.Test/TestStringConvert.cs

C# Copy Code
DateTime date = new DateTime(2000, 1,2,3,4,5,6);
string dt = date.ToString();

StringConverter c = new StringConverter();

Assert.AreNotEqual(dt, c.ToString(date));

c.Add<DateTime>(DateTime.TryParse, delegate(DateTime value) { return value.ToString(); });

Assert.AreEqual(dt, c.ToString(date));
VB.NET Copy Code
Dim [date] As New DateTime(2000, 1, 2, 3, 4, 5, _
    6)
Dim dt As String = [date].ToString()

Dim c As New StringConverter()

Assert.AreNotEqual(dt, c.ToString([date]))

c.Add(Of DateTime)(DateTime.TryParse, Function(value As DateTime) Do
    Return value.ToString()
End Function)

Assert.AreEqual(dt, c.ToString([date]))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members
Overload List

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StringConverter Constructor(Boolean)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class > StringConverter Constructor : StringConverter Constructor(Boolean)

includeDefaults
true to include default transforms

Glossary Item Box

Constructs a StringConverter optionally populated with the default serialization transforms.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal includeDefaults As Boolean _
)
C#
public StringConverter(
   bool includeDefaults
)

Parameters

includeDefaults
true to include default transforms

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members
Overload List

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
StringConverter Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : StringConverter Class

Glossary Item Box

For a list of all members of this type, see StringConverter members.

Public Methods

 | Name | Description
Public Method | Add<TYPE> | Adds a converter for the type TYPE that can transform the TYPE to and from a string
Public Method | FromString<TYPE> | Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type. Throws an ArgumentException if the string can not be converted.
Public Method | Remove<TYPE> | Removes the TYPE from the set of types allowed to be converted to and from strings.
Public Method | ToString | Overloaded. Converts an object to a string if the type is registered, or ArgumentOutOfRangeException is thrown if no transform is registered for that type.
Public Method | TryParse | Overloaded. Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type.
Top

See Also

Reference

StringConverter Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%%

TYPE
The type that can be transformed by the delegates
[image]
CSharpTest.Net
Add<TYPE> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class : Add<TYPE> Method

tryParse
A delegate method to convert from a string
toString
A delegate method to convert to a string

Glossary Item Box

Adds a converter for the type TYPE that can transform the TYPE to and from a string

Syntax

Visual Basic (Declaration)
Public Sub Add(Of TYPE)( _
   ByVal tryParse As CSharpTest.Net.Utils.StringConverter.TryParseMethod(Of TYPE), _
   ByVal toString As Converter(Of TYPE,String) _
)
C#
public void Add<TYPE>(
   CSharpTest.Net.Utils.StringConverter.TryParseMethod<TYPE> tryParse,
   Converter<TYPE,string> toString
)

Parameters

tryParse
A delegate method to convert from a string
toString
A delegate method to convert to a string

Type Parameters

TYPE
The type that can be transformed by the delegates

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members
StringConverter.TryParseMethod

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%%

TYPE
[image]
CSharpTest.Net
FromString<TYPE> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class : FromString<TYPE> Method

value

Glossary Item Box

Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type. Throws an ArgumentException if the string can not be converted.

Syntax

Visual Basic (Declaration)
Public Function FromString(Of TYPE)( _
   ByVal value As String _
) As TYPE
C#
public TYPE FromString<TYPE>(
   string value
)

Parameters

value

Type Parameters

TYPE

Exceptions

Exception | Description
System.ArgumentException | The exception that is thrown when one of the arguments provided to a method is not valid.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%%

TYPE
The type that will no longer be transformed
[image]
CSharpTest.Net
Remove<TYPE> Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class : Remove<TYPE> Method

Glossary Item Box

Removes the TYPE from the set of types allowed to be converted to and from strings.

Syntax

Visual Basic (Declaration)
Public Sub Remove(Of TYPE)()
C#
public void Remove<TYPE>()

Type Parameters

TYPE
The type that will no longer be transformed

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class : ToString Method

Glossary Item Box

Converts an object to a string if the type is registered, or ArgumentOutOfRangeException is thrown if no transform is registered for that type.

Overload List

Overload | Description
ToString(Object) | Converts an object to a string if the type is registered, or ArgumentOutOfRangeException is thrown if no transform is registered for that type.
ToString<TYPE>(TYPE) | Converts the value of TYPE to a string if the type is registered, or ArgumentOutOfRangeException is thrown if no transform is registered for that type.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString(Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class > ToString Method : ToString(Object) Method

value

Glossary Item Box

Converts an object to a string if the type is registered, or ArgumentOutOfRangeException is thrown if no transform is registered for that type.

Syntax

Visual Basic (Declaration)
Public Overloads Function ToString( _
   ByVal value As Object _
) As String
C#
public string ToString(
   object value
)

Parameters

value

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members
Overload List

Source Code

Library/Utils/StringCoverter.cs

Used By

String StringUtils.ToString(Object)


%%PageItemTitle%%

TYPE
[image]
CSharpTest.Net
ToString<TYPE>(TYPE) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class > ToString Method : ToString<TYPE>(TYPE) Method

value

Glossary Item Box

Converts the value of TYPE to a string if the type is registered, or ArgumentOutOfRangeException is thrown if no transform is registered for that type.

Syntax

Visual Basic (Declaration)
Public Overloads Function ToString(Of TYPE)( _
   ByVal value As TYPE _
) As String
C#
public string ToString<TYPE>(
   TYPE value
)

Parameters

value

Type Parameters

TYPE

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members
Overload List

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryParse Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class : TryParse Method

Glossary Item Box

Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type.

Overload List

Overload | Description
TryParse(String,Type,Object) | Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type.
TryParse<TYPE>(String,TYPE) | Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TryParse(String,Type,Object) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class > TryParse Method : TryParse(String,Type,Object) Method

input
The string value to convert
type
The type of the value to be converted to
value
The value once converted

Glossary Item Box

Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryParse( _
   ByVal input As String, _
   ByVal type As Type, _
   ByRef value As Object _
) As Boolean
C#
public bool TryParse(
   string input,
   Type type,
   out object value
)

Parameters

input
The string value to convert
type
The type of the value to be converted to
value
The value once converted

Return Value

True if it was able to make the conversion

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members
Overload List

Source Code

Library/Utils/StringCoverter.cs

Used By

Boolean StringUtils.TryParse(String,Type,Object)


%%PageItemTitle%%

TYPE
The type of the value to be converted to
[image]
CSharpTest.Net
TryParse<TYPE>(String,TYPE) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringConverter Class > TryParse Method : TryParse<TYPE>(String,TYPE) Method

input
The string value to convert
value
The value once converted

Glossary Item Box

Converts the provided string to a value of TYPE if the type is registered, or raises ArgumentOutOfRangeException if no transform is registered for that type.

Syntax

Visual Basic (Declaration)
Public Overloads Function TryParse(Of TYPE)( _
   ByVal input As String, _
   ByRef value As TYPE _
) As Boolean
C#
public bool TryParse<TYPE>(
   string input,
   out TYPE value
)

Parameters

input
The string value to convert
value
The value once converted

Type Parameters

TYPE
The type of the value to be converted to

Return Value

True if it was able to make the conversion

Exceptions

Exception | Description
System.ArgumentOutOfRangeException | The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter Class
StringConverter Members
Overload List

Source Code

Library/Utils/StringCoverter.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StringUtils Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : StringUtils Class

Glossary Item Box

Various routines for string manipulations

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class StringUtils
C#
public static class StringUtils

Inheritance Hierarchy

System.Object
CSharpTest.Net.Utils.StringUtils

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Members
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
StringUtils Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : StringUtils Class

Glossary Item Box

The following tables list the members exposed by StringUtils.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | AlphaNumericOnly | returns a new string containing only the alpha-numeric characters in the original
static (Shared in Visual Basic) | SafeFileName | Parses the text to ensure that it is a valid file name and returns the resulting string with the following offending characters replace with '-': /\:*?"'<>| Also removes any characters class as control characters, or anything below 32 space, this would include tab, backspace, newline, linefeed, etc. If provided null, this function returns null
static (Shared in Visual Basic) | SafeFilePath | Splits the string on path characters ('/' and '\\') and passes each to SafeFileName(), then reconstructs the string using '\\' and removing any empty segments. If provided null, this function returns null, provided an empty string or just a path seperator '/' it will return String.Empty
static (Shared in Visual Basic) | ToString | Overloaded. Converts primitives to strings so that they can be reconstituted via TryParse
static (Shared in Visual Basic) | Transform | Used for text-template transformation where a regex match is replaced in the input string.
static (Shared in Visual Basic) | TryParse | Overloaded. Reconstructs a type from a string that was previously obtained via StringUtils.ToString(T data)
Top

See Also

Reference

StringUtils Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
StringUtils Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : StringUtils Class

Glossary Item Box

For a list of all members of this type, see StringUtils members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | AlphaNumericOnly | returns a new string containing only the alpha-numeric characters in the original
static (Shared in Visual Basic) | SafeFileName | Parses the text to ensure that it is a valid file name and returns the resulting string with the following offending characters replace with '-': /\:*?"'<>| Also removes any characters class as control characters, or anything below 32 space, this would include tab, backspace, newline, linefeed, etc. If provided null, this function returns null
static (Shared in Visual Basic) | SafeFilePath | Splits the string on path characters ('/' and '\\') and passes each to SafeFileName(), then reconstructs the string using '\\' and removing any empty segments. If provided null, this function returns null, provided an empty string or just a path seperator '/' it will return String.Empty
static (Shared in Visual Basic) | ToString | Overloaded. Converts primitives to strings so that they can be reconstituted via TryParse
static (Shared in Visual Basic) | Transform | Used for text-template transformation where a regex match is replaced in the input string.
static (Shared in Visual Basic) | TryParse | Overloaded. Reconstructs a type from a string that was previously obtained via StringUtils.ToString(T data)
Top

See Also

Reference

StringUtils Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AlphaNumericOnly Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class : AlphaNumericOnly Method

input

Glossary Item Box

returns a new string containing only the alpha-numeric characters in the original

Syntax

Visual Basic (Declaration)
Public Shared Function AlphaNumericOnly( _
   ByVal input As String _
) As String
C#
public static string AlphaNumericOnly(
   string input
)

Parameters

input

Example

Library/Library.Test/TestStringUtils.cs

C# Copy Code
Assert.AreEqual("", StringUtils.AlphaNumericOnly("~!@#$%^&*()_+|}{	"));

Assert.AreEqual("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
    StringUtils.AlphaNumericOnly("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ.1234567890"));

Assert.AreEqual("ca761232ed4211cebacd00aa0057b223",
    StringUtils.AlphaNumericOnly("{ca761232-ed42-11ce-bacd-00aa0057b223}"));
VB.NET Copy Code
Assert.AreEqual("", StringUtils.AlphaNumericOnly("~!@#$%^&*()_+|}{" & vbTab))

Assert.AreEqual("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", StringUtils.AlphaNumericOnly("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ.1234567890"))

Assert.AreEqual("ca761232ed4211cebacd00aa0057b223", StringUtils.AlphaNumericOnly("{ca761232-ed42-11ce-bacd-00aa0057b223}"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeFileName Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class : SafeFileName Method

name
The text to parse

Glossary Item Box

Parses the text to ensure that it is a valid file name and returns the resulting string with the following offending characters replace with '-': /\:*?"'<>| Also removes any characters class as control characters, or anything below 32 space, this would include tab, backspace, newline, linefeed, etc. If provided null, this function returns null

Syntax

Visual Basic (Declaration)
Public Shared Function SafeFileName( _
   ByVal name As String _
) As String
C#
public static string SafeFileName(
   string name
)

Parameters

name
The text to parse

Return Value

The text provided with only allowable characters

Example

Library/Library.Test/TestStringUtils.cs

C# Copy Code
Assert.AreEqual(null, StringUtils.SafeFileName(null));
Assert.AreEqual("--------------", StringUtils.SafeFileName("\b\t\r\n/\\:*?\"'<>|"));

Assert.AreEqual("Greetings this is !@#)%~^@+)(",
    StringUtils.SafeFileName("Greetings this is !@#)%~^@+)("));

Assert.AreEqual("-ca761232-ed42-11ce-bacd-00aa0057b223-",
    StringUtils.SafeFileName("<ca761232|ed42|11ce|bacd|00aa0057b223>"));
VB.NET Copy Code
Assert.AreEqual(Nothing, StringUtils.SafeFileName(Nothing))
Assert.AreEqual("--------------", StringUtils.SafeFileName(vbBack & vbTab & vbCr & vbLf & "/\:*?""'<>|"))

Assert.AreEqual("Greetings this is !@#)%~^@+)(", StringUtils.SafeFileName("Greetings this is !@#)%~^@+)("))

Assert.AreEqual("-ca761232-ed42-11ce-bacd-00aa0057b223-", StringUtils.SafeFileName("<ca761232|ed42|11ce|bacd|00aa0057b223>"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members

Used By

Boolean RegistryStorage.Read(String,String,String)
RegistryStorage.Write(String,String,String)
RegistryStorage.Delete(String,String)
Boolean IsolatedStorage.Read(String,String,String)
IsolatedStorage.Write(String,String,String)
IsolatedStorage.Delete(String,String)
Boolean FileStorage.Read(String,String,String)
FileStorage.Write(String,String,String)
FileStorage.Delete(String,String)
String StringUtils.SafeFilePath(String)

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SafeFilePath Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class : SafeFilePath Method

path
The text to parse

Glossary Item Box

Splits the string on path characters ('/' and '\\') and passes each to SafeFileName(), then reconstructs the string using '\\' and removing any empty segments. If provided null, this function returns null, provided an empty string or just a path seperator '/' it will return String.Empty

Syntax

Visual Basic (Declaration)
Public Shared Function SafeFilePath( _
   ByVal path As String _
) As String
C#
public static string SafeFilePath(
   string path
)

Parameters

path
The text to parse

Return Value

The text provided as a valid path

Example

Library/Library.Test/TestStringUtils.cs

C# Copy Code
Assert.AreEqual(String.Empty, StringUtils.SafeFilePath("\\"));

Assert.AreEqual("----\\--------", StringUtils.SafeFilePath("\b\t\r\n/\\:*?\"'<>|"));

Assert.AreEqual("Greetings this\\is !@#)%~^@+)(",
    StringUtils.SafeFilePath("Greetings this/is !@#)%~^@+)("));

Assert.AreEqual("ca761232\\ed42-11ce-bacd\\00aa0057b223",
    StringUtils.SafeFilePath("/ca761232/ed42|11ce|bacd\\00aa0057b223\\"));
VB.NET Copy Code
Assert.AreEqual([String].Empty, StringUtils.SafeFilePath("\"))

Assert.AreEqual("----\--------", StringUtils.SafeFilePath(vbBack & vbTab & vbCr & vbLf & "/\:*?""'<>|"))

Assert.AreEqual("Greetings this\is !@#)%~^@+)(", StringUtils.SafeFilePath("Greetings this/is !@#)%~^@+)("))

Assert.AreEqual("ca761232\ed42-11ce-bacd\00aa0057b223", StringUtils.SafeFilePath("/ca761232/ed42|11ce|bacd\00aa0057b223\"))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class : ToString Method

Glossary Item Box

Converts primitives to strings so that they can be reconstituted via TryParse

Overload List

Overload | Description
ToString<TYPE>(TYPE) | Converts primitives to strings so that they can be reconstituted via TryParse
ToString(Object) | Converts primitives to strings so that they can be reconstituted via TryParse

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members


%%PageItemTitle%%

TYPE
[image]
CSharpTest.Net
ToString<TYPE>(TYPE) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class > ToString Method : ToString<TYPE>(TYPE) Method

value

Glossary Item Box

Converts primitives to strings so that they can be reconstituted via TryParse

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function ToString(Of TYPE)( _
   ByVal value As TYPE _
) As String
C#
public static string ToString<TYPE>(
   TYPE value
)

Parameters

value

Type Parameters

TYPE

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members
Overload List

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString(Object) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class > ToString Method : ToString(Object) Method

value

Glossary Item Box

Converts primitives to strings so that they can be reconstituted via TryParse

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function ToString( _
   ByVal value As Object _
) As String
C#
public static string ToString(
   object value
)

Parameters

value

Example

Library/Library.Test/TestStringUtils.cs

C# Copy Code
Assert.AreEqual("5.1", StringUtils.ToString<double>(5.1));
Assert.AreEqual("5.1", StringUtils.ToString((object)new Version(5, 1)));

int ival;
object oval;

Assert.IsTrue(StringUtils.TryParse("1", out ival));
Assert.AreEqual(1, ival);

Assert.IsTrue(StringUtils.TryParse("1", typeof(int), out oval));
Assert.AreEqual(1, oval);
VB.NET Copy Code
Assert.AreEqual("5.1", StringUtils.ToString(Of Double)(5.1))
Assert.AreEqual("5.1", StringUtils.ToString(DirectCast(New Version(5, 1), Object)))

Dim ival As Integer
Dim oval As Object

Assert.IsTrue(StringUtils.TryParse("1", ival))
Assert.AreEqual(1, ival)

Assert.IsTrue(StringUtils.TryParse("1", GetType(Integer), oval))
Assert.AreEqual(1, oval)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members
Overload List

Used By

Storage.SetValue(String,Type,Object)

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Transform Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class : Transform Method

input
The text to perform the replacement upon
pattern
The regex used to perform the match
fnReplace
A delegate that selects the appropriate replacement text

Glossary Item Box

Used for text-template transformation where a regex match is replaced in the input string.

Syntax

Visual Basic (Declaration)
Public Shared Function Transform( _
   ByVal input As String, _
   ByVal pattern As Regex, _
   ByVal fnReplace As Converter(Of Match,String) _
) As String
C#
public static string Transform(
   string input,
   Regex pattern,
   Converter<Match,string> fnReplace
)

Parameters

input
The text to perform the replacement upon
pattern
The regex used to perform the match
fnReplace
A delegate that selects the appropriate replacement text

Return Value

The newly formed text after all replacements are made

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members

Used By

String CommandInterpreter.ExpandOptions(String)
String XmlLightParser.ParseText(String)

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryParse Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class : TryParse Method

Glossary Item Box

Reconstructs a type from a string that was previously obtained via StringUtils.ToString(T data)

Overload List

Overload | Description
TryParse<TYPE>(String,TYPE) | Reconstructs a type from a string that was previously obtained via StringUtils.ToString(T data)
TryParse(String,Type,Object) | Reconstructs a type from a string that was previously obtained via StringUtils.ToString(T data)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members


%%PageItemTitle%%

TYPE
[image]
CSharpTest.Net
TryParse<TYPE>(String,TYPE) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class > TryParse Method : TryParse<TYPE>(String,TYPE) Method

input
value

Glossary Item Box

Reconstructs a type from a string that was previously obtained via StringUtils.ToString(T data)

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function TryParse(Of TYPE)( _
   ByVal input As String, _
   ByRef value As TYPE _
) As Boolean
C#
public static bool TryParse<TYPE>(
   string input,
   out TYPE value
)

Parameters

input
value

Type Parameters

TYPE

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members
Overload List

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryParse(String,Type,Object) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class > TryParse Method : TryParse(String,Type,Object) Method

input
type
value

Glossary Item Box

Reconstructs a type from a string that was previously obtained via StringUtils.ToString(T data)

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function TryParse( _
   ByVal input As String, _
   ByVal type As Type, _
   ByRef value As Object _
) As Boolean
C#
public static bool TryParse(
   string input,
   Type type,
   out object value
)

Parameters

input
type
value

Example

Library/Library.Test/TestStringUtils.cs

C# Copy Code
Assert.AreEqual("5.1", StringUtils.ToString<double>(5.1));
Assert.AreEqual("5.1", StringUtils.ToString((object)new Version(5, 1)));

int ival;
object oval;

Assert.IsTrue(StringUtils.TryParse("1", out ival));
Assert.AreEqual(1, ival);

Assert.IsTrue(StringUtils.TryParse("1", typeof(int), out oval));
Assert.AreEqual(1, oval);
VB.NET Copy Code
Assert.AreEqual("5.1", StringUtils.ToString(Of Double)(5.1))
Assert.AreEqual("5.1", StringUtils.ToString(DirectCast(New Version(5, 1), Object)))

Dim ival As Integer
Dim oval As Object

Assert.IsTrue(StringUtils.TryParse("1", ival))
Assert.AreEqual(1, ival)

Assert.IsTrue(StringUtils.TryParse("1", GetType(Integer), oval))
Assert.AreEqual(1, oval)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringUtils Class
StringUtils Members
Overload List

Used By

Object Storage.GetValue(String,Type,Object)
Boolean Storage.TryGetValue(String,Type,Object)

Source Code

Library/Utils/StringUtils.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
WeakReference<T> Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : WeakReference<T> Class

Glossary Item Box

A strong-typed derivation of the WeakReference class

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class WeakReference(Of T As Class)
   Inherits System.WeakReference
C#
[SerializableAttribute()]
public class WeakReference<T> : System.WeakReference
where T: class

Type Parameters

T

Example

Library/Library.Test/TestWeakReferenceT.cs

C# Copy Code
string value1 = "Testing Value - 1";
object value2 = new MyObject();
Utils.WeakReference<string> r = new Utils.WeakReference<string>(value1);

string tmp;
Assert.IsTrue(r.TryGetTarget(out tmp) && tmp == value1);

((WeakReference)r).Target = value2; //incorrect type...
Assert.IsFalse(r.IsAlive);
Assert.IsNull(r.Target);
Assert.IsFalse(r.TryGetTarget(out tmp));

Assert.IsTrue(ReferenceEquals(value2, ((WeakReference)r).Target));
VB.NET Copy Code
Dim value1 As String = "Testing Value - 1"
Dim value2 As Object = New MyObject()
Dim r As New Utils.WeakReference(Of String)(value1)

Dim tmp As String
Assert.IsTrue(r.TryGetTarget(tmp) AndAlso tmp = value1)

(DirectCast(r, WeakReference)).Target = value2
'incorrect type...
Assert.IsFalse(r.IsAlive)
Assert.IsNull(r.Target)
Assert.IsFalse(r.TryGetTarget(tmp))

Assert.IsTrue(ReferenceEquals(value2, (DirectCast(r, WeakReference)).Target))

Inheritance Hierarchy

System.Object
System.WeakReference
CSharpTest.Net.Utils.WeakReference<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WeakReference<T> Members
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/WeakReference.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
WeakReference<T> Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : WeakReference<T> Class

Glossary Item Box

The following tables list the members exposed by WeakReference<T>.

Public Constructors

 | Name | Description
Public Constructor | WeakReference<T> Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | IsAlive | Overridden. Gets an indication whether the object referenced by the current object has been garbage collected.
Public Property | Target | Gets or sets the Object stored in the handle if it's accessible.
Public Property | TrackResurrection | Gets an indication whether the object referenced by the current System.WeakReference object is tracked after it is finalized. (Inherited from System.WeakReference)
Top

Public Methods

 | Name | Description
Public Method | GetObjectData | Populates a System.Runtime.Serialization.SerializationInfo object with all the data needed to serialize the current System.WeakReference object. (Inherited from System.WeakReference)
Public Method | TryGetTarget | Returns true if the Object was retrieved.
Top

See Also

Reference

WeakReference<T> Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/WeakReference.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WeakReference<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > WeakReference<T> Class : WeakReference<T> Constructor

Glossary Item Box

Overload List

Overload | Description
WeakReference<T> Constructor(T) | Creates a new WeakReference that keeps track of target.
WeakReference<T> Constructor(SerializationInfo,StreamingContext) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WeakReference<T> Class
WeakReference<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WeakReference<T> Constructor(T)
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > WeakReference<T> Class > WeakReference<T> Constructor : WeakReference<T> Constructor(T)

instance

Glossary Item Box

Creates a new WeakReference that keeps track of target.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal instance As T _
)
C#
public WeakReference<T>(
   T instance
)

Parameters

instance

Example

Library/Library.Test/TestWeakReferenceT.cs

C# Copy Code
string value1 = "Testing Value - 1";
object value2 = new MyObject();
Utils.WeakReference<string> r = new Utils.WeakReference<string>(value1);

string tmp;
Assert.IsTrue(r.TryGetTarget(out tmp) && tmp == value1);

((WeakReference)r).Target = value2; //incorrect type...
Assert.IsFalse(r.IsAlive);
Assert.IsNull(r.Target);
Assert.IsFalse(r.TryGetTarget(out tmp));

Assert.IsTrue(ReferenceEquals(value2, ((WeakReference)r).Target));
VB.NET Copy Code
Dim value1 As String = "Testing Value - 1"
Dim value2 As Object = New MyObject()
Dim r As New Utils.WeakReference(Of String)(value1)

Dim tmp As String
Assert.IsTrue(r.TryGetTarget(tmp) AndAlso tmp = value1)

(DirectCast(r, WeakReference)).Target = value2
'incorrect type...
Assert.IsFalse(r.IsAlive)
Assert.IsNull(r.Target)
Assert.IsFalse(r.TryGetTarget(tmp))

Assert.IsTrue(ReferenceEquals(value2, (DirectCast(r, WeakReference)).Target))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WeakReference<T> Class
WeakReference<T> Members
Overload List

Source Code

Library/Utils/WeakReference.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WeakReference<T> Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > WeakReference<T> Class > WeakReference<T> Constructor : WeakReference<T> Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected WeakReference<T>(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WeakReference<T> Class
WeakReference<T> Members
Overload List


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
WeakReference<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : WeakReference<T> Class

Glossary Item Box

For a list of all members of this type, see WeakReference<T> members.

Public Methods

 | Name | Description
Public Method | GetObjectData | Populates a System.Runtime.Serialization.SerializationInfo object with all the data needed to serialize the current System.WeakReference object. (Inherited from System.WeakReference)
Public Method | TryGetTarget | Returns true if the Object was retrieved.
Top

See Also

Reference

WeakReference<T> Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/WeakReference.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TryGetTarget Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > WeakReference<T> Class : TryGetTarget Method

value

Glossary Item Box

Returns true if the Object was retrieved.

Syntax

Visual Basic (Declaration)
Public Function TryGetTarget( _
   ByRef value As T _
) As Boolean
C#
public bool TryGetTarget(
   out T value
)

Parameters

value

Example

Library/Library.Test/TestWeakReferenceT.cs

C# Copy Code
string value1 = "Testing Value - 1";
object value2 = new MyObject();
Utils.WeakReference<string> r = new Utils.WeakReference<string>(value1);

string tmp;
Assert.IsTrue(r.TryGetTarget(out tmp) && tmp == value1);

((WeakReference)r).Target = value2; //incorrect type...
Assert.IsFalse(r.IsAlive);
Assert.IsNull(r.Target);
Assert.IsFalse(r.TryGetTarget(out tmp));

Assert.IsTrue(ReferenceEquals(value2, ((WeakReference)r).Target));
VB.NET Copy Code
Dim value1 As String = "Testing Value - 1"
Dim value2 As Object = New MyObject()
Dim r As New Utils.WeakReference(Of String)(value1)

Dim tmp As String
Assert.IsTrue(r.TryGetTarget(tmp) AndAlso tmp = value1)

(DirectCast(r, WeakReference)).Target = value2
'incorrect type...
Assert.IsFalse(r.IsAlive)
Assert.IsNull(r.Target)
Assert.IsFalse(r.TryGetTarget(tmp))

Assert.IsTrue(ReferenceEquals(value2, (DirectCast(r, WeakReference)).Target))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WeakReference<T> Class
WeakReference<T> Members

Source Code

Library/Utils/WeakReference.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
WeakReference<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : WeakReference<T> Class

Glossary Item Box

For a list of all members of this type, see WeakReference<T> members.

Public Properties

 | Name | Description
Public Property | IsAlive | Overridden. Gets an indication whether the object referenced by the current object has been garbage collected.
Public Property | Target | Gets or sets the Object stored in the handle if it's accessible.
Public Property | TrackResurrection | Gets an indication whether the object referenced by the current System.WeakReference object is tracked after it is finalized. (Inherited from System.WeakReference)
Top

See Also

Reference

WeakReference<T> Class
CSharpTest.Net.Utils Namespace

Source Code

Library/Utils/WeakReference.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsAlive Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > WeakReference<T> Class : IsAlive Property

Glossary Item Box

Gets an indication whether the object referenced by the current object has been garbage collected.

Syntax

Visual Basic (Declaration)
Public Overrides ReadOnly Property IsAlive As Boolean
C#
public override bool IsAlive {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WeakReference<T> Class
WeakReference<T> Members
Base Implementation in IsAlive

Source Code

Library/Utils/WeakReference.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Target Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > WeakReference<T> Class : Target Property

Glossary Item Box

Gets or sets the Object stored in the handle if it's accessible.

Syntax

Visual Basic (Declaration)
Public Shadows Property Target As T
C#
public new T Target {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WeakReference<T> Class
WeakReference<T> Members

Source Code

Library/Utils/WeakReference.cs


%%PageItemTitle%%

T
[image]
CSharpTest.Net
XmlConfiguration<T> Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : XmlConfiguration<T> Class

Glossary Item Box

This is basically a big hack on the whole configuration system, it's purpose is to avoid the entire thing. Where argument T is any [XmlSerializable] object this class can deserialize it from the configuration file. It looks for an xsd either embeded into typeof(T).Assembly or in the local filesystem. The Xsd must be named typeof(T).FullName + ".xsd" to be found by this class. If found validation will occur durring the deserialization process and an exception of type XmlException() will be raised on errors. Optionally, you can directly set the schema via the static XmlSchema property.

Syntax

Visual Basic (Declaration)
Public Class XmlConfiguration(Of T)
   Inherits System.Configuration.ConfigurationSection
C#
public class XmlConfiguration<T> : System.Configuration.ConfigurationSection

Type Parameters

T

Inheritance Hierarchy

System.Object
System.Configuration.ConfigurationElement
System.Configuration.ConfigurationSection
CSharpTest.Net.Utils.XmlConfiguration<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Members
CSharpTest.Net.Utils Namespace

Source Code

Shared/Configuration.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
XmlConfiguration<T> Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : XmlConfiguration<T> Class

Glossary Item Box

The following tables list the members exposed by XmlConfiguration<T>.

Public Constructors

 | Name | Description
Public Constructor | XmlConfiguration<T> Constructor | Overloaded.
Top

Public Fields

 | Name | Description
static (Shared in Visual Basic) | XmlSchema | Allows explicit setting of the XmlSchema to use when validating the xml input.
Top

Public Properties

 | Name | Description
Public Property | ElementInformation | Gets an System.Configuration.ElementInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllAttributesExcept | Gets the collection of locked attributes. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllElementsExcept | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAttributes | Gets the collection of locked attributes (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockElements | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockItem | Gets or sets a value indicating whether the element is locked. (Inherited from System.Configuration.ConfigurationElement)
Public Property | SectionInformation | Gets a System.Configuration.SectionInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationSection object. (Inherited from System.Configuration.ConfigurationSection)
Public Property | Settings | Allows access to the deserialized data
Top

Protected Properties

 | Name | Description
Protected Property | EvaluationContext | Gets the System.Configuration.ContextInformation object for the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Top

Public Methods

 | Name | Description
Public Method | IsReadOnly | Gets a value indicating whether the System.Configuration.ConfigurationElement object is read-only. (Inherited from System.Configuration.ConfigurationElement)
static (Shared in Visual Basic) | ReadConfig | Reads and extracts the configuration settings from the current application's configuraiton file
static (Shared in Visual Basic) | ReadXml | Overloaded. Deserialize the xml configuration directly from an XmlReader instance
Top

Protected Methods

 | Name | Description
Protected Method | DeserializeSection | Overridden. The main work goes here, builds the reader and validator and deserializes the object.
Protected Method | ListErrors | Adds the invalid-property errors in this System.Configuration.ConfigurationElement object, and in all subelements, to the passed list. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedAttribute | Gets a value indicating whether an unknown attribute is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedElement | Gets a value indicating whether an unknown element is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnRequiredPropertyNotFound | Throws an exception when a required property is not found. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PostDeserialize | Called after deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PreSerialize | Called before serialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | ReadComplete | Provides a derived class with the ability to do post-read validation not represented in the xsd (or in place of an xsd).
Protected Method | SetPropertyValue | Sets a property to the specified value. (Inherited from System.Configuration.ConfigurationElement)
Top

Public Operators

public Operator Implicit Type Conversion Allows implicit casting of the configuration element to the actual type contained.
Top

See Also

Reference

XmlConfiguration<T> Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/Configuration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlConfiguration<T> Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class : XmlConfiguration<T> Constructor

Glossary Item Box

Overload List

Overload | Description
XmlConfiguration<T> Constructor() | Constructs the XmlConfiguration element assuming that the derived type name is the same name as the xsd file name, i.e. "MyCfg : XmlConfiguration" would expect an XSD named "MyCfg.xsd" to either exist on disk or be embeded into the type's containing assembly.
XmlConfiguration<T> Constructor(String) | Explicitly sets the xsd file name to use.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlConfiguration<T> Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class > XmlConfiguration<T> Constructor : XmlConfiguration<T> Constructor()

Glossary Item Box

Constructs the XmlConfiguration element assuming that the derived type name is the same name as the xsd file name, i.e. "MyCfg : XmlConfiguration" would expect an XSD named "MyCfg.xsd" to either exist on disk or be embeded into the type's containing assembly.

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public XmlConfiguration<T>()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members
Overload List

Source Code

Shared/Configuration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlConfiguration<T> Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class > XmlConfiguration<T> Constructor : XmlConfiguration<T> Constructor(String)

schemaName

Glossary Item Box

Explicitly sets the xsd file name to use.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal schemaName As String _
)
C#
public XmlConfiguration<T>(
   string schemaName
)

Parameters

schemaName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members
Overload List

Source Code

Shared/Configuration.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
XmlConfiguration<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : XmlConfiguration<T> Class

Glossary Item Box

For a list of all members of this type, see XmlConfiguration<T> members.

Public Methods

 | Name | Description
Public Method | IsReadOnly | Gets a value indicating whether the System.Configuration.ConfigurationElement object is read-only. (Inherited from System.Configuration.ConfigurationElement)
static (Shared in Visual Basic) | ReadConfig | Reads and extracts the configuration settings from the current application's configuraiton file
static (Shared in Visual Basic) | ReadXml | Overloaded. Deserialize the xml configuration directly from an XmlReader instance
Top

Protected Methods

 | Name | Description
Protected Method | DeserializeSection | Overridden. The main work goes here, builds the reader and validator and deserializes the object.
Protected Method | ListErrors | Adds the invalid-property errors in this System.Configuration.ConfigurationElement object, and in all subelements, to the passed list. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedAttribute | Gets a value indicating whether an unknown attribute is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnDeserializeUnrecognizedElement | Gets a value indicating whether an unknown element is encountered during deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | OnRequiredPropertyNotFound | Throws an exception when a required property is not found. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PostDeserialize | Called after deserialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | PreSerialize | Called before serialization. (Inherited from System.Configuration.ConfigurationElement)
Protected Method | ReadComplete | Provides a derived class with the ability to do post-read validation not represented in the xsd (or in place of an xsd).
Protected Method | SetPropertyValue | Sets a property to the specified value. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

XmlConfiguration<T> Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/Configuration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DeserializeSection Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class : DeserializeSection Method

reader

Glossary Item Box

The main work goes here, builds the reader and validator and deserializes the object.

Syntax

Visual Basic (Declaration)
Protected Overrides Sub DeserializeSection( _
   ByVal reader As XmlReader _
)
C#
protected override void DeserializeSection(
   XmlReader reader
)

Parameters

reader

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members
Base Implementation in DeserializeSection


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadComplete Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class : ReadComplete Method

data

Glossary Item Box

Provides a derived class with the ability to do post-read validation not represented in the xsd (or in place of an xsd).

Syntax

Visual Basic (Declaration)
Protected Overridable Function ReadComplete( _
   ByVal data As T _
) As T
C#
protected virtual T ReadComplete(
   T data
)

Parameters

data

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadConfig Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class : ReadConfig Method

sectionName

Glossary Item Box

Reads and extracts the configuration settings from the current application's configuraiton file

Syntax

Visual Basic (Declaration)
Public Shared Function ReadConfig( _
   ByVal sectionName As String _
) As T
C#
public static T ReadConfig(
   string sectionName
)

Parameters

sectionName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members

Source Code

Shared/Configuration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadXml Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class : ReadXml Method

Glossary Item Box

Deserialize the xml configuration directly from an XmlReader instance

Overload List

Overload | Description
ReadXml(XmlReader) | Deserialize the xml configuration directly from an XmlReader instance
ReadXml(String,XmlReader) | Deserialize the xml configuration directly from an XmlReader instance

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadXml(XmlReader) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class > ReadXml Method : ReadXml(XmlReader) Method

reader

Glossary Item Box

Deserialize the xml configuration directly from an XmlReader instance

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function ReadXml( _
   ByVal reader As XmlReader _
) As T
C#
public static T ReadXml(
   XmlReader reader
)

Parameters

reader

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members
Overload List

Source Code

Shared/Configuration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadXml(String,XmlReader) Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class > ReadXml Method : ReadXml(String,XmlReader) Method

schemaFile
reader

Glossary Item Box

Deserialize the xml configuration directly from an XmlReader instance

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function ReadXml( _
   ByVal schemaFile As String, _
   ByVal reader As XmlReader _
) As T
C#
public static T ReadXml(
   string schemaFile,
   XmlReader reader
)

Parameters

schemaFile
reader

Exceptions

Exception | Description
System.Xml.XmlException | Returns detailed information about the last exception.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members
Overload List

Used By

T XmlConfiguration.ReadXml(XmlReader)

Source Code

Shared/Configuration.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
XmlConfiguration<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : XmlConfiguration<T> Class

Glossary Item Box

For a list of all members of this type, see XmlConfiguration<T> members.

Public Properties

 | Name | Description
Public Property | ElementInformation | Gets an System.Configuration.ElementInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllAttributesExcept | Gets the collection of locked attributes. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAllElementsExcept | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockAttributes | Gets the collection of locked attributes (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockElements | Gets the collection of locked elements. (Inherited from System.Configuration.ConfigurationElement)
Public Property | LockItem | Gets or sets a value indicating whether the element is locked. (Inherited from System.Configuration.ConfigurationElement)
Public Property | SectionInformation | Gets a System.Configuration.SectionInformation object that contains the non-customizable information and functionality of the System.Configuration.ConfigurationSection object. (Inherited from System.Configuration.ConfigurationSection)
Public Property | Settings | Allows access to the deserialized data
Top

Protected Properties

 | Name | Description
Protected Property | EvaluationContext | Gets the System.Configuration.ContextInformation object for the System.Configuration.ConfigurationElement object. (Inherited from System.Configuration.ConfigurationElement)
Top

See Also

Reference

XmlConfiguration<T> Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/Configuration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Settings Property
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class : Settings Property

Glossary Item Box

Allows access to the deserialized data

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Settings As T
C#
public T Settings {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members

Source Code

Shared/Configuration.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
XmlConfiguration<T> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : XmlConfiguration<T> Class

Glossary Item Box

For a list of all members of this type, see XmlConfiguration<T> members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | XmlSchema | Allows explicit setting of the XmlSchema to use when validating the xml input.
Top

See Also

Reference

XmlConfiguration<T> Class
CSharpTest.Net.Utils Namespace

Source Code

Shared/Configuration.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlSchema Field
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class : XmlSchema Field

Glossary Item Box

Allows explicit setting of the XmlSchema to use when validating the xml input.

Syntax

Visual Basic (Declaration)
Public Shared XmlSchema As XmlSchema
C#
public static XmlSchema XmlSchema

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members

Used By

T XmlConfiguration.ReadXml(String,XmlReader)


%%PageItemTitle%%

[image]
CSharpTest.Net
Implicit Type Conversion Operator
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > XmlConfiguration<T> Class : Implicit Type Conversion Operator

o

Glossary Item Box

Allows implicit casting of the configuration element to the actual type contained.

Syntax

Visual Basic (Declaration)
Public Operator Widening CType( _
   ByVal o As XmlConfiguration(Of T) _
) As T
C#
public T operator implicit(
   XmlConfiguration<T> o
)

Parameters

o

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlConfiguration<T> Class
XmlConfiguration<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
IObjectKeepAlive Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : IObjectKeepAlive Interface

Glossary Item Box

Provides an interface for tracking a limited number of references to objects for use in a WeakReference cache.

Syntax

Visual Basic (Declaration)
Public Interface IObjectKeepAlive
C#
public interface IObjectKeepAlive

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IObjectKeepAlive Members
CSharpTest.Net.Utils Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IObjectKeepAlive Interface Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : IObjectKeepAlive Interface

Glossary Item Box

The following tables list the members exposed by IObjectKeepAlive.

Public Methods

 | Name | Description
Method | Add | Cleans up expired items and adds the object to the list of items to keep alive.
Method | Clear | Clears the entire keep-alive cache
Method | Tick | Can be called periodically by external threads to ensure cleanup instead of depending upon calls to Add()
Top

See Also

Reference

IObjectKeepAlive Interface
CSharpTest.Net.Utils Namespace


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IObjectKeepAlive Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : IObjectKeepAlive Interface

Glossary Item Box

For a list of all members of this type, see IObjectKeepAlive members.

Public Methods

 | Name | Description
Method | Add | Cleans up expired items and adds the object to the list of items to keep alive.
Method | Clear | Clears the entire keep-alive cache
Method | Tick | Can be called periodically by external threads to ensure cleanup instead of depending upon calls to Add()
Top

See Also

Reference

IObjectKeepAlive Interface
CSharpTest.Net.Utils Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > IObjectKeepAlive Interface : Add Method

item

Glossary Item Box

Cleans up expired items and adds the object to the list of items to keep alive.

Syntax

Visual Basic (Declaration)
Sub Add( _
   ByVal item As Object _
)
C#
void Add(
   object item
)

Parameters

item

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IObjectKeepAlive Interface
IObjectKeepAlive Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Clear Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > IObjectKeepAlive Interface : Clear Method

Glossary Item Box

Clears the entire keep-alive cache

Syntax

Visual Basic (Declaration)
Sub Clear()
C#
void Clear()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IObjectKeepAlive Interface
IObjectKeepAlive Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Tick Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > IObjectKeepAlive Interface : Tick Method

Glossary Item Box

Can be called periodically by external threads to ensure cleanup instead of depending upon calls to Add()

Syntax

Visual Basic (Declaration)
Sub Tick()
C#
void Tick()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IObjectKeepAlive Interface
IObjectKeepAlive Members


%%PageItemTitle%%

TYPE
[image]
CSharpTest.Net
StringConverter.TryParseMethod<TYPE> Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace : StringConverter.TryParseMethod<TYPE> Delegate

text
value

Glossary Item Box

The delegate type used to try and parse a string

Syntax

Visual Basic (Declaration)
Public Delegate Function StringConverter.TryParseMethod(Of TYPE)( _
   ByVal text As String, _
   ByRef value As TYPE _
) As Boolean
C#
public delegate bool StringConverter.TryParseMethod<TYPE>(
   string text,
   out TYPE value
)

Parameters

text
value

Type Parameters

TYPE

Example

Library/Library.Test/TestStringConvert.cs

C# Copy Code
DateTime date = new DateTime(2000, 1,2,3,4,5,6);
string dt = date.ToString();

StringConverter c = new StringConverter();

Assert.AreNotEqual(dt, c.ToString(date));

c.Add<DateTime>(DateTime.TryParse, delegate(DateTime value) { return value.ToString(); });

Assert.AreEqual(dt, c.ToString(date));
VB.NET Copy Code
Dim [date] As New DateTime(2000, 1, 2, 3, 4, 5, _
    6)
Dim dt As String = [date].ToString()

Dim c As New StringConverter()

Assert.AreNotEqual(dt, c.ToString([date]))

c.Add(Of DateTime)(DateTime.TryParse, Function(value As DateTime) Do
    Return value.ToString()
End Function)

Assert.AreEqual(dt, c.ToString([date]))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StringConverter.TryParseMethod<TYPE> Members
CSharpTest.Net.Utils Namespace


%%ItemTitle%%

CSharpTest.Net.WinForms Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.WinForms Namespace

Glossary Item Box

Classes

 | Class | Description
Class | Win32Window | Provides a Windows.Forms implementation of the IWin32Window inteface for windows owned by a non-.Net window handle.

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
Win32Window Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.WinForms Namespace : Win32Window Class

Glossary Item Box

Provides a Windows.Forms implementation of the IWin32Window inteface for windows owned by a non-.Net window handle.

Syntax

Visual Basic (Declaration)
Public Class Win32Window
C#
public class Win32Window

Inheritance Hierarchy

System.Object
CSharpTest.Net.WinForms.Win32Window

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Win32Window Members
CSharpTest.Net.WinForms Namespace

Source Code

Library/WinForms/Win32Window.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Win32Window Class Members
See Also Methods Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.WinForms Namespace : Win32Window Class

Glossary Item Box

The following tables list the members exposed by Win32Window.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | FromHandle | Constructs an IWin32Window from a valid handle or returns null if handle == IntPtr.Zero
Top

See Also

Reference

Win32Window Class
CSharpTest.Net.WinForms Namespace

Source Code

Library/WinForms/Win32Window.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Win32Window Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.WinForms Namespace : Win32Window Class

Glossary Item Box

For a list of all members of this type, see Win32Window members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | FromHandle | Constructs an IWin32Window from a valid handle or returns null if handle == IntPtr.Zero
Top

See Also

Reference

Win32Window Class
CSharpTest.Net.WinForms Namespace

Source Code

Library/WinForms/Win32Window.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FromHandle Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.WinForms Namespace > Win32Window Class : FromHandle Method

handle

Glossary Item Box

Constructs an IWin32Window from a valid handle or returns null if handle == IntPtr.Zero

Syntax

Visual Basic (Declaration)
Public Shared Function FromHandle( _
   ByVal handle As IntPtr _
) As IWin32Window
C#
public static IWin32Window FromHandle(
   IntPtr handle
)

Parameters

handle

Example

Library/Library.Test/TestWin32Window.cs

C# Copy Code
IntPtr ptr = new IntPtr(0x01000);//any number but zero

Assert.IsNotNull(Win32Window.FromHandle(ptr));
Assert.AreEqual(ptr, Win32Window.FromHandle(ptr).Handle);
VB.NET Copy Code
Dim ptr As New IntPtr(&H1000)
'any number but zero
Assert.IsNotNull(Win32Window.FromHandle(ptr))
Assert.AreEqual(ptr, Win32Window.FromHandle(ptr).Handle)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Win32Window Class
Win32Window Members

Source Code

Library/WinForms/Win32Window.cs


%%phrase%%

CSharpTest.Net.Logging Assembly
See Also Send Feedback Download Help File

Glossary Item Box

Namespaces

Namespace | Description
(Global) |
CSharpTest.Net.Logging |


%%ItemTitle%%

(Global) Namespace (CSharpTest.Net.Logging)
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Logging Assembly : (Global) Namespace

Glossary Item Box

Classes

 | Class | Description
Class | Log | Provides an abstraction api for logging to various outputs. This class in the global namespace for a reason. Since you may want to change log infrastructure at any time, it's important that no 'Using' statements are required to access the log infrastructure. Secondly, a static class api can provide improved performance over other possible types. We will be forcing the default configuration of log4net rather than requiring each component to independently configure itself.
Class | Log.Config | Provides configuration options for the Log subsystem

See Also

Reference

CSharpTest.Net.Logging Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
Log Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log Class

Glossary Item Box

Provides an abstraction api for logging to various outputs. This class in the global namespace for a reason. Since you may want to change log infrastructure at any time, it's important that no 'Using' statements are required to access the log infrastructure. Secondly, a static class api can provide improved performance over other possible types. We will be forcing the default configuration of log4net rather than requiring each component to independently configure itself.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class Log
C#
public static class Log

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Inheritance Hierarchy

System.Object
Log

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Members
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Log Class Members
See Also Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log Class

Glossary Item Box

The following tables list the members exposed by Log.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | IsInfoEnabled | Returns true if 'Info' messages are being recorded.
static (Shared in Visual Basic) | IsVerboseEnabled | Returns true if 'Verbose' messages are being recorded.
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | AppStart | Enables calls to Log.xxx() to be processed on another thread to improve throughput... Place this in a using() statement within Main: using( new Log.AppStart("Some Name") ) This call (and Disponse) IS Thread safe and can be called multiple times either concurrently, sequentially, nested, or overlapping calls are all permitted and handled.
static (Shared in Visual Basic) | ClearStack | Forces any left-behind calls to Start() to be closed.
static (Shared in Visual Basic) | Critical | Overloaded. Logs a Critical error
static (Shared in Visual Basic) | Error | Overloaded. Logs an Error
static (Shared in Visual Basic) | Info | Overloaded. Logs a Info error
static (Shared in Visual Basic) | Start | Pushes a string into the trace stack so that log messages appear with the 'context' set to the information provided. The operation named should be performed by the current thread and the IDisposable object returned should be disposed when the operation completes.
static (Shared in Visual Basic) | Verbose | Overloaded. Logs a Verbose error
static (Shared in Visual Basic) | Warning | Overloaded. Logs a Warning
static (Shared in Visual Basic) | Write | Write directly to the log reguardless of the currently configured log-LogLevel
Top

Public Events

 | Name | Description
Public Event | LogWrite | This event is raised when the logging routines are called and the LogLevel is at or higher than the current Log.LogLevels field value.
Top

See Also

Reference

Log Class
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Log Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log Class

Glossary Item Box

For a list of all members of this type, see Log members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | AppStart | Enables calls to Log.xxx() to be processed on another thread to improve throughput... Place this in a using() statement within Main: using( new Log.AppStart("Some Name") ) This call (and Disponse) IS Thread safe and can be called multiple times either concurrently, sequentially, nested, or overlapping calls are all permitted and handled.
static (Shared in Visual Basic) | ClearStack | Forces any left-behind calls to Start() to be closed.
static (Shared in Visual Basic) | Critical | Overloaded. Logs a Critical error
static (Shared in Visual Basic) | Error | Overloaded. Logs an Error
static (Shared in Visual Basic) | Info | Overloaded. Logs a Info error
static (Shared in Visual Basic) | Start | Pushes a string into the trace stack so that log messages appear with the 'context' set to the information provided. The operation named should be performed by the current thread and the IDisposable object returned should be disposed when the operation completes.
static (Shared in Visual Basic) | Verbose | Overloaded. Logs a Verbose error
static (Shared in Visual Basic) | Warning | Overloaded. Logs a Warning
static (Shared in Visual Basic) | Write | Write directly to the log reguardless of the currently configured log-LogLevel
Top

See Also

Reference

Log Class
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AppStart Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : AppStart Method

format
args

Glossary Item Box

Enables calls to Log.xxx() to be processed on another thread to improve throughput... Place this in a using() statement within Main: using( new Log.AppStart("Some Name") ) This call (and Disponse) IS Thread safe and can be called multiple times either concurrently, sequentially, nested, or overlapping calls are all permitted and handled.

Syntax

Visual Basic (Declaration)
Public Shared Function AppStart( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
) As IDisposable
C#
public static IDisposable AppStart(
   string format,
   params object[] args
)

Parameters

format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClearStack Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : ClearStack Method

Glossary Item Box

Forces any left-behind calls to Start() to be closed.

Syntax

Visual Basic (Declaration)
Public Shared Sub ClearStack()
C#
public static void ClearStack()

Example

Log/Test/BasicLogTest.cs

C# Copy Code
Log.Write(UniqueData);
EventData msg = LastMessage;
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);

using (Log.Start(UniqueData))
{
    msg = LastMessage;
    Assert.AreEqual("Start " + UniqueData, msg.Message);
    Assert.AreEqual(UniqueData, msg.LogCurrent);
    Assert.AreEqual(msg.LogCurrent, msg.LogStack);

    Log.ClearStack();
    Log.Warning("Stack cleared");
    msg = LastMessage;
    Assert.IsNull(msg.LogCurrent);
    Assert.IsNull(msg.LogStack);
}

//no message generated.
Assert.AreEqual(0, _lastMessages.Count);
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);
VB.NET Copy Code
Log.Write(UniqueData)
Dim msg As EventData = LastMessage
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)

Using Log.Start(UniqueData)
    msg = LastMessage
    Assert.AreEqual("Start " + UniqueData, msg.Message)
    Assert.AreEqual(UniqueData, msg.LogCurrent)
    Assert.AreEqual(msg.LogCurrent, msg.LogStack)

    Log.ClearStack()
    Log.Warning("Stack cleared")
    msg = LastMessage
    Assert.IsNull(msg.LogCurrent)
    Assert.IsNull(msg.LogStack)
End Using

'no message generated.
Assert.AreEqual(0, _lastMessages.Count)
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Critical Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : Critical Method

Glossary Item Box

Logs a Critical error

Overload List

Overload | Description
Critical(Exception) | Logs a Critical error
Critical(Exception,String,Object[]) | Logs a Critical error
Critical(String,Object[]) | Logs a Critical error

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Critical(Exception) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Critical Method : Critical(Exception) Method

e

Glossary Item Box

Logs a Critical error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Critical( _
   ByVal e As Exception _
)
C#
public static void Critical(
   Exception e
)

Parameters

e

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Critical(Exception,String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Critical Method : Critical(Exception,String,Object[]) Method

e
format
args

Glossary Item Box

Logs a Critical error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Critical( _
   ByVal e As Exception, _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Critical(
   Exception e,
   string format,
   params object[] args
)

Parameters

e
format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Critical(String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Critical Method : Critical(String,Object[]) Method

format
args

Glossary Item Box

Logs a Critical error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Critical( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Critical(
   string format,
   params object[] args
)

Parameters

format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Error Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : Error Method

Glossary Item Box

Logs an Error

Overload List

Overload | Description
Error(Exception) | Logs an Error
Error(Exception,String,Object[]) | Logs an Error
Error(String,Object[]) | Logs an Error

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Error(Exception) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Error Method : Error(Exception) Method

e

Glossary Item Box

Logs an Error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Error( _
   ByVal e As Exception _
)
C#
public static void Error(
   Exception e
)

Parameters

e

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Error(Exception,String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Error Method : Error(Exception,String,Object[]) Method

e
format
args

Glossary Item Box

Logs an Error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Error( _
   ByVal e As Exception, _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Error(
   Exception e,
   string format,
   params object[] args
)

Parameters

e
format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Error(String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Error Method : Error(String,Object[]) Method

format
args

Glossary Item Box

Logs an Error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Error( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Error(
   string format,
   params object[] args
)

Parameters

format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Info Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : Info Method

Glossary Item Box

Logs a Info error

Overload List

Overload | Description
Info(Exception) | Logs a Info error
Info(Exception,String,Object[]) | Logs a Info error
Info(String,Object[]) | Logs an Informational message

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Info(Exception) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Info Method : Info(Exception) Method

e

Glossary Item Box

Logs a Info error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Info( _
   ByVal e As Exception _
)
C#
public static void Info(
   Exception e
)

Parameters

e

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Info(Exception,String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Info Method : Info(Exception,String,Object[]) Method

e
format
args

Glossary Item Box

Logs a Info error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Info( _
   ByVal e As Exception, _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Info(
   Exception e,
   string format,
   params object[] args
)

Parameters

e
format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Info(String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Info Method : Info(String,Object[]) Method

format
args

Glossary Item Box

Logs an Informational message

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Info( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Info(
   string format,
   params object[] args
)

Parameters

format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : Start Method

format
args

Glossary Item Box

Pushes a string into the trace stack so that log messages appear with the 'context' set to the information provided. The operation named should be performed by the current thread and the IDisposable object returned should be disposed when the operation completes.

Syntax

Visual Basic (Declaration)
Public Shared Function Start( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
) As IDisposable
C#
public static IDisposable Start(
   string format,
   params object[] args
)

Parameters

format
args

Return Value

An IDisposable object that should be destroyed by calling the Dispose() method when the activity is complete.

Example

Log/Test/ThreadedLogTest.cs

C# Copy Code
Log.LogWrite += new LogEventHandler(Block_LogWrite);
try
{
    using (Log.Start("Blocking Test"))
    {
        //the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, false));

        //regaurdless, we should still get the first message
        EventData msg = NextMessage;
        Assert.AreEqual("Start Blocking Test", msg.Message);

        //Now let's just go nuts on the logger...
        for (int i = 0; i < 100; i++)
            Log.Write("Buffering at {0}%.", i);

        Thread.Sleep(100);
        Assert.AreEqual(0, _lastMessages.Count);
        _releaseBlock.Set();
        Thread.Sleep(100);
        Assert.IsFalse(_isBlocked.WaitOne(0, false));

        for (int i = 0; i < 100; i++)
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"));
    }
}
finally
{
    Log.LogWrite -= new LogEventHandler(Block_LogWrite);
}
VB.NET Copy Code
Log.LogWrite += New LogEventHandler(Block_LogWrite)
Try
    Using Log.Start("Blocking Test")
        'the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, False))

        'regaurdless, we should still get the first message
        Dim msg As EventData = NextMessage
        Assert.AreEqual("Start Blocking Test", msg.Message)

        'Now let's just go nuts on the logger...
        Dim i As Integer = 0
        While i < 100
            Log.Write("Buffering at {0}%.", i)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Thread.Sleep(100)
        Assert.AreEqual(0, _lastMessages.Count)
        _releaseBlock.[Set]()
        Thread.Sleep(100)
        Assert.IsFalse(_isBlocked.WaitOne(0, False))

        Dim i As Integer = 0
        While i < 100
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
Finally
    Log.LogWrite -= New LogEventHandler(Block_LogWrite)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Verbose Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : Verbose Method

Glossary Item Box

Logs a Verbose error

Overload List

Overload | Description
Verbose(Exception) | Logs a Verbose error
Verbose(Exception,String,Object[]) | Logs a Verbose error
Verbose(String,Object[]) | Logs a Verbose message

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Verbose(Exception) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Verbose Method : Verbose(Exception) Method

e

Glossary Item Box

Logs a Verbose error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Verbose( _
   ByVal e As Exception _
)
C#
public static void Verbose(
   Exception e
)

Parameters

e

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Verbose(Exception,String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Verbose Method : Verbose(Exception,String,Object[]) Method

e
format
args

Glossary Item Box

Logs a Verbose error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Verbose( _
   ByVal e As Exception, _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Verbose(
   Exception e,
   string format,
   params object[] args
)

Parameters

e
format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Verbose(String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Verbose Method : Verbose(String,Object[]) Method

format
args

Glossary Item Box

Logs a Verbose message

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Verbose( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Verbose(
   string format,
   params object[] args
)

Parameters

format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Warning Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : Warning Method

Glossary Item Box

Logs a Warning

Overload List

Overload | Description
Warning(Exception) | Logs a Warning
Warning(Exception,String,Object[]) | Logs a Warning
Warning(String,Object[]) | Logs a Warning

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Warning(Exception) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Warning Method : Warning(Exception) Method

e

Glossary Item Box

Logs a Warning

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Warning( _
   ByVal e As Exception _
)
C#
public static void Warning(
   Exception e
)

Parameters

e

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Warning(Exception,String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Warning Method : Warning(Exception,String,Object[]) Method

e
format
args

Glossary Item Box

Logs a Warning

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Warning( _
   ByVal e As Exception, _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Warning(
   Exception e,
   string format,
   params object[] args
)

Parameters

e
format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Warning(String,Object[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class > Warning Method : Warning(String,Object[]) Method

format
args

Glossary Item Box

Logs a Warning

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Warning( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Warning(
   string format,
   params object[] args
)

Parameters

format
args

Example

Log/Test/NegativeTests.cs

C# Copy Code
IDisposable disp = Log.AppStart(null);
disp.Dispose();
disp.Dispose();
foreach( string format in badFormats )
    Log.AppStart(format, i_blow_up).Dispose();

disp = Log.Start(null);
disp.Dispose();
disp.Dispose();
foreach (string format in badFormats)
    Log.AppStart(format, i_blow_up).Dispose();

foreach (string format in badFormats)
    Log.Write(format, i_blow_up);

foreach (string format in badFormats)
    Log.Critical(format, i_blow_up);
foreach (string format in badFormats)
    Log.Critical(i_blow_up, format, i_blow_up);
Log.Critical(i_blow_up);

foreach (string format in badFormats)
    Log.Error(format, i_blow_up);
foreach (string format in badFormats)
    Log.Error(i_blow_up, format, i_blow_up);
Log.Error(i_blow_up);

foreach (string format in badFormats)
    Log.Warning(format, i_blow_up);
foreach (string format in badFormats)
    Log.Warning(i_blow_up, format, i_blow_up);
Log.Warning(i_blow_up);

foreach (string format in badFormats)
    Log.Info(format, i_blow_up);
foreach (string format in badFormats)
    Log.Info(i_blow_up, format, i_blow_up);
Log.Info(i_blow_up);

foreach (string format in badFormats)
    Log.Verbose(format, i_blow_up);
foreach (string format in badFormats)
    Log.Verbose(i_blow_up, format, i_blow_up);
Log.Verbose(i_blow_up);
VB.NET Copy Code
Dim disp As IDisposable = Log.AppStart(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

disp = Log.Start(Nothing)
disp.Dispose()
disp.Dispose()
For Each format As String In badFormats
    Log.AppStart(format, i_blow_up).Dispose()
Next

For Each format As String In badFormats
    Log.Write(format, i_blow_up)
Next

For Each format As String In badFormats
    Log.Critical(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Critical(i_blow_up, format, i_blow_up)
Next
Log.Critical(i_blow_up)

For Each format As String In badFormats
    Log.[Error](format, i_blow_up)
Next
For Each format As String In badFormats
    Log.[Error](i_blow_up, format, i_blow_up)
Next
Log.[Error](i_blow_up)

For Each format As String In badFormats
    Log.Warning(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Warning(i_blow_up, format, i_blow_up)
Next
Log.Warning(i_blow_up)

For Each format As String In badFormats
    Log.Info(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Info(i_blow_up, format, i_blow_up)
Next
Log.Info(i_blow_up)

For Each format As String In badFormats
    Log.Verbose(format, i_blow_up)
Next
For Each format As String In badFormats
    Log.Verbose(i_blow_up, format, i_blow_up)
Next
Log.Verbose(i_blow_up)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members
Overload List

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : Write Method

format
args

Glossary Item Box

Write directly to the log reguardless of the currently configured log-LogLevel

Syntax

Visual Basic (Declaration)
Public Shared Sub Write( _
   ByVal format As String, _
   ByVal ParamArray args() As Object _
)
C#
public static void Write(
   string format,
   params object[] args
)

Parameters

format
args

Example

Log/Test/ThreadedLogTest.cs

C# Copy Code
Log.LogWrite += new LogEventHandler(Block_LogWrite);
try
{
    using (Log.Start("Blocking Test"))
    {
        //the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, false));

        //regaurdless, we should still get the first message
        EventData msg = NextMessage;
        Assert.AreEqual("Start Blocking Test", msg.Message);

        //Now let's just go nuts on the logger...
        for (int i = 0; i < 100; i++)
            Log.Write("Buffering at {0}%.", i);

        Thread.Sleep(100);
        Assert.AreEqual(0, _lastMessages.Count);
        _releaseBlock.Set();
        Thread.Sleep(100);
        Assert.IsFalse(_isBlocked.WaitOne(0, false));

        for (int i = 0; i < 100; i++)
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"));
    }
}
finally
{
    Log.LogWrite -= new LogEventHandler(Block_LogWrite);
}
VB.NET Copy Code
Log.LogWrite += New LogEventHandler(Block_LogWrite)
Try
    Using Log.Start("Blocking Test")
        'the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, False))

        'regaurdless, we should still get the first message
        Dim msg As EventData = NextMessage
        Assert.AreEqual("Start Blocking Test", msg.Message)

        'Now let's just go nuts on the logger...
        Dim i As Integer = 0
        While i < 100
            Log.Write("Buffering at {0}%.", i)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Thread.Sleep(100)
        Assert.AreEqual(0, _lastMessages.Count)
        _releaseBlock.[Set]()
        Thread.Sleep(100)
        Assert.IsFalse(_isBlocked.WaitOne(0, False))

        Dim i As Integer = 0
        While i < 100
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
Finally
    Log.LogWrite -= New LogEventHandler(Block_LogWrite)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members

Source Code

Log/Log.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Log Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log Class

Glossary Item Box

For a list of all members of this type, see Log members.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | IsInfoEnabled | Returns true if 'Info' messages are being recorded.
static (Shared in Visual Basic) | IsVerboseEnabled | Returns true if 'Verbose' messages are being recorded.
Top

See Also

Reference

Log Class
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsInfoEnabled Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : IsInfoEnabled Property

Glossary Item Box

Returns true if 'Info' messages are being recorded.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property IsInfoEnabled As Boolean
C#
public static bool IsInfoEnabled {get;}

Example

Log/Test/BasicLogTest.cs

C# Copy Code
Log.Config.Level = LogLevels.None;
NextMessage.ToString();
Assert.IsFalse(Log.IsVerboseEnabled);
Assert.IsFalse(Log.IsInfoEnabled);

_lastTrace = null;
_lastMessages.Clear();

Log.Critical("Test All off");
Assert.IsNull(_lastTrace);
Assert.AreEqual(0, _lastMessages.Count);

Log.Write("Test PassThrough?");
EventData data = LastMessage;
Assert.AreEqual("Test PassThrough?", data.Message);
VB.NET Copy Code
Log.Config.Level = LogLevels.None
NextMessage.ToString()
Assert.IsFalse(Log.IsVerboseEnabled)
Assert.IsFalse(Log.IsInfoEnabled)

_lastTrace = Nothing
_lastMessages.Clear()

Log.Critical("Test All off")
Assert.IsNull(_lastTrace)
Assert.AreEqual(0, _lastMessages.Count)

Log.Write("Test PassThrough?")
Dim data As EventData = LastMessage
Assert.AreEqual("Test PassThrough?", data.Message)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsVerboseEnabled Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : IsVerboseEnabled Property

Glossary Item Box

Returns true if 'Verbose' messages are being recorded.

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property IsVerboseEnabled As Boolean
C#
public static bool IsVerboseEnabled {get;}

Example

Log/Test/BasicLogTest.cs

C# Copy Code
Log.Config.Level = LogLevels.None;
NextMessage.ToString();
Assert.IsFalse(Log.IsVerboseEnabled);
Assert.IsFalse(Log.IsInfoEnabled);

_lastTrace = null;
_lastMessages.Clear();

Log.Critical("Test All off");
Assert.IsNull(_lastTrace);
Assert.AreEqual(0, _lastMessages.Count);

Log.Write("Test PassThrough?");
EventData data = LastMessage;
Assert.AreEqual("Test PassThrough?", data.Message);
VB.NET Copy Code
Log.Config.Level = LogLevels.None
NextMessage.ToString()
Assert.IsFalse(Log.IsVerboseEnabled)
Assert.IsFalse(Log.IsInfoEnabled)

_lastTrace = Nothing
_lastMessages.Clear()

Log.Critical("Test All off")
Assert.IsNull(_lastTrace)
Assert.AreEqual(0, _lastMessages.Count)

Log.Write("Test PassThrough?")
Dim data As EventData = LastMessage
Assert.AreEqual("Test PassThrough?", data.Message)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members

Source Code

Log/Log.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
Log Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log Class

Glossary Item Box

For a list of all members of this type, see Log members.

Public Events

 | Name | Description
Public Event | LogWrite | This event is raised when the logging routines are called and the LogLevel is at or higher than the current Log.LogLevels field value.
Top

See Also

Reference

Log Class
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LogWrite Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log Class : LogWrite Event

Glossary Item Box

This event is raised when the logging routines are called and the LogLevel is at or higher than the current Log.LogLevels field value.

Syntax

Visual Basic (Declaration)
Public Event LogWrite As LogEventHandler
C#
public event LogEventHandler LogWrite

Event Data

The event handler receives an argument of type LogEventArgs containing data related to this event. The following LogEventArgs properties provide information specific to this event.

Property | Description
Count | Returns the count of items in the collection

Example

Log/Test/ThreadedLogTest.cs

C# Copy Code
Log.LogWrite += new LogEventHandler(Block_LogWrite);
try
{
    using (Log.Start("Blocking Test"))
    {
        //the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, false));

        //regaurdless, we should still get the first message
        EventData msg = NextMessage;
        Assert.AreEqual("Start Blocking Test", msg.Message);

        //Now let's just go nuts on the logger...
        for (int i = 0; i < 100; i++)
            Log.Write("Buffering at {0}%.", i);

        Thread.Sleep(100);
        Assert.AreEqual(0, _lastMessages.Count);
        _releaseBlock.Set();
        Thread.Sleep(100);
        Assert.IsFalse(_isBlocked.WaitOne(0, false));

        for (int i = 0; i < 100; i++)
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"));
    }
}
finally
{
    Log.LogWrite -= new LogEventHandler(Block_LogWrite);
}
VB.NET Copy Code
Log.LogWrite += New LogEventHandler(Block_LogWrite)
Try
    Using Log.Start("Blocking Test")
        'the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, False))

        'regaurdless, we should still get the first message
        Dim msg As EventData = NextMessage
        Assert.AreEqual("Start Blocking Test", msg.Message)

        'Now let's just go nuts on the logger...
        Dim i As Integer = 0
        While i < 100
            Log.Write("Buffering at {0}%.", i)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Thread.Sleep(100)
        Assert.AreEqual(0, _lastMessages.Count)
        _releaseBlock.[Set]()
        Thread.Sleep(100)
        Assert.IsFalse(_isBlocked.WaitOne(0, False))

        Dim i As Integer = 0
        While i < 100
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
Finally
    Log.LogWrite -= New LogEventHandler(Block_LogWrite)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log Class
Log Members

Source Code

Log/Log.Event.cs
Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Log.Config Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log.Config Class

Glossary Item Box

Provides configuration options for the Log subsystem

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class Log.Config
C#
public static class Log.Config

Inheritance Hierarchy

System.Object
Log.Config

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Members
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
Log.Config Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log.Config Class

Glossary Item Box

The following tables list the members exposed by Log.Config.

Public Properties

Name | Description
static (Shared in Visual Basic) | EventLogName | Sets the event log name we will write events to.
static (Shared in Visual Basic) | EventLogSource | Sets the event log source we will write events with, It's up to you to register this value.
static (Shared in Visual Basic) | FormatProvider | Gets or sets the format provider to use when formatting strings
static (Shared in Visual Basic) | Level | Gets or sets the current log LogLevel
static (Shared in Visual Basic) | LogFile | Gets or sets the current log file name, insert '{0}' in the file's name to allow log rolling
static (Shared in Visual Basic) | LogFileMaxHistory | Gets or sets the maximum number of history log files to keep on the system
static (Shared in Visual Basic) | LogFileMaxSize | Gets or sets the maximum size in bytes the log file is allowed to be before rolling to history
static (Shared in Visual Basic) Options Gets or sets the availability of stack info etc. The following performance characterists were taken with a simple example app running 10 threads each writing 1000 log statements in a tight-loop. The times below reflect threading enabled (someone having called Log.AppStart()). The following hardware was used: AMD Turion 64x2 TL-62 2.10 GHz, 3 GB RAM running Vista 32-bit SP1 (HP Notebook). The time indicated below was estimated by taking the total number of milliseconds until all threads completed and dividing by the 10,000 messages that were written.
  • Cost per call 0.005 ms with no context (None)
  • Cost per call 0.035 ms with calling method (LogImmediateCaller)
  • Cost per call 0.060 ms with calling method & assembly info (LogImmediateCaller | LogAddAssemblyInfo)
  • Cost per call 0.160 ms with calling method & file info (LogImmediateCaller | LogAddFileInfo)
  • Cost per call 0.190 ms with calling method & assembly info & file info (LogImmediateCaller | LogAddAssemblyInfo | LogAddFileInfo)
static (Shared in Visual Basic) | Output | Gets or sets the current log LogLevel
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | SetOutputFormat | Changes the output format used to write to a specific output device. The format of this string behaves just like EventData.ToString(). The string can contain any public field or property available for the CSharpTest.Net.Logging.EventData class surrounded by braces {} and yes, properties/fields are case sensative. The input string should look something like the following examples: "[{ManagedThreadId:D2}] {Level,8} - {Message}{Location}{Exception}" -- this is the default format of ToString() "{EventTime:o} [{ProcessId:D4},{ManagedThreadId:D2}] {Level,8} - {Message}{Location}{Exception}" -- This is the default log file format.
static (Shared in Visual Basic) | SetOutputLevel | Changes the log level required to write to a specific output device.
Top

See Also

Reference

Log.Config Class
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Log.Config Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log.Config Class

Glossary Item Box

For a list of all members of this type, see Log.Config members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | SetOutputFormat | Changes the output format used to write to a specific output device. The format of this string behaves just like EventData.ToString(). The string can contain any public field or property available for the CSharpTest.Net.Logging.EventData class surrounded by braces {} and yes, properties/fields are case sensative. The input string should look something like the following examples: "[{ManagedThreadId:D2}] {Level,8} - {Message}{Location}{Exception}" -- this is the default format of ToString() "{EventTime:o} [{ProcessId:D4},{ManagedThreadId:D2}] {Level,8} - {Message}{Location}{Exception}" -- This is the default log file format.
static (Shared in Visual Basic) | SetOutputLevel | Changes the log level required to write to a specific output device.
Top

See Also

Reference

Log.Config Class
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetOutputFormat Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : SetOutputFormat Method

outputToConfigure
newFormat

Glossary Item Box

Changes the output format used to write to a specific output device. The format of this string behaves just like EventData.ToString(). The string can contain any public field or property available for the CSharpTest.Net.Logging.EventData class surrounded by braces {} and yes, properties/fields are case sensative. The input string should look something like the following examples: "[{ManagedThreadId:D2}] {Level,8} - {Message}{Location}{Exception}" -- this is the default format of ToString() "{EventTime:o} [{ProcessId:D4},{ManagedThreadId:D2}] {Level,8} - {Message}{Location}{Exception}" -- This is the default log file format.

Syntax

Visual Basic (Declaration)
Public Shared Sub SetOutputFormat( _
   ByVal outputToConfigure As LogOutputs, _
   ByVal newFormat As String _
)
C#
public static void SetOutputFormat(
   LogOutputs outputToConfigure,
   string newFormat
)

Parameters

outputToConfigure
newFormat

Example

Log/Test/NegativeTests.cs

C# Copy Code
string origFile = Log.Config.LogFile;
try
{
    Log.Config.Output |= LogOutputs.LogFile;
    Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "{Message}");

    Log.Config.LogFile = @"\\\\\ { <mal formed!? file> ///{0}.txt";
    Log.Write("Hi1");
    Log.Write("Hi2");
    Log.Write("Hi3");
    Assert.AreEqual(this.GetType().FullName + ": Hi3", _lastTrace);
    Log.Config.LogFile = @"C: mal {formatted} file {0}.txt";
    Log.Write("Hi4");
    Log.Write("Hi5");
    Log.Write("Hi6");
    Assert.AreEqual(this.GetType().FullName + ": Hi6", _lastTrace);
    string path = Path.Combine(Path.GetTempPath(), @"my-path-doesnt-exist");
    if (Directory.Exists(path)) Directory.Delete(path, true);
    Log.Config.LogFile = Path.Combine(path, "log.txt");
    Log.Write("Hi!");
    Assert.IsTrue(Directory.Exists(path));
    Assert.IsTrue(File.Exists(Path.Combine(path, "log.txt")));
    Log.Config.LogFile = origFile;
    Directory.Delete(path, true);

    string dir = Environment.CurrentDirectory;
    Environment.CurrentDirectory = Path.GetDirectoryName(origFile);
    Log.Config.LogFile = Path.GetFileName(origFile);
    Assert.AreEqual(origFile, Log.Config.LogFile);
    Environment.CurrentDirectory = dir;
    Assert.AreEqual(origFile, Log.Config.LogFile);
}
finally
{
    Log.Config.LogFile = origFile;
}
VB.NET Copy Code
Dim origFile As String = Log.Config.LogFile
Try
    Log.Config.Output = Log.Config.Output Or LogOutputs.LogFile
    Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "{Message}")

    Log.Config.LogFile = "\\\\\ { <mal formed!? file> ///{0}.txt"
    Log.Write("Hi1")
    Log.Write("Hi2")
    Log.Write("Hi3")
    Assert.AreEqual(Me.[GetType]().FullName + ": Hi3", _lastTrace)
    Log.Config.LogFile = "C: mal {formatted} file {0}.txt"
    Log.Write("Hi4")
    Log.Write("Hi5")
    Log.Write("Hi6")
    Assert.AreEqual(Me.[GetType]().FullName + ": Hi6", _lastTrace)
    Dim path As String = Path.Combine(Path.GetTempPath(), "my-path-doesnt-exist")
    If Directory.Exists(path) Then
        Directory.Delete(path, True)
    End If
    Log.Config.LogFile = Path.Combine(path, "log.txt")
    Log.Write("Hi!")
    Assert.IsTrue(Directory.Exists(path))
    Assert.IsTrue(File.Exists(Path.Combine(path, "log.txt")))
    Log.Config.LogFile = origFile
    Directory.Delete(path, True)

    Dim dir As String = Environment.CurrentDirectory
    Environment.CurrentDirectory = Path.GetDirectoryName(origFile)
    Log.Config.LogFile = Path.GetFileName(origFile)
    Assert.AreEqual(origFile, Log.Config.LogFile)
    Environment.CurrentDirectory = dir
    Assert.AreEqual(origFile, Log.Config.LogFile)
Finally
    Log.Config.LogFile = origFile
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members
LogOutputs

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SetOutputLevel Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : SetOutputLevel Method

outputToConfigure
newLevel

Glossary Item Box

Changes the log level required to write to a specific output device.

Syntax

Visual Basic (Declaration)
Public Shared Function SetOutputLevel( _
   ByVal outputToConfigure As LogOutputs, _
   ByVal newLevel As LogLevels _
) As LogLevels
C#
public static LogLevels SetOutputLevel(
   LogOutputs outputToConfigure,
   LogLevels newLevel
)

Parameters

outputToConfigure
newLevel

Example

Log/Test/ConfigTest.cs

C# Copy Code
string origLog = Log.Config.EventLogName;
string origSrc = Log.Config.EventLogSource;

Log.Config.EventLogName = "Dua!";
Assert.AreEqual("Dua!", Log.Config.EventLogName);
Log.Config.EventLogSource = "Yea.";
Assert.AreEqual("Yea.", Log.Config.EventLogSource);
try
{
    Log.Config.EventLogName = "Application";
    Log.Config.EventLogSource = "MsiInstaller";

    Log.Config.Output = LogOutputs.EventLog;
    Log.Config.SetOutputLevel(LogOutputs.EventLog, LogLevels.Info);
    Log.Write("Logging.Test has hijacked your MsiInstaller source for testing use.  Ignore this message.");
}
finally
{
    RestoreLogState();
    Log.Config.EventLogName = "Application";
    Log.Config.EventLogSource = "Logging.Test";
}
VB.NET Copy Code
Dim origLog As String = Log.Config.EventLogName
Dim origSrc As String = Log.Config.EventLogSource

Log.Config.EventLogName = "Dua!"
Assert.AreEqual("Dua!", Log.Config.EventLogName)
Log.Config.EventLogSource = "Yea."
Assert.AreEqual("Yea.", Log.Config.EventLogSource)
Try
    Log.Config.EventLogName = "Application"
    Log.Config.EventLogSource = "MsiInstaller"

    Log.Config.Output = LogOutputs.EventLog
    Log.Config.SetOutputLevel(LogOutputs.EventLog, LogLevels.Info)
    Log.Write("Logging.Test has hijacked your MsiInstaller source for testing use.  Ignore this message.")
Finally
    RestoreLogState()
    Log.Config.EventLogName = "Application"
    Log.Config.EventLogSource = "Logging.Test"
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members
LogOutputs
LogLevels

Source Code

Log/Log.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Log.Config Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace : Log.Config Class

Glossary Item Box

For a list of all members of this type, see Log.Config members.

Public Properties

Name | Description
static (Shared in Visual Basic) | EventLogName | Sets the event log name we will write events to.
static (Shared in Visual Basic) | EventLogSource | Sets the event log source we will write events with, It's up to you to register this value.
static (Shared in Visual Basic) | FormatProvider | Gets or sets the format provider to use when formatting strings
static (Shared in Visual Basic) | Level | Gets or sets the current log LogLevel
static (Shared in Visual Basic) | LogFile | Gets or sets the current log file name, insert '{0}' in the file's name to allow log rolling
static (Shared in Visual Basic) | LogFileMaxHistory | Gets or sets the maximum number of history log files to keep on the system
static (Shared in Visual Basic) | LogFileMaxSize | Gets or sets the maximum size in bytes the log file is allowed to be before rolling to history
static (Shared in Visual Basic) Options Gets or sets the availability of stack info etc. The following performance characterists were taken with a simple example app running 10 threads each writing 1000 log statements in a tight-loop. The times below reflect threading enabled (someone having called Log.AppStart()). The following hardware was used: AMD Turion 64x2 TL-62 2.10 GHz, 3 GB RAM running Vista 32-bit SP1 (HP Notebook). The time indicated below was estimated by taking the total number of milliseconds until all threads completed and dividing by the 10,000 messages that were written.
  • Cost per call 0.005 ms with no context (None)
  • Cost per call 0.035 ms with calling method (LogImmediateCaller)
  • Cost per call 0.060 ms with calling method & assembly info (LogImmediateCaller | LogAddAssemblyInfo)
  • Cost per call 0.160 ms with calling method & file info (LogImmediateCaller | LogAddFileInfo)
  • Cost per call 0.190 ms with calling method & assembly info & file info (LogImmediateCaller | LogAddAssemblyInfo | LogAddFileInfo)
static (Shared in Visual Basic) | Output | Gets or sets the current log LogLevel
Top

See Also

Reference

Log.Config Class
(Global) Namespace

Source Code

Log/Log.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventLogName Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : EventLogName Property

Glossary Item Box

Sets the event log name we will write events to.

Syntax

Visual Basic (Declaration)
Public Shared Property EventLogName As String
C#
public static string EventLogName {get; set;}

Example

Log/Test/ConfigTest.cs

C# Copy Code
string origLog = Log.Config.EventLogName;
string origSrc = Log.Config.EventLogSource;

Log.Config.EventLogName = "Dua!";
Assert.AreEqual("Dua!", Log.Config.EventLogName);
Log.Config.EventLogSource = "Yea.";
Assert.AreEqual("Yea.", Log.Config.EventLogSource);
try
{
    Log.Config.EventLogName = "Application";
    Log.Config.EventLogSource = "MsiInstaller";

    Log.Config.Output = LogOutputs.EventLog;
    Log.Config.SetOutputLevel(LogOutputs.EventLog, LogLevels.Info);
    Log.Write("Logging.Test has hijacked your MsiInstaller source for testing use.  Ignore this message.");
}
finally
{
    RestoreLogState();
    Log.Config.EventLogName = "Application";
    Log.Config.EventLogSource = "Logging.Test";
}
VB.NET Copy Code
Dim origLog As String = Log.Config.EventLogName
Dim origSrc As String = Log.Config.EventLogSource

Log.Config.EventLogName = "Dua!"
Assert.AreEqual("Dua!", Log.Config.EventLogName)
Log.Config.EventLogSource = "Yea."
Assert.AreEqual("Yea.", Log.Config.EventLogSource)
Try
    Log.Config.EventLogName = "Application"
    Log.Config.EventLogSource = "MsiInstaller"

    Log.Config.Output = LogOutputs.EventLog
    Log.Config.SetOutputLevel(LogOutputs.EventLog, LogLevels.Info)
    Log.Write("Logging.Test has hijacked your MsiInstaller source for testing use.  Ignore this message.")
Finally
    RestoreLogState()
    Log.Config.EventLogName = "Application"
    Log.Config.EventLogSource = "Logging.Test"
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventLogSource Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : EventLogSource Property

Glossary Item Box

Sets the event log source we will write events with, It's up to you to register this value.

Syntax

Visual Basic (Declaration)
Public Shared Property EventLogSource As String
C#
public static string EventLogSource {get; set;}

Example

Log/Test/ConfigTest.cs

C# Copy Code
string origLog = Log.Config.EventLogName;
string origSrc = Log.Config.EventLogSource;

Log.Config.EventLogName = "Dua!";
Assert.AreEqual("Dua!", Log.Config.EventLogName);
Log.Config.EventLogSource = "Yea.";
Assert.AreEqual("Yea.", Log.Config.EventLogSource);
try
{
    Log.Config.EventLogName = "Application";
    Log.Config.EventLogSource = "MsiInstaller";

    Log.Config.Output = LogOutputs.EventLog;
    Log.Config.SetOutputLevel(LogOutputs.EventLog, LogLevels.Info);
    Log.Write("Logging.Test has hijacked your MsiInstaller source for testing use.  Ignore this message.");
}
finally
{
    RestoreLogState();
    Log.Config.EventLogName = "Application";
    Log.Config.EventLogSource = "Logging.Test";
}
VB.NET Copy Code
Dim origLog As String = Log.Config.EventLogName
Dim origSrc As String = Log.Config.EventLogSource

Log.Config.EventLogName = "Dua!"
Assert.AreEqual("Dua!", Log.Config.EventLogName)
Log.Config.EventLogSource = "Yea."
Assert.AreEqual("Yea.", Log.Config.EventLogSource)
Try
    Log.Config.EventLogName = "Application"
    Log.Config.EventLogSource = "MsiInstaller"

    Log.Config.Output = LogOutputs.EventLog
    Log.Config.SetOutputLevel(LogOutputs.EventLog, LogLevels.Info)
    Log.Write("Logging.Test has hijacked your MsiInstaller source for testing use.  Ignore this message.")
Finally
    RestoreLogState()
    Log.Config.EventLogName = "Application"
    Log.Config.EventLogSource = "Logging.Test"
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FormatProvider Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : FormatProvider Property

Glossary Item Box

Gets or sets the format provider to use when formatting strings

Syntax

Visual Basic (Declaration)
Public Shared WriteOnly Property FormatProvider As IFormatProvider
C#
public static IFormatProvider FormatProvider {set;}

Example

Log/Test/ConfigTest.cs

C# Copy Code
DateTime now = DateTime.Now;
string cultured = String.Format("{0}", now);
string invariant = String.Format(CultureInfo.InvariantCulture, "{0}", now);

Log.Write("{0}", now);
Assert.IsTrue(_lastTrace.StartsWith(GetType().FullName + ": "));
string trimed = _lastTrace.Substring(GetType().FullName.Length + 2);

Assert.AreEqual(invariant, trimed);

Log.Config.FormatProvider = CultureInfo.CurrentCulture;
Log.Write("{0}", now);
Assert.IsTrue(_lastTrace.StartsWith(GetType().FullName + ": "));
trimed = _lastTrace.Substring(GetType().FullName.Length + 2);

Assert.AreEqual(cultured, trimed);

Log.Config.FormatProvider = CultureInfo.InvariantCulture;
Log.Write("{0}", now);
Assert.IsTrue(_lastTrace.StartsWith(GetType().FullName + ": "));
trimed = _lastTrace.Substring(GetType().FullName.Length + 2);

Assert.AreEqual(invariant, trimed);
VB.NET Copy Code
Dim now As DateTime = DateTime.Now
Dim cultured As String = [String].Format("{0}", now)
Dim invariant As String = [String].Format(CultureInfo.InvariantCulture, "{0}", now)

Log.Write("{0}", now)
Assert.IsTrue(_lastTrace.StartsWith([GetType]().FullName + ": "))
Dim trimed As String = _lastTrace.Substring([GetType]().FullName.Length + 2)

Assert.AreEqual(invariant, trimed)

Log.Config.FormatProvider = CultureInfo.CurrentCulture
Log.Write("{0}", now)
Assert.IsTrue(_lastTrace.StartsWith([GetType]().FullName + ": "))
trimed = _lastTrace.Substring([GetType]().FullName.Length + 2)

Assert.AreEqual(cultured, trimed)

Log.Config.FormatProvider = CultureInfo.InvariantCulture
Log.Write("{0}", now)
Assert.IsTrue(_lastTrace.StartsWith([GetType]().FullName + ": "))
trimed = _lastTrace.Substring([GetType]().FullName.Length + 2)

Assert.AreEqual(invariant, trimed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Level Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : Level Property

Glossary Item Box

Gets or sets the current log LogLevel

Syntax

Visual Basic (Declaration)
Public Shared Property Level As LogLevels
C#
public static LogLevels Level {get; set;}

Example

Log/Test/NegativeTests.cs

C# Copy Code
base.Setup();
Log.Config.Output = LogOutputs.TraceWrite;
Log.Config.Options = LogOptions.LogAddAssemblyInfo | LogOptions.LogAddFileInfo | LogOptions.Default;
Log.Config.Level = LogLevels.Verbose;
Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "NegativeTests: {FULLMESSAGE}");

_out = Console.Out;
_error = Console.Error;
Console.SetOut(new StringWriter());
Console.SetError(new StringWriter());
VB.NET Copy Code
MyBase.Setup()
Log.Config.Output = LogOutputs.TraceWrite
Log.Config.Options = LogOptions.LogAddAssemblyInfo Or LogOptions.LogAddFileInfo Or LogOptions.[Default]
Log.Config.Level = LogLevels.Verbose
Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "NegativeTests: {FULLMESSAGE}")

_out = Console.Out
_error = Console.[Error]
Console.SetOut(New StringWriter())
Console.SetError(New StringWriter())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members
LogLevels

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LogFile Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : LogFile Property

Glossary Item Box

Gets or sets the current log file name, insert '{0}' in the file's name to allow log rolling

Syntax

Visual Basic (Declaration)
Public Shared Property LogFile As String
C#
public static string LogFile {get; set;}

Example

Log/Test/NegativeTests.cs

C# Copy Code
string origFile = Log.Config.LogFile;
try
{
    Log.Config.Output |= LogOutputs.LogFile;
    Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "{Message}");

    Log.Config.LogFile = @"\\\\\ { <mal formed!? file> ///{0}.txt";
    Log.Write("Hi1");
    Log.Write("Hi2");
    Log.Write("Hi3");
    Assert.AreEqual(this.GetType().FullName + ": Hi3", _lastTrace);
    Log.Config.LogFile = @"C: mal {formatted} file {0}.txt";
    Log.Write("Hi4");
    Log.Write("Hi5");
    Log.Write("Hi6");
    Assert.AreEqual(this.GetType().FullName + ": Hi6", _lastTrace);
    string path = Path.Combine(Path.GetTempPath(), @"my-path-doesnt-exist");
    if (Directory.Exists(path)) Directory.Delete(path, true);
    Log.Config.LogFile = Path.Combine(path, "log.txt");
    Log.Write("Hi!");
    Assert.IsTrue(Directory.Exists(path));
    Assert.IsTrue(File.Exists(Path.Combine(path, "log.txt")));
    Log.Config.LogFile = origFile;
    Directory.Delete(path, true);

    string dir = Environment.CurrentDirectory;
    Environment.CurrentDirectory = Path.GetDirectoryName(origFile);
    Log.Config.LogFile = Path.GetFileName(origFile);
    Assert.AreEqual(origFile, Log.Config.LogFile);
    Environment.CurrentDirectory = dir;
    Assert.AreEqual(origFile, Log.Config.LogFile);
}
finally
{
    Log.Config.LogFile = origFile;
}
VB.NET Copy Code
Dim origFile As String = Log.Config.LogFile
Try
    Log.Config.Output = Log.Config.Output Or LogOutputs.LogFile
    Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "{Message}")

    Log.Config.LogFile = "\\\\\ { <mal formed!? file> ///{0}.txt"
    Log.Write("Hi1")
    Log.Write("Hi2")
    Log.Write("Hi3")
    Assert.AreEqual(Me.[GetType]().FullName + ": Hi3", _lastTrace)
    Log.Config.LogFile = "C: mal {formatted} file {0}.txt"
    Log.Write("Hi4")
    Log.Write("Hi5")
    Log.Write("Hi6")
    Assert.AreEqual(Me.[GetType]().FullName + ": Hi6", _lastTrace)
    Dim path As String = Path.Combine(Path.GetTempPath(), "my-path-doesnt-exist")
    If Directory.Exists(path) Then
        Directory.Delete(path, True)
    End If
    Log.Config.LogFile = Path.Combine(path, "log.txt")
    Log.Write("Hi!")
    Assert.IsTrue(Directory.Exists(path))
    Assert.IsTrue(File.Exists(Path.Combine(path, "log.txt")))
    Log.Config.LogFile = origFile
    Directory.Delete(path, True)

    Dim dir As String = Environment.CurrentDirectory
    Environment.CurrentDirectory = Path.GetDirectoryName(origFile)
    Log.Config.LogFile = Path.GetFileName(origFile)
    Assert.AreEqual(origFile, Log.Config.LogFile)
    Environment.CurrentDirectory = dir
    Assert.AreEqual(origFile, Log.Config.LogFile)
Finally
    Log.Config.LogFile = origFile
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LogFileMaxHistory Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : LogFileMaxHistory Property

Glossary Item Box

Gets or sets the maximum number of history log files to keep on the system

Syntax

Visual Basic (Declaration)
Public Shared Property LogFileMaxHistory As Integer
C#
public static int LogFileMaxHistory {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LogFileMaxSize Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : LogFileMaxSize Property

Glossary Item Box

Gets or sets the maximum size in bytes the log file is allowed to be before rolling to history

Syntax

Visual Basic (Declaration)
Public Shared Property LogFileMaxSize As Integer
C#
public static int LogFileMaxSize {get; set;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Options Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : Options Property

Glossary Item Box

Gets or sets the availability of stack info etc. The following performance characterists were taken with a simple example app running 10 threads each writing 1000 log statements in a tight-loop. The times below reflect threading enabled (someone having called Log.AppStart()). The following hardware was used: AMD Turion 64x2 TL-62 2.10 GHz, 3 GB RAM running Vista 32-bit SP1 (HP Notebook). The time indicated below was estimated by taking the total number of milliseconds until all threads completed and dividing by the 10,000 messages that were written.
  • Cost per call 0.005 ms with no context (None)
  • Cost per call 0.035 ms with calling method (LogImmediateCaller)
  • Cost per call 0.060 ms with calling method & assembly info (LogImmediateCaller | LogAddAssemblyInfo)
  • Cost per call 0.160 ms with calling method & file info (LogImmediateCaller | LogAddFileInfo)
  • Cost per call 0.190 ms with calling method & assembly info & file info (LogImmediateCaller | LogAddAssemblyInfo | LogAddFileInfo)

Syntax

Visual Basic (Declaration)
Public Shared Property Options As LogOptions
C#
public static LogOptions Options {get; set;}

Example

Log/Test/NegativeTests.cs

C# Copy Code
base.Setup();
Log.Config.Output = LogOutputs.TraceWrite;
Log.Config.Options = LogOptions.LogAddAssemblyInfo | LogOptions.LogAddFileInfo | LogOptions.Default;
Log.Config.Level = LogLevels.Verbose;
Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "NegativeTests: {FULLMESSAGE}");

_out = Console.Out;
_error = Console.Error;
Console.SetOut(new StringWriter());
Console.SetError(new StringWriter());
VB.NET Copy Code
MyBase.Setup()
Log.Config.Output = LogOutputs.TraceWrite
Log.Config.Options = LogOptions.LogAddAssemblyInfo Or LogOptions.LogAddFileInfo Or LogOptions.[Default]
Log.Config.Level = LogLevels.Verbose
Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "NegativeTests: {FULLMESSAGE}")

_out = Console.Out
_error = Console.[Error]
Console.SetOut(New StringWriter())
Console.SetError(New StringWriter())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members
LogOptions

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Output Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > (Global) Namespace > Log.Config Class : Output Property

Glossary Item Box

Gets or sets the current log LogLevel

Syntax

Visual Basic (Declaration)
Public Shared Property Output As LogOutputs
C#
public static LogOutputs Output {get; set;}

Example

Log/Test/NegativeTests.cs

C# Copy Code
string origFile = Log.Config.LogFile;
try
{
    Log.Config.Output |= LogOutputs.LogFile;
    Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "{Message}");

    Log.Config.LogFile = @"\\\\\ { <mal formed!? file> ///{0}.txt";
    Log.Write("Hi1");
    Log.Write("Hi2");
    Log.Write("Hi3");
    Assert.AreEqual(this.GetType().FullName + ": Hi3", _lastTrace);
    Log.Config.LogFile = @"C: mal {formatted} file {0}.txt";
    Log.Write("Hi4");
    Log.Write("Hi5");
    Log.Write("Hi6");
    Assert.AreEqual(this.GetType().FullName + ": Hi6", _lastTrace);
    string path = Path.Combine(Path.GetTempPath(), @"my-path-doesnt-exist");
    if (Directory.Exists(path)) Directory.Delete(path, true);
    Log.Config.LogFile = Path.Combine(path, "log.txt");
    Log.Write("Hi!");
    Assert.IsTrue(Directory.Exists(path));
    Assert.IsTrue(File.Exists(Path.Combine(path, "log.txt")));
    Log.Config.LogFile = origFile;
    Directory.Delete(path, true);

    string dir = Environment.CurrentDirectory;
    Environment.CurrentDirectory = Path.GetDirectoryName(origFile);
    Log.Config.LogFile = Path.GetFileName(origFile);
    Assert.AreEqual(origFile, Log.Config.LogFile);
    Environment.CurrentDirectory = dir;
    Assert.AreEqual(origFile, Log.Config.LogFile);
}
finally
{
    Log.Config.LogFile = origFile;
}
VB.NET Copy Code
Dim origFile As String = Log.Config.LogFile
Try
    Log.Config.Output = Log.Config.Output Or LogOutputs.LogFile
    Log.Config.SetOutputFormat(LogOutputs.TraceWrite, "{Message}")

    Log.Config.LogFile = "\\\\\ { <mal formed!? file> ///{0}.txt"
    Log.Write("Hi1")
    Log.Write("Hi2")
    Log.Write("Hi3")
    Assert.AreEqual(Me.[GetType]().FullName + ": Hi3", _lastTrace)
    Log.Config.LogFile = "C: mal {formatted} file {0}.txt"
    Log.Write("Hi4")
    Log.Write("Hi5")
    Log.Write("Hi6")
    Assert.AreEqual(Me.[GetType]().FullName + ": Hi6", _lastTrace)
    Dim path As String = Path.Combine(Path.GetTempPath(), "my-path-doesnt-exist")
    If Directory.Exists(path) Then
        Directory.Delete(path, True)
    End If
    Log.Config.LogFile = Path.Combine(path, "log.txt")
    Log.Write("Hi!")
    Assert.IsTrue(Directory.Exists(path))
    Assert.IsTrue(File.Exists(Path.Combine(path, "log.txt")))
    Log.Config.LogFile = origFile
    Directory.Delete(path, True)

    Dim dir As String = Environment.CurrentDirectory
    Environment.CurrentDirectory = Path.GetDirectoryName(origFile)
    Log.Config.LogFile = Path.GetFileName(origFile)
    Assert.AreEqual(origFile, Log.Config.LogFile)
    Environment.CurrentDirectory = dir
    Assert.AreEqual(origFile, Log.Config.LogFile)
Finally
    Log.Config.LogFile = origFile
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

Log.Config Class
Log.Config Members
LogOutputs

Source Code

Log/Log.cs
Tools/CmdTool/Config.cs


%%ItemTitle%%

CSharpTest.Net.Logging Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.Logging Assembly : CSharpTest.Net.Logging Namespace

Glossary Item Box

Classes

 | Class | Description
Class | EventData | This is the class that is used to transfer log events through the system. It's basically a 'picture' of the state at the time the log was written since all logging is actually happening in a delayed fashion.
Class | LogEventArgs | The event args passed to the log system, often multiple log entries will arrive 'near' simultaneous, ALWAYs allow for ZERO or more than one.

Delegates

 | Delegate | Description
Delegate | LogEventHandler | Log events are raised with this event handler

Enumerations

 | Enumeration | Description
Enumeration | LogLevels | Defines the various levels of logging
Enumeration | LogOptions | Performance and behavior related LogOption for the log system.
Enumeration | LogOutputs | Defines the various possble outputs of the logging system

See Also

Reference

CSharpTest.Net.Logging Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
EventData Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : EventData Class

Glossary Item Box

This is the class that is used to transfer log events through the system. It's basically a 'picture' of the state at the time the log was written since all logging is actually happening in a delayed fashion.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public NotInheritable Class EventData
C#
[SerializableAttribute()]
public sealed class EventData

Inheritance Hierarchy

System.Object
CSharpTest.Net.Logging.EventData

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Members
CSharpTest.Net.Logging Namespace
EventData[] LogEventArgs.ToArray()

Source Code

Log/Log.EventData.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
EventData Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : EventData Class

Glossary Item Box

The following tables list the members exposed by EventData.

Public Constructors

 | Name | Description
Public Constructor | EventData Constructor | /// Serialization Constructor for ISerializable ///
Top

Public Fields

 | Name | Description
Public Field | Level | The LogLevel of the log data or LogLevels.None if Log.Write() was called
Public Field | Output | The outputs that should recieve this message
Top

Public Properties

 | Name | Description
Public Property | AppDomainName | The current app domain's friendly name
Public Property | EntryAssembly | The current app domain's entry-point assembly name
Public Property | EventId | A unique integer representing the index the event was written since program start
Public Property | EventTime | Returns the time when the log event was raised
Public Property | Exception | An instance of the Exception class or null if none provided
Public Property | FileColumn | The file column where the log was called from.
Public Property | FileLine | The file line number where the log was called from.
Public Property | FileLocation | Returns the full message of Message + Location + Exception
Public Property | FileName | The file name where the log was called from or null if no file dataList available/configured.
Public Property | FullMessage | Returns the full message of Message + Location + Exception
Public Property | IlOffset | Returns the IL offset within the calling method
Public Property | Location | The full method information: Type.Name(Args)
Public Property | LogCurrent | returns the text given the most recent call to Log.Start() that has not yet been Disponsed
Public Property | LogStack | returns the text given to all calls to Log.Start() that has not yet been Disponsed separated by '::'
Public Property | ManagedThreadId | The managed thread id that called the log routine
Public Property | ManagedThreadName | The managed thread name (if any) or String.Empty
Public Property | Message | The formatted string of the message or String.Empty if none
Public Property | Method | The full method information: Type.Name(Args)
Public Property | MethodArgs | The method's argument names and types.
Public Property | MethodAssembly | The assembly's name that contained the method where the log was called from.
Public Property | MethodAssemblyVersion | The assembly's version that contained the method where the log was called from.
Public Property | MethodName | The method where the log was called from.
Public Property | MethodType | The type containing the method where the log was called from.
Public Property | MethodTypeName | The unqualified type containing the method where the log was called from.
Public Property | ProcessId | The current process id
Public Property | ProcessName | The current process name
Public Property | ThreadPrincipalName | The logging thread's 'CurrentPrincipal.Identity.Name' property
Top

Public Methods

 | Name | Description
Public Method | ToString | Overloaded. Displays this log data in a default brief format
Public Method | ToXml | Returns this data as an XmlWriter text fragment who name is the class name and each attribute is the field name, again maintaining the case.
Public Method | Write | Overloaded. Writes this event to the text writter with the default brief format
Top

See Also

Reference

EventData Class
CSharpTest.Net.Logging Namespace
EventData[] LogEventArgs.ToArray()

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventData Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : EventData Constructor

info
context

Glossary Item Box

/// Serialization Constructor for ISerializable ///

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
public EventData(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
EventData Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : EventData Class

Glossary Item Box

For a list of all members of this type, see EventData members.

Public Methods

 | Name | Description
Public Method | ToString | Overloaded. Displays this log data in a default brief format
Public Method | ToXml | Returns this data as an XmlWriter text fragment who name is the class name and each attribute is the field name, again maintaining the case.
Public Method | Write | Overloaded. Writes this event to the text writter with the default brief format
Top

See Also

Reference

EventData Class
CSharpTest.Net.Logging Namespace
EventData[] LogEventArgs.ToArray()

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : ToString Method

Glossary Item Box

Displays this log data in a default brief format

Overload List

Overload | Description
ToString() | Displays this log data in a default brief format
ToString(String) | Displays this log data in a specific format. Use '{FieldName}' to be substituded with it's value. Sorry but it uses a case-sensitive match of fields in this class.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members
Base Implementation in ToString


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString() Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class > ToString Method : ToString() Method

Glossary Item Box

Displays this log data in a default brief format

Syntax

Visual Basic (Declaration)
Public Overloads Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members
Overload List
Base Implementation in ToString

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString(String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class > ToString Method : ToString(String) Method

format

Glossary Item Box

Displays this log data in a specific format. Use '{FieldName}' to be substituded with it's value. Sorry but it uses a case-sensitive match of fields in this class.

Syntax

Visual Basic (Declaration)
Public Overloads Function ToString( _
   ByVal format As String _
) As String
C#
public string ToString(
   string format
)

Parameters

format

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members
Overload List

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToXml Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : ToXml Method

Glossary Item Box

Returns this data as an XmlWriter text fragment who name is the class name and each attribute is the field name, again maintaining the case.

Syntax

Visual Basic (Declaration)
Public Function ToXml() As String
C#
public string ToXml()

Example

Log/Test/BasicLogTest.cs

C# Copy Code
Log.Write("");
EventData msg = LastMessage;
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);

using (Log.Start(UniqueData))
{
    msg = LastMessage;
    Assert.AreEqual("Start " + UniqueData, msg.Message);
    Assert.AreEqual(UniqueData, msg.LogCurrent);
    Assert.AreEqual(msg.LogCurrent, msg.LogStack);

    using (Log.Start("2ndlevel"))
    {
        msg = LastMessage;
        Assert.AreEqual("Start 2ndlevel", msg.Message);
        Assert.AreEqual("2ndlevel", msg.LogCurrent);
        Assert.AreEqual(UniqueData + "::2ndlevel", msg.LogStack);

        Assert.IsTrue(msg.ToXml().Contains("2ndlevel"));
        Assert.AreEqual("2ndlevel", msg.ToString("{LogCurrent}"));
    }
    msg = LastMessage;
    Assert.IsTrue(msg.Message.StartsWith("End 2ndlevel"));
    Assert.AreEqual(UniqueData, msg.LogCurrent);
    Assert.AreEqual(msg.LogCurrent, msg.LogStack);
}
msg = LastMessage;
Assert.IsTrue(msg.Message.StartsWith("End " + UniqueData));
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);
VB.NET Copy Code
Log.Write("")
Dim msg As EventData = LastMessage
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)

Using Log.Start(UniqueData)
    msg = LastMessage
    Assert.AreEqual("Start " + UniqueData, msg.Message)
    Assert.AreEqual(UniqueData, msg.LogCurrent)
    Assert.AreEqual(msg.LogCurrent, msg.LogStack)

    Using Log.Start("2ndlevel")
        msg = LastMessage
        Assert.AreEqual("Start 2ndlevel", msg.Message)
        Assert.AreEqual("2ndlevel", msg.LogCurrent)
        Assert.AreEqual(UniqueData + "::2ndlevel", msg.LogStack)

        Assert.IsTrue(msg.ToXml().Contains("2ndlevel"))
        Assert.AreEqual("2ndlevel", msg.ToString("{LogCurrent}"))
    End Using
    msg = LastMessage
    Assert.IsTrue(msg.Message.StartsWith("End 2ndlevel"))
    Assert.AreEqual(UniqueData, msg.LogCurrent)
    Assert.AreEqual(msg.LogCurrent, msg.LogStack)
End Using
msg = LastMessage
Assert.IsTrue(msg.Message.StartsWith("End " + UniqueData))
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : Write Method

Glossary Item Box

Writes this event to the text writter with the default brief format

Overload List

Overload | Description
Write(TextWriter) | Writes this event to the text writter with the default brief format
Write(TextWriter,String) | Writes this log data in a specific format. Use '{FieldName}' to be substituded with it's value. Sorry but it uses a case-sensitive match of fields in this class.
Write(XmlWriter) | Writes a custom xml format for this record.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(TextWriter) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class > Write Method : Write(TextWriter) Method

writer

Glossary Item Box

Writes this event to the text writter with the default brief format

Syntax

Visual Basic (Declaration)
Public Overloads Sub Write( _
   ByVal writer As TextWriter _
)
C#
public void Write(
   TextWriter writer
)

Parameters

writer

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members
Overload List

Used By

String LogEventArgs.ToString()

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(TextWriter,String) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class > Write Method : Write(TextWriter,String) Method

writer
format

Glossary Item Box

Writes this log data in a specific format. Use '{FieldName}' to be substituded with it's value. Sorry but it uses a case-sensitive match of fields in this class.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Write( _
   ByVal writer As TextWriter, _
   ByVal format As String _
)
C#
public void Write(
   TextWriter writer,
   string format
)

Parameters

writer
format

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members
Overload List

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Write(XmlWriter) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class > Write Method : Write(XmlWriter) Method

writer

Glossary Item Box

Writes a custom xml format for this record.

Syntax

Visual Basic (Declaration)
Public Overloads Sub Write( _
   ByVal writer As XmlWriter _
)
C#
public void Write(
   XmlWriter writer
)

Parameters

writer

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members
Overload List

Source Code

Log/Log.EventData.cs

Used By

String EventData.ToXml()


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
EventData Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : EventData Class

Glossary Item Box

For a list of all members of this type, see EventData members.

Public Properties

 | Name | Description
Public Property | AppDomainName | The current app domain's friendly name
Public Property | EntryAssembly | The current app domain's entry-point assembly name
Public Property | EventId | A unique integer representing the index the event was written since program start
Public Property | EventTime | Returns the time when the log event was raised
Public Property | Exception | An instance of the Exception class or null if none provided
Public Property | FileColumn | The file column where the log was called from.
Public Property | FileLine | The file line number where the log was called from.
Public Property | FileLocation | Returns the full message of Message + Location + Exception
Public Property | FileName | The file name where the log was called from or null if no file dataList available/configured.
Public Property | FullMessage | Returns the full message of Message + Location + Exception
Public Property | IlOffset | Returns the IL offset within the calling method
Public Property | Location | The full method information: Type.Name(Args)
Public Property | LogCurrent | returns the text given the most recent call to Log.Start() that has not yet been Disponsed
Public Property | LogStack | returns the text given to all calls to Log.Start() that has not yet been Disponsed separated by '::'
Public Property | ManagedThreadId | The managed thread id that called the log routine
Public Property | ManagedThreadName | The managed thread name (if any) or String.Empty
Public Property | Message | The formatted string of the message or String.Empty if none
Public Property | Method | The full method information: Type.Name(Args)
Public Property | MethodArgs | The method's argument names and types.
Public Property | MethodAssembly | The assembly's name that contained the method where the log was called from.
Public Property | MethodAssemblyVersion | The assembly's version that contained the method where the log was called from.
Public Property | MethodName | The method where the log was called from.
Public Property | MethodType | The type containing the method where the log was called from.
Public Property | MethodTypeName | The unqualified type containing the method where the log was called from.
Public Property | ProcessId | The current process id
Public Property | ProcessName | The current process name
Public Property | ThreadPrincipalName | The logging thread's 'CurrentPrincipal.Identity.Name' property
Top

See Also

Reference

EventData Class
CSharpTest.Net.Logging Namespace
EventData[] LogEventArgs.ToArray()

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AppDomainName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : AppDomainName Property

Glossary Item Box

The current app domain's friendly name

Syntax

Visual Basic (Declaration)
Public ReadOnly Property AppDomainName As String
C#
public string AppDomainName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EntryAssembly Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : EntryAssembly Property

Glossary Item Box

The current app domain's entry-point assembly name

Syntax

Visual Basic (Declaration)
Public ReadOnly Property EntryAssembly As String
C#
public string EntryAssembly {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventId Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : EventId Property

Glossary Item Box

A unique integer representing the index the event was written since program start

Syntax

Visual Basic (Declaration)
Public ReadOnly Property EventId As Integer
C#
public int EventId {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
EventTime Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : EventTime Property

Glossary Item Box

Returns the time when the log event was raised

Syntax

Visual Basic (Declaration)
Public ReadOnly Property EventTime As Date
C#
public DateTime EventTime {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Exception Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : Exception Property

Glossary Item Box

An instance of the Exception class or null if none provided

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Exception As Exception
C#
public Exception Exception {get;}

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileColumn Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : FileColumn Property

Glossary Item Box

The file column where the log was called from.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileColumn As Integer
C#
public int FileColumn {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileLine Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : FileLine Property

Glossary Item Box

The file line number where the log was called from.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileLine As Integer
C#
public int FileLine {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileLocation Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : FileLocation Property

Glossary Item Box

Returns the full message of Message + Location + Exception

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileLocation As String
C#
public string FileLocation {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FileName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : FileName Property

Glossary Item Box

The file name where the log was called from or null if no file dataList available/configured.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FileName As String
C#
public string FileName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
FullMessage Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : FullMessage Property

Glossary Item Box

Returns the full message of Message + Location + Exception

Syntax

Visual Basic (Declaration)
Public ReadOnly Property FullMessage As String
C#
public string FullMessage {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IlOffset Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : IlOffset Property

Glossary Item Box

Returns the IL offset within the calling method

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IlOffset As Integer
C#
public int IlOffset {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Location Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : Location Property

Glossary Item Box

The full method information: Type.Name(Args)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Location As String
C#
public string Location {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LogCurrent Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : LogCurrent Property

Glossary Item Box

returns the text given the most recent call to Log.Start() that has not yet been Disponsed

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LogCurrent As String
C#
public string LogCurrent {get;}

Example

Log/Test/BasicLogTest.cs

C# Copy Code
Log.Write(UniqueData);
EventData msg = LastMessage;
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);

using (Log.Start(UniqueData))
{
    msg = LastMessage;
    Assert.AreEqual("Start " + UniqueData, msg.Message);
    Assert.AreEqual(UniqueData, msg.LogCurrent);
    Assert.AreEqual(msg.LogCurrent, msg.LogStack);

    Log.ClearStack();
    Log.Warning("Stack cleared");
    msg = LastMessage;
    Assert.IsNull(msg.LogCurrent);
    Assert.IsNull(msg.LogStack);
}

//no message generated.
Assert.AreEqual(0, _lastMessages.Count);
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);
VB.NET Copy Code
Log.Write(UniqueData)
Dim msg As EventData = LastMessage
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)

Using Log.Start(UniqueData)
    msg = LastMessage
    Assert.AreEqual("Start " + UniqueData, msg.Message)
    Assert.AreEqual(UniqueData, msg.LogCurrent)
    Assert.AreEqual(msg.LogCurrent, msg.LogStack)

    Log.ClearStack()
    Log.Warning("Stack cleared")
    msg = LastMessage
    Assert.IsNull(msg.LogCurrent)
    Assert.IsNull(msg.LogStack)
End Using

'no message generated.
Assert.AreEqual(0, _lastMessages.Count)
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LogStack Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : LogStack Property

Glossary Item Box

returns the text given to all calls to Log.Start() that has not yet been Disponsed separated by '::'

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LogStack As String
C#
public string LogStack {get;}

Example

Log/Test/BasicLogTest.cs

C# Copy Code
Log.Write(UniqueData);
EventData msg = LastMessage;
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);

using (Log.Start(UniqueData))
{
    msg = LastMessage;
    Assert.AreEqual("Start " + UniqueData, msg.Message);
    Assert.AreEqual(UniqueData, msg.LogCurrent);
    Assert.AreEqual(msg.LogCurrent, msg.LogStack);

    Log.ClearStack();
    Log.Warning("Stack cleared");
    msg = LastMessage;
    Assert.IsNull(msg.LogCurrent);
    Assert.IsNull(msg.LogStack);
}

//no message generated.
Assert.AreEqual(0, _lastMessages.Count);
Assert.IsNull(msg.LogCurrent);
Assert.IsNull(msg.LogStack);
VB.NET Copy Code
Log.Write(UniqueData)
Dim msg As EventData = LastMessage
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)

Using Log.Start(UniqueData)
    msg = LastMessage
    Assert.AreEqual("Start " + UniqueData, msg.Message)
    Assert.AreEqual(UniqueData, msg.LogCurrent)
    Assert.AreEqual(msg.LogCurrent, msg.LogStack)

    Log.ClearStack()
    Log.Warning("Stack cleared")
    msg = LastMessage
    Assert.IsNull(msg.LogCurrent)
    Assert.IsNull(msg.LogStack)
End Using

'no message generated.
Assert.AreEqual(0, _lastMessages.Count)
Assert.IsNull(msg.LogCurrent)
Assert.IsNull(msg.LogStack)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ManagedThreadId Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : ManagedThreadId Property

Glossary Item Box

The managed thread id that called the log routine

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ManagedThreadId As Integer
C#
public int ManagedThreadId {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ManagedThreadName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : ManagedThreadName Property

Glossary Item Box

The managed thread name (if any) or String.Empty

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ManagedThreadName As String
C#
public string ManagedThreadName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Message Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : Message Property

Glossary Item Box

The formatted string of the message or String.Empty if none

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Message As String
C#
public string Message {get;}

Example

Log/Test/ThreadedLogTest.cs

C# Copy Code
Log.LogWrite += new LogEventHandler(Block_LogWrite);
try
{
    using (Log.Start("Blocking Test"))
    {
        //the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, false));

        //regaurdless, we should still get the first message
        EventData msg = NextMessage;
        Assert.AreEqual("Start Blocking Test", msg.Message);

        //Now let's just go nuts on the logger...
        for (int i = 0; i < 100; i++)
            Log.Write("Buffering at {0}%.", i);

        Thread.Sleep(100);
        Assert.AreEqual(0, _lastMessages.Count);
        _releaseBlock.Set();
        Thread.Sleep(100);
        Assert.IsFalse(_isBlocked.WaitOne(0, false));

        for (int i = 0; i < 100; i++)
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"));
    }
}
finally
{
    Log.LogWrite -= new LogEventHandler(Block_LogWrite);
}
VB.NET Copy Code
Log.LogWrite += New LogEventHandler(Block_LogWrite)
Try
    Using Log.Start("Blocking Test")
        'the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, False))

        'regaurdless, we should still get the first message
        Dim msg As EventData = NextMessage
        Assert.AreEqual("Start Blocking Test", msg.Message)

        'Now let's just go nuts on the logger...
        Dim i As Integer = 0
        While i < 100
            Log.Write("Buffering at {0}%.", i)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Thread.Sleep(100)
        Assert.AreEqual(0, _lastMessages.Count)
        _releaseBlock.[Set]()
        Thread.Sleep(100)
        Assert.IsFalse(_isBlocked.WaitOne(0, False))

        Dim i As Integer = 0
        While i < 100
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
Finally
    Log.LogWrite -= New LogEventHandler(Block_LogWrite)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs

Used By

String EventData.ToString(String)


%%PageItemTitle%%

[image]
CSharpTest.Net
Method Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : Method Property

Glossary Item Box

The full method information: Type.Name(Args)

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Method As String
C#
public string Method {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MethodArgs Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : MethodArgs Property

Glossary Item Box

The method's argument names and types.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MethodArgs As String
C#
public string MethodArgs {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MethodAssembly Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : MethodAssembly Property

Glossary Item Box

The assembly's name that contained the method where the log was called from.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MethodAssembly As String
C#
public string MethodAssembly {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MethodAssemblyVersion Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : MethodAssemblyVersion Property

Glossary Item Box

The assembly's version that contained the method where the log was called from.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MethodAssemblyVersion As String
C#
public string MethodAssemblyVersion {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MethodName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : MethodName Property

Glossary Item Box

The method where the log was called from.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MethodName As String
C#
public string MethodName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MethodType Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : MethodType Property

Glossary Item Box

The type containing the method where the log was called from.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MethodType As String
C#
public string MethodType {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MethodTypeName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : MethodTypeName Property

Glossary Item Box

The unqualified type containing the method where the log was called from.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property MethodTypeName As String
C#
public string MethodTypeName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessId Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : ProcessId Property

Glossary Item Box

The current process id

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ProcessId As Integer
C#
public int ProcessId {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProcessName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : ProcessName Property

Glossary Item Box

The current process name

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ProcessName As String
C#
public string ProcessName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ThreadPrincipalName Property
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : ThreadPrincipalName Property

Glossary Item Box

The logging thread's 'CurrentPrincipal.Identity.Name' property

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ThreadPrincipalName As String
C#
public string ThreadPrincipalName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members

Source Code

Log/Log.EventData.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
EventData Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : EventData Class

Glossary Item Box

For a list of all members of this type, see EventData members.

Public Fields

 | Name | Description
Public Field | Level | The LogLevel of the log data or LogLevels.None if Log.Write() was called
Public Field | Output | The outputs that should recieve this message
Top

See Also

Reference

EventData Class
CSharpTest.Net.Logging Namespace
EventData[] LogEventArgs.ToArray()

Source Code

Log/Log.EventData.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Level Field
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : Level Field

Glossary Item Box

The LogLevel of the log data or LogLevels.None if Log.Write() was called

Syntax

Visual Basic (Declaration)
Public ReadOnly Level As LogLevels
C#
public readonly LogLevels Level

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Output Field
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : Output Field

Glossary Item Box

The outputs that should recieve this message

Syntax

Visual Basic (Declaration)
Public ReadOnly Output As LogOutputs
C#
public readonly LogOutputs Output

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members


%%PageItemTitle%%

[image]
CSharpTest.Net
LogEventArgs Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : LogEventArgs Class

Glossary Item Box

The event args passed to the log system, often multiple log entries will arrive 'near' simultaneous, ALWAYs allow for ZERO or more than one.

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public NotInheritable Class LogEventArgs
   Inherits System.EventArgs
C#
[SerializableAttribute()]
public sealed class LogEventArgs : System.EventArgs

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.Logging.LogEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LogEventArgs Members
CSharpTest.Net.Logging Namespace
LogEventHandler.Invoke(Object,LogEventArgs)
IAsyncResult LogEventHandler.BeginInvoke(Object,LogEventArgs,AsyncCallback,Object)

Source Code

Log/Log.Event.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
LogEventArgs Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : LogEventArgs Class

Glossary Item Box

The following tables list the members exposed by LogEventArgs.

Public Constructors

 | Name | Description
Public Constructor | LogEventArgs Constructor | /// Serialization Constructor for ISerializable ///
Top

Public Properties

 | Name | Description
Public Property | Count | Returns the count of items in the collection
Top

Public Methods

 | Name | Description
Public Method | GetEnumerator | Returns the enumeration of the EventData structures
Public Method | ToArray | Returns the items as an array of EventData
Public Method | ToString | Returns the entire collection of EventData records as a single line-delimited string
Top

See Also

Reference

LogEventArgs Class
CSharpTest.Net.Logging Namespace
LogEventHandler.Invoke(Object,LogEventArgs)
IAsyncResult LogEventHandler.BeginInvoke(Object,LogEventArgs,AsyncCallback,Object)

Source Code

Log/Log.Event.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LogEventArgs Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > LogEventArgs Class : LogEventArgs Constructor

info
context

Glossary Item Box

/// Serialization Constructor for ISerializable ///

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
public LogEventArgs(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LogEventArgs Class
LogEventArgs Members

Source Code

Log/Log.Event.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LogEventArgs Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : LogEventArgs Class

Glossary Item Box

For a list of all members of this type, see LogEventArgs members.

Public Methods

 | Name | Description
Public Method | GetEnumerator | Returns the enumeration of the EventData structures
Public Method | ToArray | Returns the items as an array of EventData
Public Method | ToString | Returns the entire collection of EventData records as a single line-delimited string
Top

See Also

Reference

LogEventArgs Class
CSharpTest.Net.Logging Namespace
LogEventHandler.Invoke(Object,LogEventArgs)
IAsyncResult LogEventHandler.BeginInvoke(Object,LogEventArgs,AsyncCallback,Object)

Source Code

Log/Log.Event.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
GetEnumerator Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > LogEventArgs Class : GetEnumerator Method

Glossary Item Box

Returns the enumeration of the EventData structures

Syntax

Visual Basic (Declaration)
Public Function GetEnumerator() As IEnumerator(Of EventData)
C#
public IEnumerator<EventData> GetEnumerator()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LogEventArgs Class
LogEventArgs Members

Source Code

Log/Log.Event.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToArray Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > LogEventArgs Class : ToArray Method

Glossary Item Box

Returns the items as an array of EventData

Syntax

Visual Basic (Declaration)
Public Function ToArray() As EventData()
C#
public EventData[] ToArray()

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LogEventArgs Class
LogEventArgs Members
EventData

Source Code

Log/Log.Event.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ToString Method
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > LogEventArgs Class : ToString Method

Glossary Item Box

Returns the entire collection of EventData records as a single line-delimited string

Syntax

Visual Basic (Declaration)
Public Overrides Function ToString() As String
C#
public override string ToString()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LogEventArgs Class
LogEventArgs Members
Base Implementation in ToString

Source Code

Log/Log.Event.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LogEventArgs Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : LogEventArgs Class

Glossary Item Box

For a list of all members of this type, see LogEventArgs members.

Public Properties

 | Name | Description
Public Property | Count | Returns the count of items in the collection
Top

See Also

Reference

LogEventArgs Class
CSharpTest.Net.Logging Namespace
LogEventHandler.Invoke(Object,LogEventArgs)
IAsyncResult LogEventHandler.BeginInvoke(Object,LogEventArgs,AsyncCallback,Object)

Source Code

Log/Log.Event.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Count Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > LogEventArgs Class : Count Property

Glossary Item Box

Returns the count of items in the collection

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Count As Integer
C#
public int Count {get;}

Example

Log/Test/NegativeTests.cs

C# Copy Code
Log.LogWrite += BreakIn_LogWrite;
try
{

    string message = "Bad {500} Data: {0}";
    Exception myError = i_blow_up;
    LogEventArgs arg1 = null;

    LogEventHandler eh = new LogEventHandler(delegate(object s, LogEventArgs e) { arg1 = e; });
    Log.LogWrite += eh;
    Log.LogWrite += BreakIn_LogWrite;
    Log.Error(myError, message, i_blow_up);
    Log.LogWrite -= eh;
    Log.LogWrite -= BreakIn_LogWrite;

    Assert.IsNotNull(arg1);
    Assert.AreEqual(1, arg1.Count);
    Assert.AreEqual(1, arg1.ToArray().Length);

    EventData data = arg1.ToArray()[0];
    Assert.IsNotNull(data);
    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, myError.GetType());

    Assert.IsTrue(data.ToString().Contains(message));
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message));
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.GetType().FullName));

    data.Write((System.Xml.XmlTextWriter)null);
    System.Xml.XmlTextWriter wtr = new System.Xml.XmlTextWriter(new MemoryStream(new byte[10]), System.Text.Encoding.UTF32);
    data.Write(wtr);

    data.Write(new StreamWriter(new MemoryStream(new byte[10])));
    foreach (string format in badFormats)
        data.Write(new StreamWriter(new MemoryStream(new byte[10])), format);

    BinaryFormatter ser = new BinaryFormatter();
    MemoryStream ms = new MemoryStream();

    ser.Serialize(ms, arg1);
    Assert.Greater((int)ms.Position, 0);

    ms.Position = 0;
    object restored = ser.Deserialize(ms);
    Assert.IsNotNull(restored);
    Assert.AreEqual(typeof(LogEventArgs), restored.GetType());
    LogEventArgs arg2 = restored as LogEventArgs;

    Assert.IsNotNull(arg2);
    Assert.AreEqual(1, arg2.Count);
    Assert.AreEqual(1, arg2.ToArray().Length);

    data = arg2.ToArray()[0];
    Assert.IsNotNull(data);

    Assert.IsNotNull(data.Exception);
    Assert.AreNotEqual(myError.GetType(), data.Exception.GetType());
    Assert.AreEqual(typeof(Log).Assembly, data.Exception.GetType().Assembly);
    Assert.IsTrue(data.Exception.Message.Contains(myError.GetType().FullName));
    Assert.IsNotNull(data.Exception.ToString());
    Assert.AreNotEqual(String.Empty, data.Exception.ToString());
    Assert.IsTrue(data.Exception.ToString().Contains(myError.GetType().FullName));

    BasicLogTest.AssertMessage(GetType(), null, data, LogLevels.Error, null, data.Exception.GetType());

    System.Runtime.Serialization.SerializationInfo info = new System.Runtime.Serialization.SerializationInfo(data.Exception.GetType(), new myconverter());
    System.Runtime.Serialization.StreamingContext ctx = new System.Runtime.Serialization.StreamingContext();

    Exception err = (Exception)
        data.Exception.GetType().InvokeMember(null, System.Reflection.BindingFlags.CreateInstance,
        null, null, new object[] { info, ctx });

    Assert.IsNotNull(err.Message);
    Assert.IsNotEmpty(err.Message);
    Assert.IsNotNull(err.ToString());
    Assert.IsNotEmpty(err.ToString());
}
finally
{
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
    Log.LogWrite -= BreakIn_LogWrite;
}
VB.NET Copy Code
Log.LogWrite += BreakIn_LogWrite
Try

    Dim message As String = "Bad {500} Data: {0}"
    Dim myError As Exception = i_blow_up
    Dim arg1 As LogEventArgs = Nothing

    Dim eh As New LogEventHandler(Function(s As Object, e As LogEventArgs) Do
        arg1 = e
    End Function)
    Log.LogWrite += eh
    Log.LogWrite += BreakIn_LogWrite
    Log.[Error](myError, message, i_blow_up)
    Log.LogWrite -= eh
    Log.LogWrite -= BreakIn_LogWrite

    Assert.IsNotNull(arg1)
    Assert.AreEqual(1, arg1.Count)
    Assert.AreEqual(1, arg1.ToArray().Length)

    Dim data As EventData = arg1.ToArray()(0)
    Assert.IsNotNull(data)
    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, myError.[GetType]())

    Assert.IsTrue(data.ToString().Contains(message))
    Assert.IsTrue(data.ToString("{Message:%s!} {}").Contains(message))
    Assert.IsTrue(data.ToString("{Exception}").Contains(myError.[GetType]().FullName))

    data.Write(DirectCast(Nothing, System.Xml.XmlTextWriter))
    Dim wtr As New System.Xml.XmlTextWriter(New MemoryStream(New Byte(10) {}), System.Text.Encoding.UTF32)
    data.Write(wtr)

    data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})))
    For Each format As String In badFormats
        data.Write(New StreamWriter(New MemoryStream(New Byte(10) {})), format)
    Next

    Dim ser As New BinaryFormatter()
    Dim ms As New MemoryStream()

    ser.Serialize(ms, arg1)
    Assert.Greater(DirectCast(ms.Position, Integer), 0)

    ms.Position = 0
    Dim restored As Object = ser.Deserialize(ms)
    Assert.IsNotNull(restored)
    Assert.AreEqual(GetType(LogEventArgs), restored.[GetType]())
    Dim arg2 As LogEventArgs = TryCast(restored, LogEventArgs)

    Assert.IsNotNull(arg2)
    Assert.AreEqual(1, arg2.Count)
    Assert.AreEqual(1, arg2.ToArray().Length)

    data = arg2.ToArray()(0)
    Assert.IsNotNull(data)

    Assert.IsNotNull(data.Exception)
    Assert.AreNotEqual(myError.[GetType](), data.Exception.[GetType]())
    Assert.AreEqual(GetType(Log).Assembly, data.Exception.[GetType]().Assembly)
    Assert.IsTrue(data.Exception.Message.Contains(myError.[GetType]().FullName))
    Assert.IsNotNull(data.Exception.ToString())
    Assert.AreNotEqual([String].Empty, data.Exception.ToString())
    Assert.IsTrue(data.Exception.ToString().Contains(myError.[GetType]().FullName))

    BasicLogTest.AssertMessage([GetType](), Nothing, data, LogLevels.[Error], Nothing, data.Exception.[GetType]())

    Dim info As New System.Runtime.Serialization.SerializationInfo(data.Exception.[GetType](), New myconverter())
    Dim ctx As New System.Runtime.Serialization.StreamingContext()

    Dim err As Exception = DirectCast(data.Exception.[GetType]().InvokeMember(Nothing, System.Reflection.BindingFlags.CreateInstance, Nothing, Nothing, New Object() {info, ctx}), Exception)

    Assert.IsNotNull(err.Message)
    Assert.IsNotEmpty(err.Message)
    Assert.IsNotNull(err.ToString())
    Assert.IsNotEmpty(err.ToString())
Finally
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
    Log.LogWrite -= BreakIn_LogWrite
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LogEventArgs Class
LogEventArgs Members

Source Code

Log/Log.Event.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LogLevels Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : LogLevels Enumeration

Glossary Item Box

Defines the various levels of logging

Syntax

Visual Basic (Declaration)
Public Enum LogLevels
   Inherits System.Enum
C#
public enum LogLevels : System.Enum

Members

Member | Description
Critical | Logs a Fatal error
Error | Logs an Error
Info | Logs an Informational message
None | Logging is disabled
Verbose | Logs a Verbose message
Warning | Logs a Warning

Example

Log/Test/ConfigTest.cs

C# Copy Code
LogOutputs output = Log.Config.Output;
try
{
    string messageText = "Warning will robinson, DANGER!";

    Log.Config.SetOutputFormat(LogOutputs.All, "{Message}");
    Log.Config.SetOutputLevel(LogOutputs.All, LogLevels.Info);

    LogLevels newLevel = LogLevels.Warning;
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.AspNetTrace, newLevel));
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.TraceWrite, newLevel));
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.Console, newLevel));
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.EventLog, newLevel));
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.LogFile, newLevel));
    Assert.AreEqual(LogLevels.None, Log.Config.SetOutputLevel(LogOutputs.None, newLevel));

    Log.Config.Output = LogOutputs.All & ~LogOutputs.EventLog;

    TextWriter sw = new StringWriter(), orig = Console.Out;
    Console.SetOut(sw);
    string tempFile = Path.GetTempFileName();
    string origLog = Log.Config.LogFile;
    Log.Config.LogFile = tempFile;
    try
    {
        Log.Warning(messageText);
        Log.Info("Hello");
        Log.Verbose("Hello");
    }
    finally
    {
        Console.SetOut(orig);
        Log.Config.LogFile = origLog;
    }

    Assert.AreEqual(messageText, _lastTrace.Substring(GetType().FullName.Length + 2));
    Assert.AreEqual(messageText, sw.ToString().Trim());
    Assert.AreEqual(messageText, File.ReadAllText(tempFile).Trim());
}
finally
{
    Log.Config.Output = output;
    Log.Config.SetOutputLevel(LogOutputs.All, LogLevels.Verbose);
    Log.Config.SetOutputFormat(LogOutputs.All, "[{ManagedThreadId}] {Level} - {FullMessage}");
}
VB.NET Copy Code
Dim output As LogOutputs = Log.Config.Output
Try
    Dim messageText As String = "Warning will robinson, DANGER!"

    Log.Config.SetOutputFormat(LogOutputs.All, "{Message}")
    Log.Config.SetOutputLevel(LogOutputs.All, LogLevels.Info)

    Dim newLevel As LogLevels = LogLevels.Warning
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.AspNetTrace, newLevel))
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.TraceWrite, newLevel))
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.Console, newLevel))
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.EventLog, newLevel))
    Assert.AreEqual(LogLevels.Info, Log.Config.SetOutputLevel(LogOutputs.LogFile, newLevel))
    Assert.AreEqual(LogLevels.None, Log.Config.SetOutputLevel(LogOutputs.None, newLevel))

    Log.Config.Output = LogOutputs.All And Not LogOutputs.EventLog

    Dim sw As TextWriter = New StringWriter(), orig As TextWriter = Console.Out
    Console.SetOut(sw)
    Dim tempFile As String = Path.GetTempFileName()
    Dim origLog As String = Log.Config.LogFile
    Log.Config.LogFile = tempFile
    Try
        Log.Warning(messageText)
        Log.Info("Hello")
        Log.Verbose("Hello")
    Finally
        Console.SetOut(orig)
        Log.Config.LogFile = origLog
    End Try

    Assert.AreEqual(messageText, _lastTrace.Substring([GetType]().FullName.Length + 2))
    Assert.AreEqual(messageText, sw.ToString().Trim())
    Assert.AreEqual(messageText, File.ReadAllText(tempFile).Trim())
Finally
    Log.Config.Output = output
    Log.Config.SetOutputLevel(LogOutputs.All, LogLevels.Verbose)
    Log.Config.SetOutputFormat(LogOutputs.All, "[{ManagedThreadId}] {Level} - {FullMessage}")
End Try

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Logging.LogLevels

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Logging Namespace
LogLevels Log.Config.Level

Used By

LogLevels Log.Config.SetOutputLevel(LogOutputs,LogLevels)


%%PageItemTitle%%

[image]
CSharpTest.Net
LogOptions Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : LogOptions Enumeration

Glossary Item Box

Performance and behavior related LogOption for the log system.

Syntax

Visual Basic (Declaration)
Public Enum LogOptions
   Inherits System.Enum
C#
public enum LogOptions : System.Enum

Members

Member | Description
ConsoleColors | Uses a different color based on the level of the log message, Use ONLY nothing else is writting to the console.
Default | These are the default options used. Addtionally, if your debugging or using asp.net trace, the following will also be set: LogAddFileInfo
GZipLogFileOnRoll | GZip and append a .gz extension to log files as they are rolled, the current log file will remain unzipped.
LogAddAssemblyInfo | Populate the MethodAssemblyVersion and MethodAssembly properties for logging. Requires at least the LogImmediateCaller information.
LogAddFileInfo | If this is specified the file and line number where the log call was made will be available to log LogOutput.
LogImmediateCaller | Calls new StackFrame( n ) to retrieve the immediate caller of the log routine and pass it along to all logging information.
LogNearestCaller | Starting with n frames back walk back until the calling class is not decorated with the ////[System.Diagnostics.DebuggerNonUserCode()] attribute. This allows you to create wrapper classes that provide logging but are not considered to be the point of origin in the log. Can be slightly slower as this now reflects each class' attributes and addtionally may gather more than one stack frame.
None | No LogOption enabled

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Logging.LogOptions

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Logging Namespace
LogOptions Log.Config.Options


%%PageItemTitle%%

[image]
CSharpTest.Net
LogOutputs Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : LogOutputs Enumeration

Glossary Item Box

Defines the various possble outputs of the logging system

Syntax

Visual Basic (Declaration)
Public Enum LogOutputs
   Inherits System.Enum
C#
public enum LogOutputs : System.Enum

Members

Member | Description
All | Writes to all LogOutput types available
AspNetTrace | Outputs messages to the System.Web.HttpContext.Current.Trace.[Write/Warn]() methods
Console | Outputs messages to the Console.[Out/Error].WriteLine() methods
EventLog | Outputs messages to the event log
LogFile | Outputs messages to this process' log file
None | No default destination (Event will still fire if anyone is subscribed)
TraceWrite | Outputs messages to the System.Diagnostics.Trace.WriteLine() method

Example

Log/Test/ConfigTest.cs

C# Copy Code
LogOutputs defaultOutputs = Log.Config.Output;
Assert.AreEqual(defaultOutputs, Log.Config.Output);
Log.Config.Output = LogOutputs.TraceWrite;

Log.Write("Test Trace");
Assert.AreEqual(GetType().FullName + ": Test Trace", _lastTrace);

Assert.AreEqual(LogOutputs.TraceWrite, Log.Config.Output);

Log.Config.Output = LogOutputs.None;
_lastTrace = null;
Log.Write("Test Trace");
Assert.IsNull(_lastTrace);

Log.Config.Output = LogOutputs.TraceWrite | defaultOutputs;
Assert.AreEqual(LogOutputs.TraceWrite | defaultOutputs, Log.Config.Output);
VB.NET Copy Code
Dim defaultOutputs As LogOutputs = Log.Config.Output
Assert.AreEqual(defaultOutputs, Log.Config.Output)
Log.Config.Output = LogOutputs.TraceWrite

Log.Write("Test Trace")
Assert.AreEqual([GetType]().FullName + ": Test Trace", _lastTrace)

Assert.AreEqual(LogOutputs.TraceWrite, Log.Config.Output)

Log.Config.Output = LogOutputs.None
_lastTrace = Nothing
Log.Write("Test Trace")
Assert.IsNull(_lastTrace)

Log.Config.Output = LogOutputs.TraceWrite Or defaultOutputs
Assert.AreEqual(LogOutputs.TraceWrite Or defaultOutputs, Log.Config.Output)

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.Logging.LogOutputs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.Logging Namespace
LogOutputs Log.Config.Output

Used By

LogLevels Log.Config.SetOutputLevel(LogOutputs,LogLevels)
Log.Config.SetOutputFormat(LogOutputs,String)


%%PageItemTitle%%

[image]
CSharpTest.Net
LogEventHandler Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace : LogEventHandler Delegate

sender
args

Glossary Item Box

Log events are raised with this event handler

Syntax

Visual Basic (Declaration)
Public Delegate Sub LogEventHandler( _
   ByVal sender As Object, _
   ByVal args As LogEventArgs _
)
C#
public delegate void LogEventHandler(
   object sender,
   LogEventArgs args
)

Parameters

sender
args

Example

Log/Test/ThreadedLogTest.cs

C# Copy Code
Log.LogWrite += new LogEventHandler(Block_LogWrite);
try
{
    using (Log.Start("Blocking Test"))
    {
        //the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, false));

        //regaurdless, we should still get the first message
        EventData msg = NextMessage;
        Assert.AreEqual("Start Blocking Test", msg.Message);

        //Now let's just go nuts on the logger...
        for (int i = 0; i < 100; i++)
            Log.Write("Buffering at {0}%.", i);

        Thread.Sleep(100);
        Assert.AreEqual(0, _lastMessages.Count);
        _releaseBlock.Set();
        Thread.Sleep(100);
        Assert.IsFalse(_isBlocked.WaitOne(0, false));

        for (int i = 0; i < 100; i++)
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"));
    }
}
finally
{
    Log.LogWrite -= new LogEventHandler(Block_LogWrite);
}
VB.NET Copy Code
Log.LogWrite += New LogEventHandler(Block_LogWrite)
Try
    Using Log.Start("Blocking Test")
        'the start above should already get us in a blocked state:
        Assert.IsTrue(_isBlocked.WaitOne(300, False))

        'regaurdless, we should still get the first message
        Dim msg As EventData = NextMessage
        Assert.AreEqual("Start Blocking Test", msg.Message)

        'Now let's just go nuts on the logger...
        Dim i As Integer = 0
        While i < 100
            Log.Write("Buffering at {0}%.", i)
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        Thread.Sleep(100)
        Assert.AreEqual(0, _lastMessages.Count)
        _releaseBlock.[Set]()
        Thread.Sleep(100)
        Assert.IsFalse(_isBlocked.WaitOne(0, False))

        Dim i As Integer = 0
        While i < 100
            Assert.IsTrue(NextMessage.Message.StartsWith("Buffering at"))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
Finally
    Log.LogWrite -= New LogEventHandler(Block_LogWrite)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LogEventHandler Members
CSharpTest.Net.Logging Namespace


%%phrase%%

CSharpTest.Net.RpcLibrary Assembly
See Also Send Feedback Download Help File

Glossary Item Box

Namespaces

Namespace | Description
CSharpTest.Net.RpcLibrary |


%%ItemTitle%%

CSharpTest.Net.RpcLibrary Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly : CSharpTest.Net.RpcLibrary Namespace

Glossary Item Box

Classes

 | Class | Description
Class | RpcClientApi | Provides a connection-based wrapper around the RPC client
Class | RpcException | Exception class: RpcException : System.ComponentModel.Win32Exception Unspecified rpc error
Class | RpcServerApi | Provides server-side services for RPC

Interfaces

 | Interface | Description
Interface | IRpcClientInfo | An interface that provide contextual information about the client within an Rpc server call

Delegates

 | Delegate | Description
Delegate | RpcServerApi.RpcExecuteHandler | The delegate format for the OnExecute event

Enumerations

 | Enumeration | Description
Enumeration | RpcAuthentication | The authentication type to be used for connection, GSS_NEGOTIATE / WINNT are the most common. Be aware that GSS_NEGOTIATE is not available unless the machin is a member of a domain that is not running WinNT (or in legacy mode).
Enumeration | RpcError | WIN32 RPC Error Codes
Enumeration | RpcProtectionLevel | The protection level of the communications, RPC_C_PROTECT_LEVEL_PKT_PRIVACY is the default for authenticated communications.
Enumeration | RpcProtoseqType | Defines the type of protocol the client is connected with
Enumeration | RpcProtseq | Defines the various types of protocols that are supported by Win32 RPC

See Also

Reference

CSharpTest.Net.RpcLibrary Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcClientApi Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcClientApi Class

Glossary Item Box

Provides a connection-based wrapper around the RPC client

Syntax

Visual Basic (Declaration)
Public Class RpcClientApi
C#
public class RpcClientApi

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.RpcLibrary.RpcClientApi

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Members
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
RpcClientApi Class Members
See Also Fields Properties Methods Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcClientApi Class

Glossary Item Box

The following tables list the members exposed by RpcClientApi.

Public Constructors

 | Name | Description
Public Constructor | RpcClientApi Constructor | Connects to the provided server interface with the given protocol and server:endpoint
Top

Public Fields

 | Name | Description
Public Field | IID | The interface Id the client is connected to
Top

Public Properties

 | Name | Description
static (Shared in Visual Basic) | Anonymous | Returns a constant NetworkCredential that represents the Anonymous user
Public Property | Protocol | The protocol that was provided to the constructor
static (Shared in Visual Basic) | Self | Returns a constant NetworkCredential that represents the current Windows user
Top

Public Methods

 | Name | Description
Public Method | AuthenticateAs | Overloaded. Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user.
Public Method | Dispose | Disconnects the client and frees any resources.
Public Method | Execute | Sends a message as an array of bytes and retrieves the response from the server, if AuthenticateAs() has not been called, the client will authenticate as Anonymous.
Top

See Also

Reference

RpcClientApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcClientApi Constructor
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : RpcClientApi Constructor

iid
protocol
server
endpoint

Glossary Item Box

Connects to the provided server interface with the given protocol and server:endpoint

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal iid As Guid, _
   ByVal protocol As RpcProtseq, _
   ByVal server As String, _
   ByVal endpoint As String _
)
C#
public RpcClientApi(
   Guid iid,
   RpcProtseq protocol,
   string server,
   string endpoint
)

Parameters

iid
protocol
server
endpoint

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
RpcClientApi Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcClientApi Class

Glossary Item Box

For a list of all members of this type, see RpcClientApi members.

Public Methods

 | Name | Description
Public Method | AuthenticateAs | Overloaded. Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user.
Public Method | Dispose | Disconnects the client and frees any resources.
Public Method | Execute | Sends a message as an array of bytes and retrieves the response from the server, if AuthenticateAs() has not been called, the client will authenticate as Anonymous.
Top

See Also

Reference

RpcClientApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AuthenticateAs Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : AuthenticateAs Method

Glossary Item Box

Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user.

Overload List

Overload | Description
AuthenticateAs(NetworkCredential) | Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user.
AuthenticateAs(String,NetworkCredential) | Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user.
AuthenticateAs(String,NetworkCredential,RpcProtectionLevel,RpcAuthentication[]) | Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user. This overload allows you to specify the privacy level and authentication types to try. Normally these default to RPC_C_PROTECT_LEVEL_PKT_PRIVACY, and both RPC_C_AUTHN_GSS_NEGOTIATE or RPC_C_AUTHN_WINNT if that fails. If credentials is null, or is the Anonymous user, RPC_C_PROTECT_LEVEL_DEFAULT and RPC_C_AUTHN_NONE are used instead.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AuthenticateAs(NetworkCredential) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class > AuthenticateAs Method : AuthenticateAs(NetworkCredential) Method

credentials

Glossary Item Box

Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user.

Syntax

Visual Basic (Declaration)
Public Overloads Sub AuthenticateAs( _
   ByVal credentials As NetworkCredential _
)
C#
public void AuthenticateAs(
   NetworkCredential credentials
)

Parameters

credentials

Example

RpcLibrary/RpcLibrary.Test/TestClientInfo.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncacn_np, @"\pipe\testpipename", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    server.OnExecute +=
        delegate(IRpcClientInfo client, byte[] arg)
        {
            Assert.AreEqual(false, client.IsImpersonating);
            using (client.Impersonate())
            {
                Assert.AreEqual(true, client.IsImpersonating);
                using (client.Impersonate())
                    Assert.AreEqual(true, client.IsImpersonating);
                //does not dispose, we are still impersonating
                Assert.AreEqual(true, client.IsImpersonating);
            }
            Assert.AreEqual(false, client.IsImpersonating);
            return arg;
        };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, @"\pipe\testpipename"))
    {
        client.AuthenticateAs(RpcClientApi.Self);
        client.Execute(new byte[0]);
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncacn_np, "\pipe\testpipename", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    server.OnExecute += Function(client As IRpcClientInfo, arg As Byte()) Do
        Assert.AreEqual(False, client.IsImpersonating)
        Using client.Impersonate()
            Assert.AreEqual(True, client.IsImpersonating)
            Using client.Impersonate()
                Assert.AreEqual(True, client.IsImpersonating)
            End Using
            'does not dispose, we are still impersonating
            Assert.AreEqual(True, client.IsImpersonating)
        End Using
        Assert.AreEqual(False, client.IsImpersonating)
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncacn_np, Nothing, "\pipe\testpipename")
        client.AuthenticateAs(RpcClientApi.Self)
        client.Execute(New Byte(0) {})
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members
Overload List

Source Code

RpcLibrary/RpcClientApi.cs

Used By

Byte[] RpcClientApi.Execute(Byte[])


%%PageItemTitle%%

[image]
CSharpTest.Net
AuthenticateAs(String,NetworkCredential) Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class > AuthenticateAs Method : AuthenticateAs(String,NetworkCredential) Method

serverPrincipalName
credentials

Glossary Item Box

Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user.

Syntax

Visual Basic (Declaration)
Public Overloads Sub AuthenticateAs( _
   ByVal serverPrincipalName As String, _
   ByVal credentials As NetworkCredential _
)
C#
public void AuthenticateAs(
   string serverPrincipalName,
   NetworkCredential credentials
)

Parameters

serverPrincipalName
credentials

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members
Overload List

Used By

RpcClientApi.AuthenticateAs(NetworkCredential)

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AuthenticateAs(String,NetworkCredential,RpcProtectionLevel,RpcAuthentication[]) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class > AuthenticateAs Method : AuthenticateAs(String,NetworkCredential,RpcProtectionLevel,RpcAuthentication[]) Method

serverPrincipalName
credentials
level
authTypes

Glossary Item Box

Adds authentication information to the client, use the static Self to authenticate as the currently logged on Windows user. This overload allows you to specify the privacy level and authentication types to try. Normally these default to RPC_C_PROTECT_LEVEL_PKT_PRIVACY, and both RPC_C_AUTHN_GSS_NEGOTIATE or RPC_C_AUTHN_WINNT if that fails. If credentials is null, or is the Anonymous user, RPC_C_PROTECT_LEVEL_DEFAULT and RPC_C_AUTHN_NONE are used instead.

Syntax

Visual Basic (Declaration)
Public Overloads Sub AuthenticateAs( _
   ByVal serverPrincipalName As String, _
   ByVal credentials As NetworkCredential, _
   ByVal level As RpcProtectionLevel, _
   ByVal ParamArray authTypes() As RpcAuthentication _
)
C#
public void AuthenticateAs(
   string serverPrincipalName,
   NetworkCredential credentials,
   RpcProtectionLevel level,
   params RpcAuthentication[] authTypes
)

Parameters

serverPrincipalName
credentials
level
authTypes

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members
Overload List
RpcProtectionLevel
RpcAuthentication

Used By

RpcClientApi.AuthenticateAs(String,NetworkCredential)

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : Dispose Method

Glossary Item Box

Disconnects the client and frees any resources.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Execute Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : Execute Method

input

Glossary Item Box

Sends a message as an array of bytes and retrieves the response from the server, if AuthenticateAs() has not been called, the client will authenticate as Anonymous.

Syntax

Visual Basic (Declaration)
Public Function Execute( _
   ByVal input() As Byte _
) As Byte()
C#
public byte[] Execute(
   byte[] input
)

Parameters

input

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
RpcClientApi Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcClientApi Class

Glossary Item Box

For a list of all members of this type, see RpcClientApi members.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | Anonymous | Returns a constant NetworkCredential that represents the Anonymous user
Public Property | Protocol | The protocol that was provided to the constructor
static (Shared in Visual Basic) | Self | Returns a constant NetworkCredential that represents the current Windows user
Top

See Also

Reference

RpcClientApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Anonymous Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : Anonymous Property

Glossary Item Box

Returns a constant NetworkCredential that represents the Anonymous user

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Anonymous As NetworkCredential
C#
public static NetworkCredential Anonymous {get;}

Example

RpcLibrary/RpcLibrary.Test/TestClientInfo.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncacn_np, @"\pipe\testpipename", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_NONE);
    server.StartListening();
    server.OnExecute +=
        delegate(IRpcClientInfo client, byte[] arg)
        {
            Assert.AreEqual(0, arg.Length);
            Assert.AreEqual(RpcAuthentication.RPC_C_AUTHN_NONE, client.AuthenticationLevel);
            Assert.AreEqual(RpcProtectionLevel.RPC_C_PROTECT_LEVEL_NONE, client.ProtectionLevel);
            Assert.AreEqual(RpcProtoseqType.NMP, client.ProtocolType);
            Assert.AreEqual(new byte[0], client.ClientAddress);
            Assert.AreEqual(0, client.ClientPid.ToInt32());
            Assert.AreEqual(null, client.ClientPrincipalName);
            Assert.AreEqual(System.Security.Principal.WindowsIdentity.GetAnonymous().Name, client.ClientUser.Name);
            Assert.AreEqual(true, client.IsClientLocal);
            Assert.AreEqual(false, client.IsAuthenticated);
            Assert.AreEqual(false, client.IsImpersonating);

            bool failed = false;
            try { client.Impersonate().Dispose(); }
            catch (UnauthorizedAccessException) { failed = true; }
            Assert.AreEqual(true, failed);
            return arg;
        };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncacn_np, null, @"\pipe\testpipename"))
    {
        client.AuthenticateAs(RpcClientApi.Anonymous);
        client.Execute(new byte[0]);
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncacn_np, "\pipe\testpipename", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_NONE)
    server.StartListening()
    server.OnExecute += Function(client As IRpcClientInfo, arg As Byte()) Do
        Assert.AreEqual(0, arg.Length)
        Assert.AreEqual(RpcAuthentication.RPC_C_AUTHN_NONE, client.AuthenticationLevel)
        Assert.AreEqual(RpcProtectionLevel.RPC_C_PROTECT_LEVEL_NONE, client.ProtectionLevel)
        Assert.AreEqual(RpcProtoseqType.NMP, client.ProtocolType)
        Assert.AreEqual(New Byte(0) {}, client.ClientAddress)
        Assert.AreEqual(0, client.ClientPid.ToInt32())
        Assert.AreEqual(Nothing, client.ClientPrincipalName)
        Assert.AreEqual(System.Security.Principal.WindowsIdentity.GetAnonymous().Name, client.ClientUser.Name)
        Assert.AreEqual(True, client.IsClientLocal)
        Assert.AreEqual(False, client.IsAuthenticated)
        Assert.AreEqual(False, client.IsImpersonating)

        Dim failed As Boolean = False
        Try
            client.Impersonate().Dispose()
        Catch generatedExceptionName As UnauthorizedAccessException
            failed = True
        End Try
        Assert.AreEqual(True, failed)
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncacn_np, Nothing, "\pipe\testpipename")
        client.AuthenticateAs(RpcClientApi.Anonymous)
        client.Execute(New Byte(0) {})
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members

Used By

RpcClientApi.AuthenticateAs(String,NetworkCredential)
Byte[] RpcClientApi.Execute(Byte[])

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Protocol Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : Protocol Property

Glossary Item Box

The protocol that was provided to the constructor

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Protocol As RpcProtseq
C#
public RpcProtseq Protocol {get;}

Example

RpcLibrary/RpcLibrary.Test/TestClientApi.cs

C# Copy Code
using (RpcClientApi client = new RpcClientApi(Guid.NewGuid(), RpcProtseq.ncacn_ip_tcp, null, "123"))
    Assert.AreEqual(RpcProtseq.ncacn_ip_tcp, client.Protocol);
VB.NET Copy Code
Using client As New RpcClientApi(Guid.NewGuid(), RpcProtseq.ncacn_ip_tcp, Nothing, "123")
    Assert.AreEqual(RpcProtseq.ncacn_ip_tcp, client.Protocol)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members
RpcProtseq

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Self Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : Self Property

Glossary Item Box

Returns a constant NetworkCredential that represents the current Windows user

Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property Self As NetworkCredential
C#
public static NetworkCredential Self {get;}

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
RpcClientApi Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcClientApi Class

Glossary Item Box

For a list of all members of this type, see RpcClientApi members.

Public Fields

 | Name | Description
Public Field | IID | The interface Id the client is connected to
Top

See Also

Reference

RpcClientApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IID Field
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcClientApi Class : IID Field

Glossary Item Box

The interface Id the client is connected to

Syntax

Visual Basic (Declaration)
Public ReadOnly IID As Guid
C#
public readonly Guid IID

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcClientApi Class
RpcClientApi Members

Used By

Byte[] RpcClientApi.Execute(Byte[])

Source Code

RpcLibrary/RpcClientApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcException Class
Members See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcException Class

Glossary Item Box

Exception class: RpcException : System.ComponentModel.Win32Exception Unspecified rpc error

Syntax

Visual Basic (Declaration)
<SerializableAttribute()>
Public Class RpcException
   Inherits System.ComponentModel.Win32Exception
C#
[SerializableAttribute()]
public class RpcException : System.ComponentModel.Win32Exception

Inheritance Hierarchy

System.Object
System.Exception
System.SystemException
System.Runtime.InteropServices.ExternalException
System.ComponentModel.Win32Exception
CSharpTest.Net.RpcLibrary.RpcException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Members
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
RpcException Class Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcException Class

Glossary Item Box

The following tables list the members exposed by RpcException.

Public Constructors

 | Name | Description
Public Constructor | RpcException Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | ErrorCode | Gets the HRESULT of the error. (Inherited from System.Runtime.InteropServices.ExternalException)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | NativeErrorCode | (Inherited from System.ComponentModel.Win32Exception)
Public Property | RpcError | Returns the RPC Error as an enumeration
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | Overloaded. if(condition == false) throws Unspecified rpc error
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

RpcException Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcException Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class : RpcException Constructor

Glossary Item Box

Overload List

Overload | Description
RpcException Constructor(SerializationInfo,StreamingContext) | Serialization constructor
RpcException Constructor() | Unspecified rpc error
RpcException Constructor(Exception) | Unspecified rpc error
RpcException Constructor(String) | {0}
RpcException Constructor(String,Exception) | {0}
RpcException Constructor(RpcError) | Exception class: RpcException : System.ComponentModel.Win32Exception Unspecified rpc error

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcException Constructor(SerializationInfo,StreamingContext)
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > RpcException Constructor : RpcException Constructor(SerializationInfo,StreamingContext)

info
context

Glossary Item Box

Serialization constructor

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal info As SerializationInfo, _
   ByVal context As StreamingContext _
)
C#
protected RpcException(
   SerializationInfo info,
   StreamingContext context
)

Parameters

info
context

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcException Constructor()
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > RpcException Constructor : RpcException Constructor()

Glossary Item Box

Unspecified rpc error

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public RpcException()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List

Used By

RpcException.Assert(Boolean)

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcException Constructor(Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > RpcException Constructor : RpcException Constructor(Exception)

innerException

Glossary Item Box

Unspecified rpc error

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal innerException As Exception _
)
C#
public RpcException(
   Exception innerException
)

Parameters

innerException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcException Constructor(String)
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > RpcException Constructor : RpcException Constructor(String)

message

Glossary Item Box

{0}

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal message As String _
)
C#
public RpcException(
   string message
)

Parameters

message

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List

Used By

RpcException.Assert(Boolean,String)

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcException Constructor(String,Exception)
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > RpcException Constructor : RpcException Constructor(String,Exception)

message
innerException

Glossary Item Box

{0}

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal message As String, _
   ByVal innerException As Exception _
)
C#
public RpcException(
   string message,
   Exception innerException
)

Parameters

message
innerException

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcException Constructor(RpcError)
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > RpcException Constructor : RpcException Constructor(RpcError)

errorCode

Glossary Item Box

Exception class: RpcException : System.ComponentModel.Win32Exception Unspecified rpc error

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal errorCode As RpcError _
)
C#
public RpcException(
   RpcError errorCode
)

Parameters

errorCode

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List

Used By

RpcException.Assert(RpcError)

Source Code

RpcLibrary/RpcException.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
RpcException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcException Class

Glossary Item Box

For a list of all members of this type, see RpcException members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | Assert | Overloaded. if(condition == false) throws Unspecified rpc error
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

RpcException Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class : Assert Method

Glossary Item Box

if(condition == false) throws Unspecified rpc error

Overload List

Overload | Description
Assert(Boolean) | if(condition == false) throws Unspecified rpc error
Assert(Boolean,String) | if(condition == false) throws {0}
Assert(RpcError) | Asserts that the argument is set to RpcError.RPC_S_OK or throws a new exception.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(Boolean) Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > Assert Method : Assert(Boolean) Method

condition

Glossary Item Box

if(condition == false) throws Unspecified rpc error

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal condition As Boolean _
)
C#
public static void Assert(
   bool condition
)

Parameters

condition

Exceptions

Exception | Description
RpcException | Exception class: RpcException : System.ComponentModel.Win32Exception Unspecified rpc error

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(Boolean,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > Assert Method : Assert(Boolean,String) Method

condition
message

Glossary Item Box

if(condition == false) throws {0}

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal condition As Boolean, _
   ByVal message As String _
)
C#
public static void Assert(
   bool condition,
   string message
)

Parameters

condition
message

Exceptions

Exception | Description
RpcException | Exception class: RpcException : System.ComponentModel.Win32Exception Unspecified rpc error

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Assert(RpcError) Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class > Assert Method : Assert(RpcError) Method

errorCode

Glossary Item Box

Asserts that the argument is set to RpcError.RPC_S_OK or throws a new exception.

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub Assert( _
   ByVal errorCode As RpcError _
)
C#
public static void Assert(
   RpcError errorCode
)

Parameters

errorCode

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
Overload List
RpcError

Source Code

RpcLibrary/RpcException.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
RpcException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcException Class

Glossary Item Box

For a list of all members of this type, see RpcException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | ErrorCode | Gets the HRESULT of the error. (Inherited from System.Runtime.InteropServices.ExternalException)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | NativeErrorCode | (Inherited from System.ComponentModel.Win32Exception)
Public Property | RpcError | Returns the RPC Error as an enumeration
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

RpcException Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/Resources.Designer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcError Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcException Class : RpcError Property

Glossary Item Box

Returns the RPC Error as an enumeration

Syntax

Visual Basic (Declaration)
Public ReadOnly Property RpcError As RpcError
C#
public RpcError RpcError {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcException Class
RpcException Members
RpcError

Source Code

RpcLibrary/RpcException.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcServerApi Class
Members Example See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcServerApi Class

Glossary Item Box

Provides server-side services for RPC

Syntax

Visual Basic (Declaration)
Public Class RpcServerApi
C#
public class RpcServerApi

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.RpcLibrary.RpcServerApi

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Members
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
RpcServerApi Class Members
See Also Fields Properties Methods Events Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcServerApi Class

Glossary Item Box

The following tables list the members exposed by RpcServerApi.

Public Constructors

 | Name | Description
Public Constructor | RpcServerApi Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | DEF_REQ_LIMIT | Use the default request limits
Public Field | IID | The interface Id the service is using
Public Field | MAX_CALL_LIMIT | The max limit of in-flight calls
Top

Public Properties

 | Name | Description
static (Shared in Visual Basic) | VerboseLogging | Enables verbose logging of the RPC calls to the Trace window
Top

Public Methods

 | Name | Description
Public Method | AddAuthentication | Overloaded. Adds a type of authentication sequence that will be allowed for RPC connections to this process.
Public Method | AddProtocol | Used to ensure that the server is listening with a specific protocol type. Once invoked this can not be undone, and all RPC servers within the process will be available on that protocol
Public Method | Dispose | Disposes of the server and stops listening if the server is currently listening
Public Method | Execute | Can be over-ridden in a derived class to handle the incomming RPC request, or you can subscribe to the OnExecute event.
Public Method | StartListening | Starts the RPC listener for this instance, if this is the first RPC server instance the process starts listening on the registered protocols.
Public Method | StopListening | Stops listening for this instance, if this is the last instance to stop listening the process stops listening on all registered protocols.
Top

Public Events

 | Name | Description
Public Event | OnExecute | Allows a single subscription to this event to handle incomming requests rather than deriving from and overriding the Execute call.
Top

See Also

Reference

RpcServerApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcServerApi Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : RpcServerApi Constructor

Glossary Item Box

Overload List

Overload | Description
RpcServerApi Constructor(Guid) | Constructs an RPC server for the given interface guid, the guid is used to identify multiple rpc servers/services within a single process.
RpcServerApi Constructor(Guid,Int32,Int32,Boolean) | Constructs an RPC server for the given interface guid, the guid is used to identify multiple rpc servers/services within a single process.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcServerApi Constructor(Guid)
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class > RpcServerApi Constructor : RpcServerApi Constructor(Guid)

iid

Glossary Item Box

Constructs an RPC server for the given interface guid, the guid is used to identify multiple rpc servers/services within a single process.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal iid As Guid _
)
C#
public RpcServerApi(
   Guid iid
)

Parameters

iid

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members
Overload List

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcServerApi Constructor(Guid,Int32,Int32,Boolean)
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class > RpcServerApi Constructor : RpcServerApi Constructor(Guid,Int32,Int32,Boolean)

iid
maxCalls
maxRequestBytes
allowAnonTcp

Glossary Item Box

Constructs an RPC server for the given interface guid, the guid is used to identify multiple rpc servers/services within a single process.

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal iid As Guid, _
   ByVal maxCalls As Integer, _
   ByVal maxRequestBytes As Integer, _
   ByVal allowAnonTcp As Boolean _
)
C#
public RpcServerApi(
   Guid iid,
   int maxCalls,
   int maxRequestBytes,
   bool allowAnonTcp
)

Parameters

iid
maxCalls
maxRequestBytes
allowAnonTcp

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members
Overload List

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
RpcServerApi Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcServerApi Class

Glossary Item Box

For a list of all members of this type, see RpcServerApi members.

Public Methods

 | Name | Description
Public Method | AddAuthentication | Overloaded. Adds a type of authentication sequence that will be allowed for RPC connections to this process.
Public Method | AddProtocol | Used to ensure that the server is listening with a specific protocol type. Once invoked this can not be undone, and all RPC servers within the process will be available on that protocol
Public Method | Dispose | Disposes of the server and stops listening if the server is currently listening
Public Method | Execute | Can be over-ridden in a derived class to handle the incomming RPC request, or you can subscribe to the OnExecute event.
Public Method | StartListening | Starts the RPC listener for this instance, if this is the first RPC server instance the process starts listening on the registered protocols.
Public Method | StopListening | Stops listening for this instance, if this is the last instance to stop listening the process stops listening on all registered protocols.
Top

See Also

Reference

RpcServerApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddAuthentication Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : AddAuthentication Method

Glossary Item Box

Adds a type of authentication sequence that will be allowed for RPC connections to this process.

Overload List

Overload | Description
AddAuthentication(RpcAuthentication) | Adds a type of authentication sequence that will be allowed for RPC connections to this process.
AddAuthentication(RpcAuthentication,String) | Adds a type of authentication sequence that will be allowed for RPC connections to this process.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddAuthentication(RpcAuthentication) Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class > AddAuthentication Method : AddAuthentication(RpcAuthentication) Method

type

Glossary Item Box

Adds a type of authentication sequence that will be allowed for RPC connections to this process.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddAuthentication( _
   ByVal type As RpcAuthentication _
) As Boolean
C#
public bool AddAuthentication(
   RpcAuthentication type
)

Parameters

type

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members
Overload List
RpcAuthentication

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddAuthentication(RpcAuthentication,String) Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class > AddAuthentication Method : AddAuthentication(RpcAuthentication,String) Method

type
serverPrincipalName

Glossary Item Box

Adds a type of authentication sequence that will be allowed for RPC connections to this process.

Syntax

Visual Basic (Declaration)
Public Overloads Function AddAuthentication( _
   ByVal type As RpcAuthentication, _
   ByVal serverPrincipalName As String _
) As Boolean
C#
public bool AddAuthentication(
   RpcAuthentication type,
   string serverPrincipalName
)

Parameters

type
serverPrincipalName

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members
Overload List
RpcAuthentication

Used By

Boolean RpcServerApi.AddAuthentication(RpcAuthentication)

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddProtocol Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : AddProtocol Method

protocol
endpoint
maxCalls

Glossary Item Box

Used to ensure that the server is listening with a specific protocol type. Once invoked this can not be undone, and all RPC servers within the process will be available on that protocol

Syntax

Visual Basic (Declaration)
Public Function AddProtocol( _
   ByVal protocol As RpcProtseq, _
   ByVal endpoint As String, _
   ByVal maxCalls As Integer _
) As Boolean
C#
public bool AddProtocol(
   RpcProtseq protocol,
   string endpoint,
   int maxCalls
)

Parameters

protocol
endpoint
maxCalls

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members
RpcProtseq

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : Dispose Method

Glossary Item Box

Disposes of the server and stops listening if the server is currently listening

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Execute Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : Execute Method

client
input

Glossary Item Box

Can be over-ridden in a derived class to handle the incomming RPC request, or you can subscribe to the OnExecute event.

Syntax

Visual Basic (Declaration)
Public Overridable Function Execute( _
   ByVal client As IRpcClientInfo, _
   ByVal input() As Byte _
) As Byte()
C#
public virtual byte[] Execute(
   IRpcClientInfo client,
   byte[] input
)

Parameters

client
input

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members
IRpcClientInfo

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StartListening Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : StartListening Method

Glossary Item Box

Starts the RPC listener for this instance, if this is the first RPC server instance the process starts listening on the registered protocols.

Syntax

Visual Basic (Declaration)
Public Sub StartListening()
C#
public void StartListening()

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StopListening Method
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : StopListening Method

Glossary Item Box

Stops listening for this instance, if this is the last instance to stop listening the process stops listening on all registered protocols.

Syntax

Visual Basic (Declaration)
Public Sub StopListening()
C#
public void StopListening()

Example

RpcLibrary/RpcLibrary.Test/TestClientApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    server.OnExecute +=
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    {
        RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest");
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);
        client.Execute(new byte[0]);
        client = null;
    }

    GC.Collect(0, GCCollectionMode.Forced);
    GC.WaitForPendingFinalizers();

    server.StopListening();
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    server.OnExecute += Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    If True Then
        Dim client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)
        client.Execute(New Byte(0) {})
        client = Nothing
    End If

    GC.Collect(0, GCCollectionMode.Forced)
    GC.WaitForPendingFinalizers()

    server.StopListening()
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members

Used By

RpcServerApi.Dispose()

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
RpcServerApi Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcServerApi Class

Glossary Item Box

For a list of all members of this type, see RpcServerApi members.

Public Properties

 | Name | Description
static (Shared in Visual Basic) | VerboseLogging | Enables verbose logging of the RPC calls to the Trace window
Top

See Also

Reference

RpcServerApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
VerboseLogging Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : VerboseLogging Property

Glossary Item Box

Enables verbose logging of the RPC calls to the Trace window

Syntax

Visual Basic (Declaration)
Public Shared Property VerboseLogging As Boolean
C#
public static bool VerboseLogging {get; set;}

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
RpcServerApi.VerboseLogging = true;
Assert.IsTrue(RpcServerApi.VerboseLogging);

RpcServerApi.VerboseLogging = false;
Assert.IsFalse(RpcServerApi.VerboseLogging);
VB.NET Copy Code
RpcServerApi.VerboseLogging = True
Assert.IsTrue(RpcServerApi.VerboseLogging)

RpcServerApi.VerboseLogging = False
Assert.IsFalse(RpcServerApi.VerboseLogging)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
RpcServerApi Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcServerApi Class

Glossary Item Box

For a list of all members of this type, see RpcServerApi members.

Public Fields

 | Name | Description
Public Field | DEF_REQ_LIMIT | Use the default request limits
Public Field | IID | The interface Id the service is using
Public Field | MAX_CALL_LIMIT | The max limit of in-flight calls
Top

See Also

Reference

RpcServerApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DEF_REQ_LIMIT Field
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : DEF_REQ_LIMIT Field

Glossary Item Box

Use the default request limits

Syntax

Visual Basic (Declaration)
Public Const DEF_REQ_LIMIT As Integer
C#
public const int DEF_REQ_LIMIT

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IID Field
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : IID Field

Glossary Item Box

The interface Id the service is using

Syntax

Visual Basic (Declaration)
Public ReadOnly IID As Guid
C#
public readonly Guid IID

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
MAX_CALL_LIMIT Field
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : MAX_CALL_LIMIT Field

Glossary Item Box

The max limit of in-flight calls

Syntax

Visual Basic (Declaration)
Public Const MAX_CALL_LIMIT As Integer
C#
public const int MAX_CALL_LIMIT

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
RpcServerApi Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcServerApi Class

Glossary Item Box

For a list of all members of this type, see RpcServerApi members.

Public Events

 | Name | Description
Public Event | OnExecute | Allows a single subscription to this event to handle incomming requests rather than deriving from and overriding the Execute call.
Top

See Also

Reference

RpcServerApi Class
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnExecute Event
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > RpcServerApi Class : OnExecute Event

Glossary Item Box

Allows a single subscription to this event to handle incomming requests rather than deriving from and overriding the Execute call.

Syntax

Visual Basic (Declaration)
Public Event OnExecute As RpcServerApi.RpcExecuteHandler
C#
public event RpcServerApi.RpcExecuteHandler OnExecute

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi Class
RpcServerApi Members

Source Code

RpcLibrary/RpcServerApi.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcAuthentication Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcAuthentication Enumeration

Glossary Item Box

The authentication type to be used for connection, GSS_NEGOTIATE / WINNT are the most common. Be aware that GSS_NEGOTIATE is not available unless the machin is a member of a domain that is not running WinNT (or in legacy mode).

Syntax

Visual Basic (Declaration)
Public Enum RpcAuthentication
   Inherits System.Enum
C#
public enum RpcAuthentication : System.Enum

Members

Member | Description
RPC_C_AUTHN_DCE_PRIVATE |
RPC_C_AUTHN_DCE_PUBLIC |
RPC_C_AUTHN_DEC_PUBLIC |
RPC_C_AUTHN_DEFAULT |
RPC_C_AUTHN_DIGEST |
RPC_C_AUTHN_DPA |
RPC_C_AUTHN_GSS_KERBEROS |
RPC_C_AUTHN_GSS_NEGOTIATE |
RPC_C_AUTHN_GSS_SCHANNEL |
RPC_C_AUTHN_MQ |
RPC_C_AUTHN_MSN |
RPC_C_AUTHN_NONE |
RPC_C_AUTHN_WINNT |

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.RpcLibrary.RpcAuthentication

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.RpcLibrary Namespace
RpcAuthentication IRpcClientInfo.AuthenticationLevel
RpcClientApi.AuthenticateAs(String,NetworkCredential,RpcProtectionLevel,RpcAuthentication[])
Boolean RpcServerApi.AddAuthentication(RpcAuthentication)
Boolean RpcServerApi.AddAuthentication(RpcAuthentication,String)

Used By

RpcClientApi.AuthenticateAs(String,NetworkCredential)


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcError Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcError Enumeration

Glossary Item Box

WIN32 RPC Error Codes

Syntax

Visual Basic (Declaration)
Public Enum RpcError
   Inherits System.Enum
C#
public enum RpcError : System.Enum

Members

Member | Description
EPT_S_CANT_PERFORM_OP |
EPT_S_INVALID_ENTRY |
EPT_S_NOT_REGISTERED |
RPC_E_FAIL |
RPC_S_ACCESS_DENIED |
RPC_S_ADDRESS_ERROR |
RPC_S_ALREADY_LISTENING |
RPC_S_ALREADY_REGISTERED |
RPC_S_ASYNC_CALL_PENDING |
RPC_S_BINDING_HAS_NO_AUTH |
RPC_S_BUFFER_TOO_SMALL |
RPC_S_CALL_FAILED |
RPC_S_CALL_FAILED_DNE |
RPC_S_CANNOT_SUPPORT |
RPC_S_CANT_CREATE_ENDPOINT |
RPC_S_DUPLICATE_ENDPOINT |
RPC_S_ENTRY_ALREADY_EXISTS |
RPC_S_ENTRY_NOT_FOUND |
RPC_S_FP_DIV_ZERO |
RPC_S_FP_OVERFLOW |
RPC_S_FP_UNDERFLOW |
RPC_S_INCOMPLETE_NAME |
RPC_S_INTERFACE_NOT_FOUND |
RPC_S_INTERNAL_ERROR |
RPC_S_INVALID_ARG |
RPC_S_INVALID_AUTH_IDENTITY |
RPC_S_INVALID_BINDING |
RPC_S_INVALID_BOUND |
RPC_S_INVALID_ENDPOINT_FORMAT |
RPC_S_INVALID_NAF_ID |
RPC_S_INVALID_NAME_SYNTAX |
RPC_S_INVALID_NET_ADDR |
RPC_S_INVALID_NETWORK_OPTIONS |
RPC_S_INVALID_RPC_PROTSEQ |
RPC_S_INVALID_SECURITY_DESC |
RPC_S_INVALID_STRING_BINDING |
RPC_S_INVALID_STRING_UUID |
RPC_S_INVALID_TAG |
RPC_S_INVALID_TIMEOUT |
RPC_S_INVALID_VERS_OPTION |
RPC_S_MAX_CALLS_TOO_SMALL |
RPC_S_NAME_SERVICE_UNAVAILABLE |
RPC_S_NO_BINDINGS |
RPC_S_NO_CALL_ACTIVE |
RPC_S_NO_CONTEXT_AVAILABLE |
RPC_S_NO_ENDPOINT_FOUND |
RPC_S_NO_ENTRY_NAME |
RPC_S_NO_MORE_MEMBERS |
RPC_S_NO_PROTSEQS |
RPC_S_NO_PROTSEQS_REGISTERED |
RPC_S_NOT_ALL_OBJS_UNEXPORTED |
RPC_S_NOT_LISTENING |
RPC_S_NOTHING_TO_EXPORT |
RPC_S_OBJECT_NOT_FOUND |
RPC_S_OK |
RPC_S_OUT_OF_MEMORY |
RPC_S_OUT_OF_RESOURCES |
RPC_S_OUT_OF_THREADS |
RPC_S_PROCNUM_OUT_OF_RANGE |
RPC_S_PROTOCOL_ERROR |
RPC_S_PROTSEQ_NOT_FOUND |
RPC_S_PROTSEQ_NOT_SUPPORTED |
RPC_S_PROXY_ACCESS_DENIED |
RPC_S_SERVER_OUT_OF_MEMORY |
RPC_S_SERVER_TOO_BUSY |
RPC_S_SERVER_UNAVAILABLE |
RPC_S_STRING_TOO_LONG |
RPC_S_TIMEOUT |
RPC_S_TYPE_ALREADY_REGISTERED |
RPC_S_UNKNOWN_AUTHN_LEVEL |
RPC_S_UNKNOWN_AUTHN_SERVICE |
RPC_S_UNKNOWN_AUTHN_TYPE |
RPC_S_UNKNOWN_AUTHZ_SERVICE |
RPC_S_UNKNOWN_IF |
RPC_S_UNKNOWN_MGR_TYPE |
RPC_S_UNKNOWN_PRINCIPAL |
RPC_S_UNSUPPORTED_NAME_SYNTAX |
RPC_S_UNSUPPORTED_TRANS_SYN |
RPC_S_UNSUPPORTED_TYPE |
RPC_S_UUID_NO_ADDRESS |
RPC_S_WRONG_KIND_OF_BINDING |
RPC_S_ZERO_DIVIDE |
RPC_X_BAD_STUB_DATA |
RPC_X_BYTE_COUNT_TOO_SMALL |
RPC_X_ENUM_VALUE_OUT_OF_RANGE |
RPC_X_NO_MORE_ENTRIES |
RPC_X_NULL_REF_POINTER |
RPC_X_SS_CANNOT_GET_CALL_HANDLE |
RPC_X_SS_CHAR_TRANS_OPEN_FAIL |
RPC_X_SS_CHAR_TRANS_SHORT_FILE |
RPC_X_SS_CONTEXT_DAMAGED |
RPC_X_SS_HANDLES_MISMATCH |
RPC_X_SS_IN_NULL_CONTEXT |

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.RpcLibrary.RpcError

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.RpcLibrary Namespace
RpcError RpcException.RpcError

Used By

RpcException.Assert(RpcError)


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcProtectionLevel Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcProtectionLevel Enumeration

Glossary Item Box

The protection level of the communications, RPC_C_PROTECT_LEVEL_PKT_PRIVACY is the default for authenticated communications.

Syntax

Visual Basic (Declaration)
Public Enum RpcProtectionLevel
   Inherits System.Enum
C#
public enum RpcProtectionLevel : System.Enum

Members

Member | Description
RPC_C_PROTECT_LEVEL_CALL |
RPC_C_PROTECT_LEVEL_CONNECT |
RPC_C_PROTECT_LEVEL_DEFAULT |
RPC_C_PROTECT_LEVEL_NONE |
RPC_C_PROTECT_LEVEL_PKT |
RPC_C_PROTECT_LEVEL_PKT_INTEGRITY |
RPC_C_PROTECT_LEVEL_PKT_PRIVACY |

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.RpcLibrary.RpcProtectionLevel

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.RpcLibrary Namespace
RpcProtectionLevel IRpcClientInfo.ProtectionLevel
RpcClientApi.AuthenticateAs(String,NetworkCredential,RpcProtectionLevel,RpcAuthentication[])


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcProtoseqType Enumeration
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcProtoseqType Enumeration

Glossary Item Box

Defines the type of protocol the client is connected with

Syntax

Visual Basic (Declaration)
Public Enum RpcProtoseqType
   Inherits System.Enum
C#
public enum RpcProtoseqType : System.Enum

Members

Member | Description
HTTP | HTTP / IIS integrated
LRPC | LPRC / Local RPC
NMP | Named Pipes
TCP | TCP, UDP, IPX over TCP, etc

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.RpcLibrary.RpcProtoseqType

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.RpcLibrary Namespace
RpcProtoseqType IRpcClientInfo.ProtocolType


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcProtseq Enumeration
Example See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcProtseq Enumeration

Glossary Item Box

Defines the various types of protocols that are supported by Win32 RPC

Syntax

Visual Basic (Declaration)
Public Enum RpcProtseq
   Inherits System.Enum
C#
public enum RpcProtseq : System.Enum

Members

Member | Description
ncacn_at_dsp | Connection-oriented AppleTalk DSP Client: Apple Macintosh Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT
ncacn_dnet_nsp | Connection-oriented DECnet transport Client only: MS-DOS, Windows 3.x
ncacn_http | Connection-oriented TCP/IP using Microsoft Internet Information Server as HTTP proxy Client only: Windows Me/98/95 Client and Server: Windows Server 2003, Windows XP, Windows 2000
ncacn_ip_tcp | Connection-oriented Transmission Control Protocol/Internet Protocol (TCP/IP) Client only: MS-DOS, Windows 3.x, and Apple Macintosh Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT, Windows Me, Windows 98, Windows 95
ncacn_nb_ipx | Connection-oriented NetBIOS over Internet Packet Exchange (IPX) Client only: MS-DOS, Windows 3.x Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT
ncacn_nb_nb | Connection-oriented NetBIOS Enhanced User Interface (NetBEUI) Client only: MS-DOS, Windows 3.x Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT, Windows Me, Windows 98, Windows 95
ncacn_nb_tcp | Connection-oriented NetBIOS over Transmission Control Protocol (TCP) Client only: MS-DOS, Windows 3.x Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT
ncacn_np | Connection-oriented named pipes Client only: MS-DOS, Windows 3.x, Windows 95 Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT
ncacn_spx | Connection-oriented Sequenced Packet Exchange (SPX) Client only: MS-DOS, Windows 3.x Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT, Windows Me, Windows 98, Windows 95
ncacn_vns_spp | Connection-oriented Vines scalable parallel processing (SPP) transport Client only: MS-DOS, Windows 3.x Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT
ncadg_ip_udp | Datagram (connectionless) User Datagram Protocol/Internet Protocol (UDP/IP) Client only: MS-DOS, Windows 3.x Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT
ncadg_ipx | Datagram (connectionless) IPX Client only: MS-DOS, Windows 3.x Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT
ncadg_mq | Datagram (connectionless) over the Microsoft Message Queue Server (MSMQ) Client only: Windows Me/98/95 Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT Server 4.0 with SP3 and later
ncalrpc | Local procedure call Client and Server: Windows Server 2003, Windows XP, Windows 2000, Windows NT, Windows Me, Windows 98, Windows 95

Example

RpcLibrary/RpcLibrary.Test/TestClientApi.cs

C# Copy Code
using (RpcClientApi client = new RpcClientApi(Guid.NewGuid(), RpcProtseq.ncacn_ip_tcp, null, "123"))
    Assert.AreEqual(RpcProtseq.ncacn_ip_tcp, client.Protocol);
VB.NET Copy Code
Using client As New RpcClientApi(Guid.NewGuid(), RpcProtseq.ncacn_ip_tcp, Nothing, "123")
    Assert.AreEqual(RpcProtseq.ncacn_ip_tcp, client.Protocol)
End Using

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.RpcLibrary.RpcProtseq

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.RpcLibrary Namespace
RpcProtseq RpcClientApi.Protocol
Boolean RpcServerApi.AddProtocol(RpcProtseq,String,Int32)


%%PageItemTitle%%

[image]
CSharpTest.Net
IRpcClientInfo Interface
Members See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : IRpcClientInfo Interface

Glossary Item Box

An interface that provide contextual information about the client within an Rpc server call

Syntax

Visual Basic (Declaration)
Public Interface IRpcClientInfo
C#
public interface IRpcClientInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Members
CSharpTest.Net.RpcLibrary Namespace
Byte[] RpcServerApi.Execute(IRpcClientInfo,Byte[])
Byte[] RpcServerApi.RpcExecuteHandler.Invoke(IRpcClientInfo,Byte[])
IAsyncResult RpcServerApi.RpcExecuteHandler.BeginInvoke(IRpcClientInfo,Byte[],AsyncCallback,Object)

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
IRpcClientInfo Interface Members
See Also Properties Methods Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : IRpcClientInfo Interface

Glossary Item Box

The following tables list the members exposed by IRpcClientInfo.

Public Properties

 | Name | Description
Property | AuthenticationLevel | Returns the authentication level of the connection
Property | ClientAddress | Returns a most random set of bytes, undocumented Win32 value.
Property | ClientPid | Returns the ProcessId of the LRPC caller, may not be valid on all platforms
Property | ClientPrincipalName | Returns the client user name if authenticated, not available on WinXP
Property | ClientUser | Returns the identity of the client user or Anonymous if unauthenticated
Property | IsAuthenticated | Returns true if the caller has authenticated as a user
Property | IsClientLocal | Returns true if the caller is using LRPC
Property | IsImpersonating | Returns true if already impersonating the caller
Property | ProtectionLevel | Returns the packet protection level of the communications
Property | ProtocolType | Defines the type of the procol being used in the communication, unavailable on Windows XP
Top

Public Methods

 | Name | Description
Method | Impersonate | Returns a disposable context that is used to impersonate the calling user
Top

See Also

Reference

IRpcClientInfo Interface
CSharpTest.Net.RpcLibrary Namespace
Byte[] RpcServerApi.Execute(IRpcClientInfo,Byte[])
Byte[] RpcServerApi.RpcExecuteHandler.Invoke(IRpcClientInfo,Byte[])
IAsyncResult RpcServerApi.RpcExecuteHandler.BeginInvoke(IRpcClientInfo,Byte[],AsyncCallback,Object)

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IRpcClientInfo Interface Methods
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : IRpcClientInfo Interface

Glossary Item Box

For a list of all members of this type, see IRpcClientInfo members.

Public Methods

 | Name | Description
Method | Impersonate | Returns a disposable context that is used to impersonate the calling user
Top

See Also

Reference

IRpcClientInfo Interface
CSharpTest.Net.RpcLibrary Namespace
Byte[] RpcServerApi.Execute(IRpcClientInfo,Byte[])
Byte[] RpcServerApi.RpcExecuteHandler.Invoke(IRpcClientInfo,Byte[])
IAsyncResult RpcServerApi.RpcExecuteHandler.BeginInvoke(IRpcClientInfo,Byte[],AsyncCallback,Object)

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Impersonate Method
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : Impersonate Method

Glossary Item Box

Returns a disposable context that is used to impersonate the calling user

Syntax

Visual Basic (Declaration)
Function Impersonate() As IDisposable
C#
IDisposable Impersonate()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IRpcClientInfo Interface Properties
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : IRpcClientInfo Interface

Glossary Item Box

For a list of all members of this type, see IRpcClientInfo members.

Public Properties

 | Name | Description
Property | AuthenticationLevel | Returns the authentication level of the connection
Property | ClientAddress | Returns a most random set of bytes, undocumented Win32 value.
Property | ClientPid | Returns the ProcessId of the LRPC caller, may not be valid on all platforms
Property | ClientPrincipalName | Returns the client user name if authenticated, not available on WinXP
Property | ClientUser | Returns the identity of the client user or Anonymous if unauthenticated
Property | IsAuthenticated | Returns true if the caller has authenticated as a user
Property | IsClientLocal | Returns true if the caller is using LRPC
Property | IsImpersonating | Returns true if already impersonating the caller
Property | ProtectionLevel | Returns the packet protection level of the communications
Property | ProtocolType | Defines the type of the procol being used in the communication, unavailable on Windows XP
Top

See Also

Reference

IRpcClientInfo Interface
CSharpTest.Net.RpcLibrary Namespace
Byte[] RpcServerApi.Execute(IRpcClientInfo,Byte[])
Byte[] RpcServerApi.RpcExecuteHandler.Invoke(IRpcClientInfo,Byte[])
IAsyncResult RpcServerApi.RpcExecuteHandler.BeginInvoke(IRpcClientInfo,Byte[],AsyncCallback,Object)

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AuthenticationLevel Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : AuthenticationLevel Property

Glossary Item Box

Returns the authentication level of the connection

Syntax

Visual Basic (Declaration)
ReadOnly Property AuthenticationLevel As RpcAuthentication
C#
RpcAuthentication AuthenticationLevel {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members
RpcAuthentication

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClientAddress Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : ClientAddress Property

Glossary Item Box

Returns a most random set of bytes, undocumented Win32 value.

Syntax

Visual Basic (Declaration)
ReadOnly Property ClientAddress As Byte()
C#
byte[] ClientAddress {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClientPid Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : ClientPid Property

Glossary Item Box

Returns the ProcessId of the LRPC caller, may not be valid on all platforms

Syntax

Visual Basic (Declaration)
ReadOnly Property ClientPid As IntPtr
C#
IntPtr ClientPid {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClientPrincipalName Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : ClientPrincipalName Property

Glossary Item Box

Returns the client user name if authenticated, not available on WinXP

Syntax

Visual Basic (Declaration)
ReadOnly Property ClientPrincipalName As String
C#
string ClientPrincipalName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClientUser Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : ClientUser Property

Glossary Item Box

Returns the identity of the client user or Anonymous if unauthenticated

Syntax

Visual Basic (Declaration)
ReadOnly Property ClientUser As WindowsIdentity
C#
WindowsIdentity ClientUser {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsAuthenticated Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : IsAuthenticated Property

Glossary Item Box

Returns true if the caller has authenticated as a user

Syntax

Visual Basic (Declaration)
ReadOnly Property IsAuthenticated As Boolean
C#
bool IsAuthenticated {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsClientLocal Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : IsClientLocal Property

Glossary Item Box

Returns true if the caller is using LRPC

Syntax

Visual Basic (Declaration)
ReadOnly Property IsClientLocal As Boolean
C#
bool IsClientLocal {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsImpersonating Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : IsImpersonating Property

Glossary Item Box

Returns true if already impersonating the caller

Syntax

Visual Basic (Declaration)
ReadOnly Property IsImpersonating As Boolean
C#
bool IsImpersonating {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProtectionLevel Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : ProtectionLevel Property

Glossary Item Box

Returns the packet protection level of the communications

Syntax

Visual Basic (Declaration)
ReadOnly Property ProtectionLevel As RpcProtectionLevel
C#
RpcProtectionLevel ProtectionLevel {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members
RpcProtectionLevel

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ProtocolType Property
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace > IRpcClientInfo Interface : ProtocolType Property

Glossary Item Box

Defines the type of the procol being used in the communication, unavailable on Windows XP

Syntax

Visual Basic (Declaration)
ReadOnly Property ProtocolType As RpcProtoseqType
C#
RpcProtoseqType ProtocolType {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

IRpcClientInfo Interface
IRpcClientInfo Members
RpcProtoseqType

Source Code

RpcLibrary/IRpcClientInfo.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RpcServerApi.RpcExecuteHandler Delegate
See Also Example Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly > CSharpTest.Net.RpcLibrary Namespace : RpcServerApi.RpcExecuteHandler Delegate

client
input

Glossary Item Box

The delegate format for the OnExecute event

Syntax

Visual Basic (Declaration)
Public Delegate Function RpcServerApi.RpcExecuteHandler( _
   ByVal client As IRpcClientInfo, _
   ByVal input() As Byte _
) As Byte()
C#
public delegate byte[] RpcServerApi.RpcExecuteHandler(
   IRpcClientInfo client,
   byte[] input
)

Parameters

client
input

Example

RpcLibrary/RpcLibrary.Test/TestServerApi.cs

C# Copy Code
Guid iid = Guid.NewGuid();
using (RpcServerApi server = new RpcServerApi(iid))
{
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5);
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT);
    server.StartListening();
    RpcServerApi.RpcExecuteHandler handler =
        delegate(IRpcClientInfo client, byte[] arg)
        { return arg; };

    using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest"))
    {
        client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT);

        server.OnExecute += handler;
        client.Execute(new byte[0]);

        server.OnExecute -= handler;
        try
        {
            client.Execute(new byte[0]);
            Assert.Fail();
        }
        catch (RpcException)
        { }
    }
}
VB.NET Copy Code
Dim iid As Guid = Guid.NewGuid()
Using server As New RpcServerApi(iid)
    server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5)
    server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT)
    server.StartListening()
    Dim handler As RpcServerApi.RpcExecuteHandler = Function(client As IRpcClientInfo, arg As Byte()) Do
        Return arg
    End Function

    Using client As New RpcClientApi(iid, RpcProtseq.ncalrpc, Nothing, "lrpctest")
        client.AuthenticateAs(Nothing, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT)

        server.OnExecute += handler
        client.Execute(New Byte(0) {})

        server.OnExecute -= handler
        Try
            client.Execute(New Byte(0) {})
            Assert.Fail()
        Catch generatedExceptionName As RpcException
        End Try
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

RpcServerApi.RpcExecuteHandler Members
CSharpTest.Net.RpcLibrary Namespace

Source Code

RpcLibrary/RpcServerApi.cs


%%phrase%%

SslTunnel.Library Assembly
See Also Send Feedback Download Help File

Glossary Item Box

Namespaces

Namespace | Description
CSharpTest.Net.SslTunnel |


%%ItemTitle%%

CSharpTest.Net.SslTunnel Namespace
See Also Inheritance Hierarchy Send Feedback Download Help File
SslTunnel.Library Assembly : CSharpTest.Net.SslTunnel Namespace

Glossary Item Box

Classes

 | Class | Description
Class | AddPort |
Class | ExpectedCertificate |
Class | SslCertValidator | Provides a validator for an endpoint's SSL certificate
Class | SslClient | Creates a TcpClient that uses SSL
Class | SslServer | TcpServer implementation that uses SSL
Class | StreamRedirect | Used to forward data from one stream to another as soon as it's available.
Class | TcpClient | Wraps the System.Net.Sockets.TcpClient
Class | TcpForwardingBase | An abstract class for handling the connection of clients and establishing a forwarding route to another tcp connection.
Class | TcpRedirector | A simple class that implements the abstract forwarding object to forward to a single destination endpoint
Class | TcpServer | A wrapper around the TcpListener
Class | TcpServer.ConnectedEventArgs | The event argument used to handling inbound connections
Class | TcpSettings | Some basic global timeout setting that can be modified.
Class | TunnelConfig |
Class | TunnelDemultiplexer | A one-to-many port forwarding protocol that receives requests from a multiplexer and dispatches the the data stream to the services selected by the originating port.
Class | TunnelListener | A simple one-to-one port forwarding protocol
Class | TunnelListenerBase | A common base class for the server listener types, listener, mux, and demux
Class | TunnelMultiplexer | A many-to-one port forwarding protocol that embeds the originating port into the communication so that the demultiplexer on the other end can forward to the appropriate ip and port
Class | TunnelSender | A service endpoint to connect to, setting UseSsl=true or provide either a client certificate or an expected server certificate to ensure the connection is secured with ssl.
Class | TunnelSenderFromPort |

Delegates

 | Delegate | Description
Delegate | StreamRedirect.BinaryLogWrite | An event to monitor the bytes being sent between client/server

Enumerations

 | Enumeration | Description
Enumeration | IgnorePolicyErrors |

See Also

Reference

SslTunnel.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
AddPort Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : AddPort Class

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Class AddPort
C#
public class AddPort

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.AddPort

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AddPort Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
AddPort Class Members
See Also Fields Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : AddPort Class

Glossary Item Box

The following tables list the members exposed by AddPort.

Public Constructors

 | Name | Description
Public Constructor | AddPort Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | Port |
Top

See Also

Reference

AddPort Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddPort Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > AddPort Class : AddPort Constructor

Glossary Item Box

Overload List

Overload | Description
AddPort Constructor() |
AddPort Constructor(Int32) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AddPort Class
AddPort Members


%%PageItemTitle%%

[image]
CSharpTest.Net
AddPort Constructor()
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > AddPort Class > AddPort Constructor : AddPort Constructor()

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public AddPort()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AddPort Class
AddPort Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddPort Constructor(Int32)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > AddPort Class > AddPort Constructor : AddPort Constructor(Int32)

port

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal port As Integer _
)
C#
public AddPort(
   int port
)

Parameters

port

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AddPort Class
AddPort Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
AddPort Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : AddPort Class

Glossary Item Box

For a list of all members of this type, see AddPort members.

Public Fields

 | Name | Description
Public Field | Port |
Top

See Also

Reference

AddPort Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Port Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > AddPort Class : Port Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Port As Integer
C#
public int Port

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<multiplexer ip="127.0.0.1">
Assert.AreEqual(typeof(TunnelMultiplexer), config.Listeners[0].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).IpEndpoint);
//  <accept ?
Assert.IsNull(((TunnelMultiplexer)config.Listeners[0]).AllowedClients);
//  <add port="10080"/>
Assert.AreEqual(10080, ((TunnelMultiplexer)config.Listeners[0]).Ports[0].Port);
//  <add port="10081"/>
Assert.AreEqual(10081, ((TunnelMultiplexer)config.Listeners[0]).Ports[1].Port);
//  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).Target.IpEndpoint);
Assert.AreEqual(10443, ((TunnelMultiplexer)config.Listeners[0]).Target.Port);
Assert.AreEqual("client.localhost.nunit.cer", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertificate);
Assert.AreEqual("password", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertPassword);
//    <!--expect publicKey = server.localhost.nunit.cer-->
//    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001",
    ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.PublicKey);
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.IgnoredErrors);
//  </target>
//</multiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<multiplexer ip="127.0.0.1">
Assert.AreEqual(GetType(TunnelMultiplexer), config.Listeners(0).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).IpEndpoint)
'  <accept ?
Assert.IsNull((DirectCast(config.Listeners(0), TunnelMultiplexer)).AllowedClients)
'  <add port="10080"/>
Assert.AreEqual(10080, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(0).Port)
'  <add port="10081"/>
Assert.AreEqual(10081, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(1).Port)
'  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.Port)
Assert.AreEqual("client.localhost.nunit.cer", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertPassword)
'    <!--expect publicKey = server.localhost.nunit.cer-->
'    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.PublicKey)
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.IgnoredErrors)
'  </target>
'</multiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

AddPort Class
AddPort Members

Used By

TestSampleConfig.TestConfigMultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
ExpectedCertificate Class
Members Example See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : ExpectedCertificate Class

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Class ExpectedCertificate
C#
public class ExpectedCertificate

Example

SslTunnel/Test/TestCertValidator.cs

C# Copy Code
ExpectedCertificate allowed = new ExpectedCertificate();
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString();
allowed.IgnoredErrors = IgnorePolicyErrors.All;
SslCertValidator validator = new SslCertValidator(allowed);

Assert.IsTrue(validator.CertRequired);
Assert.IsFalse(validator.IsValid(null, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors));
VB.NET Copy Code
Dim allowed As New ExpectedCertificate()
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString()
allowed.IgnoredErrors = IgnorePolicyErrors.All
Dim validator As New SslCertValidator(allowed)

Assert.IsTrue(validator.CertRequired)
Assert.IsFalse(validator.IsValid(Nothing, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors))

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.ExpectedCertificate

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExpectedCertificate Members
CSharpTest.Net.SslTunnel Namespace

Used By

TestCertValidator.TestAllowAnyValidCert()
TestCertValidator.TestAllowAnyTrustedCert()
TestCertValidator.TestValidUnexpectedCert()
TestCertValidator.TestValidAndExpectedCert()
TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestAllowByHash()
TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByIssuer()
TestCertValidator.TestDenyByHash()
TestCertValidator.TestDenyByPublicKey()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
ExpectedCertificate Class Members
See Also Fields Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : ExpectedCertificate Class

Glossary Item Box

The following tables list the members exposed by ExpectedCertificate.

Public Constructors

 | Name | Description
Public Constructor | ExpectedCertificate Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | Hash |
Public Field | IgnoredErrors |
Public Field | IssuedTo |
Public Field | PublicKey |
Top

See Also

Reference

ExpectedCertificate Class
CSharpTest.Net.SslTunnel Namespace

Used By

TestCertValidator.TestAllowAnyValidCert()
TestCertValidator.TestAllowAnyTrustedCert()
TestCertValidator.TestValidUnexpectedCert()
TestCertValidator.TestValidAndExpectedCert()
TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestAllowByHash()
TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByIssuer()
TestCertValidator.TestDenyByHash()
TestCertValidator.TestDenyByPublicKey()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExpectedCertificate Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > ExpectedCertificate Class : ExpectedCertificate Constructor

Glossary Item Box

Overload List

Overload | Description
ExpectedCertificate Constructor() |
ExpectedCertificate Constructor(String,IgnorePolicyErrors) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExpectedCertificate Class
ExpectedCertificate Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ExpectedCertificate Constructor()
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > ExpectedCertificate Class > ExpectedCertificate Constructor : ExpectedCertificate Constructor()

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public ExpectedCertificate()

Example

SslTunnel/Test/TestCertValidator.cs

C# Copy Code
ExpectedCertificate allowed = new ExpectedCertificate();
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString();
allowed.IgnoredErrors = IgnorePolicyErrors.All;
SslCertValidator validator = new SslCertValidator(allowed);

Assert.IsTrue(validator.CertRequired);
Assert.IsFalse(validator.IsValid(null, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors));
VB.NET Copy Code
Dim allowed As New ExpectedCertificate()
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString()
allowed.IgnoredErrors = IgnorePolicyErrors.All
Dim validator As New SslCertValidator(allowed)

Assert.IsTrue(validator.CertRequired)
Assert.IsFalse(validator.IsValid(Nothing, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExpectedCertificate Class
ExpectedCertificate Members
Overload List

Used By

TestCertValidator.TestAllowAnyTrustedCert()
TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestAllowByHash()
TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByIssuer()
TestCertValidator.TestDenyByHash()
TestCertValidator.TestDenyByPublicKey()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ExpectedCertificate Constructor(String,IgnorePolicyErrors)
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > ExpectedCertificate Class > ExpectedCertificate Constructor : ExpectedCertificate Constructor(String,IgnorePolicyErrors)

publicKey
ignore

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal publicKey As String, _
   ByVal ignore As IgnorePolicyErrors _
)
C#
public ExpectedCertificate(
   string publicKey,
   IgnorePolicyErrors ignore
)

Parameters

publicKey
ignore

Example

SslTunnel/Test/TestCertValidator.cs

C# Copy Code
ExpectedCertificate allowed = new ExpectedCertificate(_clientCert.Certificate.GetPublicKeyString(), IgnorePolicyErrors.None);
SslCertValidator validator = new SslCertValidator(allowed);

Assert.IsTrue(validator.CertRequired);
Assert.IsTrue(validator.IsValid(null, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.None));
Assert.IsFalse(validator.IsValid(null, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors));
VB.NET Copy Code
Dim allowed As New ExpectedCertificate(_clientCert.Certificate.GetPublicKeyString(), IgnorePolicyErrors.None)
Dim validator As New SslCertValidator(allowed)

Assert.IsTrue(validator.CertRequired)
Assert.IsTrue(validator.IsValid(Nothing, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.None))
Assert.IsFalse(validator.IsValid(Nothing, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExpectedCertificate Class
ExpectedCertificate Members
Overload List

Used By

TestCertValidator.TestValidUnexpectedCert()
TestCertValidator.TestValidAndExpectedCert()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
ExpectedCertificate Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : ExpectedCertificate Class

Glossary Item Box

For a list of all members of this type, see ExpectedCertificate members.

Public Fields

 | Name | Description
Public Field | Hash |
Public Field | IgnoredErrors |
Public Field | IssuedTo |
Public Field | PublicKey |
Top

See Also

Reference

ExpectedCertificate Class
CSharpTest.Net.SslTunnel Namespace

Used By

TestCertValidator.TestAllowAnyValidCert()
TestCertValidator.TestAllowAnyTrustedCert()
TestCertValidator.TestValidUnexpectedCert()
TestCertValidator.TestValidAndExpectedCert()
TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestAllowByHash()
TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByIssuer()
TestCertValidator.TestDenyByHash()
TestCertValidator.TestDenyByPublicKey()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Hash Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > ExpectedCertificate Class : Hash Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Hash As String
C#
public string Hash

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExpectedCertificate Class
ExpectedCertificate Members

Used By

TestCertValidator.TestAllowByHash()
TestCertValidator.TestDenyByHash()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnoredErrors Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > ExpectedCertificate Class : IgnoredErrors Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public IgnoredErrors As IgnorePolicyErrors
C#
public IgnorePolicyErrors IgnoredErrors

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExpectedCertificate Class
ExpectedCertificate Members

Used By

TestCertValidator.TestAllowAnyTrustedCert()
TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestAllowByHash()
TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByIssuer()
TestCertValidator.TestDenyByHash()
TestCertValidator.TestDenyByPublicKey()
TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
IssuedTo Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > ExpectedCertificate Class : IssuedTo Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public IssuedTo As String
C#
public string IssuedTo

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExpectedCertificate Class
ExpectedCertificate Members

Used By

TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestDenyByIssuer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
PublicKey Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > ExpectedCertificate Class : PublicKey Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public PublicKey As String
C#
public string PublicKey

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ExpectedCertificate Class
ExpectedCertificate Members

Used By

TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByPublicKey()
TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
SslCertValidator Class
Members Example See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslCertValidator Class

Glossary Item Box

Provides a validator for an endpoint's SSL certificate

Syntax

Visual Basic (Declaration)
Public Class SslCertValidator
C#
public class SslCertValidator

Example

SslTunnel/Test/TestCertValidator.cs

C# Copy Code
ExpectedCertificate allowed = new ExpectedCertificate();
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString();
allowed.IgnoredErrors = IgnorePolicyErrors.All;
SslCertValidator validator = new SslCertValidator(allowed);

Assert.IsTrue(validator.CertRequired);
Assert.IsFalse(validator.IsValid(null, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors));
VB.NET Copy Code
Dim allowed As New ExpectedCertificate()
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString()
allowed.IgnoredErrors = IgnorePolicyErrors.All
Dim validator As New SslCertValidator(allowed)

Assert.IsTrue(validator.CertRequired)
Assert.IsFalse(validator.IsValid(Nothing, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors))

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.SslCertValidator

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslCertValidator Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SslCertValidator Class Members
See Also Properties Methods Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslCertValidator Class

Glossary Item Box

The following tables list the members exposed by SslCertValidator.

Public Constructors

 | Name | Description
Public Constructor | SslCertValidator Constructor | Constructs a validator for an endpoint's SSL certificate
Top

Public Properties

 | Name | Description
Public Property | CertRequired | Returns true if a certificate is required.
Top

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DebugDumpCertificate | Overloaded. Logs a certificate's properties to the Trace window
Public Method | IsValid | Returns true if the endpoint's certificate is valid
Top

See Also

Reference

SslCertValidator Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SslCertValidator Constructor
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslCertValidator Class : SslCertValidator Constructor

allow

Glossary Item Box

Constructs a validator for an endpoint's SSL certificate

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray allow() As ExpectedCertificate _
)
C#
public SslCertValidator(
   params ExpectedCertificate[] allow
)

Parameters

allow

Example

SslTunnel/Test/TestCertValidator.cs

C# Copy Code
ExpectedCertificate allowed = new ExpectedCertificate();
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString();
allowed.IgnoredErrors = IgnorePolicyErrors.All;
SslCertValidator validator = new SslCertValidator(allowed);

Assert.IsTrue(validator.CertRequired);
Assert.IsFalse(validator.IsValid(null, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors));
VB.NET Copy Code
Dim allowed As New ExpectedCertificate()
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString()
allowed.IgnoredErrors = IgnorePolicyErrors.All
Dim validator As New SslCertValidator(allowed)

Assert.IsTrue(validator.CertRequired)
Assert.IsFalse(validator.IsValid(Nothing, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslCertValidator Class
SslCertValidator Members

Used By

TestCertValidator.TestAllowAnyValidCert()
TestCertValidator.TestAllowAnyTrustedCert()
TestCertValidator.TestValidUnexpectedCert()
TestCertValidator.TestValidAndExpectedCert()
TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestAllowByHash()
TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByIssuer()
TestCertValidator.TestDenyByHash()
TestCertValidator.TestDenyByPublicKey()

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SslCertValidator Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslCertValidator Class

Glossary Item Box

For a list of all members of this type, see SslCertValidator members.

Public Methods

 | Name | Description
static (Shared in Visual Basic) | DebugDumpCertificate | Overloaded. Logs a certificate's properties to the Trace window
Public Method | IsValid | Returns true if the endpoint's certificate is valid
Top

See Also

Reference

SslCertValidator Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugDumpCertificate Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslCertValidator Class : DebugDumpCertificate Method

Glossary Item Box

Logs a certificate's properties to the Trace window

Overload List

Overload | Description
DebugDumpCertificate(X509Certificate) | Logs a certificate's properties to the Trace window
DebugDumpCertificate(X509Certificate,TextWriter) | Logs a certificate's properties to the give text writer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslCertValidator Class
SslCertValidator Members


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugDumpCertificate(X509Certificate) Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslCertValidator Class > DebugDumpCertificate Method : DebugDumpCertificate(X509Certificate) Method

certificate

Glossary Item Box

Logs a certificate's properties to the Trace window

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub DebugDumpCertificate( _
   ByVal certificate As X509Certificate _
)
C#
public static void DebugDumpCertificate(
   X509Certificate certificate
)

Parameters

certificate

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslCertValidator Class
SslCertValidator Members
Overload List

Used By

Boolean SslCertValidator.IsValid(Object,X509Certificate,X509Chain,SslPolicyErrors)

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
DebugDumpCertificate(X509Certificate,TextWriter) Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslCertValidator Class > DebugDumpCertificate Method : DebugDumpCertificate(X509Certificate,TextWriter) Method

certificate
sw

Glossary Item Box

Logs a certificate's properties to the give text writer

Syntax

Visual Basic (Declaration)
Public Overloads Shared Sub DebugDumpCertificate( _
   ByVal certificate As X509Certificate, _
   ByVal sw As TextWriter _
)
C#
public static void DebugDumpCertificate(
   X509Certificate certificate,
   TextWriter sw
)

Parameters

certificate
sw

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslCertValidator Class
SslCertValidator Members
Overload List

Used By

SslCertValidator.DebugDumpCertificate(X509Certificate)

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IsValid Method
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslCertValidator Class : IsValid Method

sender
certificate
chain
sslPolicyErrors

Glossary Item Box

Returns true if the endpoint's certificate is valid

Syntax

Visual Basic (Declaration)
Public Function IsValid( _
   ByVal sender As Object, _
   ByVal certificate As X509Certificate, _
   ByVal chain As X509Chain, _
   ByVal sslPolicyErrors As SslPolicyErrors _
) As Boolean
C#
public bool IsValid(
   object sender,
   X509Certificate certificate,
   X509Chain chain,
   SslPolicyErrors sslPolicyErrors
)

Parameters

sender
certificate
chain
sslPolicyErrors

Example

SslTunnel/Test/TestCertValidator.cs

C# Copy Code
ExpectedCertificate allowed = new ExpectedCertificate();
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString();
allowed.IgnoredErrors = IgnorePolicyErrors.All;
SslCertValidator validator = new SslCertValidator(allowed);

Assert.IsTrue(validator.CertRequired);
Assert.IsFalse(validator.IsValid(null, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors));
VB.NET Copy Code
Dim allowed As New ExpectedCertificate()
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString()
allowed.IgnoredErrors = IgnorePolicyErrors.All
Dim validator As New SslCertValidator(allowed)

Assert.IsTrue(validator.CertRequired)
Assert.IsFalse(validator.IsValid(Nothing, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslCertValidator Class
SslCertValidator Members

Used By

TestCertValidator.TestAllowAnyValidCert()
TestCertValidator.TestAllowAnyTrustedCert()
TestCertValidator.TestValidUnexpectedCert()
TestCertValidator.TestValidAndExpectedCert()
TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestAllowByHash()
TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByIssuer()
TestCertValidator.TestDenyByHash()
TestCertValidator.TestDenyByPublicKey()

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SslCertValidator Class Properties
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslCertValidator Class

Glossary Item Box

For a list of all members of this type, see SslCertValidator members.

Public Properties

 | Name | Description
Public Property | CertRequired | Returns true if a certificate is required.
Top

See Also

Reference

SslCertValidator Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
CertRequired Property
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslCertValidator Class : CertRequired Property

Glossary Item Box

Returns true if a certificate is required.

Syntax

Visual Basic (Declaration)
Public ReadOnly Property CertRequired As Boolean
C#
public bool CertRequired {get;}

Example

SslTunnel/Test/TestCertValidator.cs

C# Copy Code
ExpectedCertificate allowed = new ExpectedCertificate();
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString();
allowed.IgnoredErrors = IgnorePolicyErrors.All;
SslCertValidator validator = new SslCertValidator(allowed);

Assert.IsTrue(validator.CertRequired);
Assert.IsFalse(validator.IsValid(null, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors));
VB.NET Copy Code
Dim allowed As New ExpectedCertificate()
allowed.PublicKey = _serverCert.Certificate.GetPublicKeyString()
allowed.IgnoredErrors = IgnorePolicyErrors.All
Dim validator As New SslCertValidator(allowed)

Assert.IsTrue(validator.CertRequired)
Assert.IsFalse(validator.IsValid(Nothing, _clientCert.Certificate, EmptyX509Chain, SslPolicyErrors.RemoteCertificateChainErrors))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslCertValidator Class
SslCertValidator Members

Used By

TestCertValidator.TestAllowAnyValidCert()
TestCertValidator.TestAllowAnyTrustedCert()
TestCertValidator.TestValidUnexpectedCert()
TestCertValidator.TestValidAndExpectedCert()
TestCertValidator.TestAllowByIssuer()
TestCertValidator.TestAllowByHash()
TestCertValidator.TestAllowByPublicKey()
TestCertValidator.TestDenyByIssuer()
TestCertValidator.TestDenyByHash()
TestCertValidator.TestDenyByPublicKey()

Source Code

SslTunnel/Library/SslCertValidator.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SslClient Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslClient Class

Glossary Item Box

Creates a TcpClient that uses SSL

Syntax

Visual Basic (Declaration)
Public Class SslClient
   Inherits TcpClient
C#
public class SslClient : TcpClient

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TcpClient
CSharpTest.Net.SslTunnel.SslClient

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslClient Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslClient.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SslClient Class Members
See Also Properties Methods Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslClient Class

Glossary Item Box

The following tables list the members exposed by SslClient.

Public Constructors

 | Name | Description
Public Constructor | SslClient Constructor | Creates the client with the specified client certificiate and the expected server information
Top

Public Properties

 | Name | Description
Public Property | Client | Returns the underlying client soket after a call to Connect() (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Public Property | ServerName | Returns the server name that this client connects to (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Public Property | ServerPort | Returns the port that this client connects to (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Public Property | Stream | Returns the network stream after a call to Connect() (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Top

Public Methods

 | Name | Description
Public Method | Clone | Overridden. Clones the client connection
Public Method | Connect | Estabilishes the connection with the server (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Public Method | Dispose | Disposes of the client connection. (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Top

Protected Methods

 | Name | Description
Protected Method | ConnectServer | Overridden. Establishes the client SSL connection
Top

See Also

Reference

SslClient Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SslClient Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslClient Class : SslClient Constructor

serverName
bindingPort
certificate
expectedCert

Glossary Item Box

Creates the client with the specified client certificiate and the expected server information

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal serverName As String, _
   ByVal bindingPort As Integer, _
   ByVal certificate As X509Certificate, _
   ByVal expectedCert As ExpectedCertificate _
)
C#
public SslClient(
   string serverName,
   int bindingPort,
   X509Certificate certificate,
   ExpectedCertificate expectedCert
)

Parameters

serverName
bindingPort
certificate
expectedCert

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslClient Class
SslClient Members

Source Code

SslTunnel/Library/SslClient.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SslClient Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslClient Class

Glossary Item Box

For a list of all members of this type, see SslClient members.

Public Methods

 | Name | Description
Public Method | Clone | Overridden. Clones the client connection
Public Method | Connect | Estabilishes the connection with the server (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Public Method | Dispose | Disposes of the client connection. (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Top

Protected Methods

 | Name | Description
Protected Method | ConnectServer | Overridden. Establishes the client SSL connection
Top

See Also

Reference

SslClient Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslClient Class : Clone Method

Glossary Item Box

Clones the client connection

Syntax

Visual Basic (Declaration)
Public Overrides Function Clone() As TcpClient
C#
public override TcpClient Clone()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslClient Class
SslClient Members
Base Implementation in Clone
TcpClient

Source Code

SslTunnel/Library/SslClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ConnectServer Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslClient Class : ConnectServer Method

client

Glossary Item Box

Establishes the client SSL connection

Syntax

Visual Basic (Declaration)
Protected Overrides Function ConnectServer( _
   ByVal client As TcpClient _
) As Stream
C#
protected override Stream ConnectServer(
   TcpClient client
)

Parameters

client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslClient Class
SslClient Members
Base Implementation in ConnectServer


%%PageItemTitle%%

[image]
CSharpTest.Net
SslServer Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslServer Class

Glossary Item Box

TcpServer implementation that uses SSL

Syntax

Visual Basic (Declaration)
Public Class SslServer
   Inherits TcpServer
C#
public class SslServer : TcpServer

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TcpServer
CSharpTest.Net.SslTunnel.SslServer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslServer Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
SslServer Class Members
See Also Methods Events Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslServer Class

Glossary Item Box

The following tables list the members exposed by SslServer.

Public Constructors

 | Name | Description
Public Constructor | SslServer Constructor | Constructs the server with the specified certificate and optionally allowable client certificates
Top

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of the server, stops listening if needed. (Inherited from CSharpTest.Net.SslTunnel.TcpServer)
Public Method | Start | Starts listening for requests (Inherited from CSharpTest.Net.SslTunnel.TcpServer)
Public Method | Stop | Stops listening for requests (Inherited from CSharpTest.Net.SslTunnel.TcpServer)
Top

Protected Methods

 | Name | Description
Protected Method | ConnectClient | Overridden. Establishes the SSL connection for this client.
Top

Public Events

 | Name | Description
Public Event | Connected | Raised when a client establishes a connection. (Inherited from CSharpTest.Net.SslTunnel.TcpServer)
Top

See Also

Reference

SslServer Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SslServer Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslServer Class : SslServer Constructor

bindingName
bindingPort
certificate
allowClients

Glossary Item Box

Constructs the server with the specified certificate and optionally allowable client certificates

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bindingName As String, _
   ByVal bindingPort As Integer, _
   ByVal certificate As X509Certificate, _
   ByVal allowClients() As ExpectedCertificate _
)
C#
public SslServer(
   string bindingName,
   int bindingPort,
   X509Certificate certificate,
   ExpectedCertificate[] allowClients
)

Parameters

bindingName
bindingPort
certificate
allowClients

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslServer Class
SslServer Members

Source Code

SslTunnel/Library/SslServer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
SslServer Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslServer Class

Glossary Item Box

For a list of all members of this type, see SslServer members.

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of the server, stops listening if needed. (Inherited from CSharpTest.Net.SslTunnel.TcpServer)
Public Method | Start | Starts listening for requests (Inherited from CSharpTest.Net.SslTunnel.TcpServer)
Public Method | Stop | Stops listening for requests (Inherited from CSharpTest.Net.SslTunnel.TcpServer)
Top

Protected Methods

 | Name | Description
Protected Method | ConnectClient | Overridden. Establishes the SSL connection for this client.
Top

See Also

Reference

SslServer Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ConnectClient Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslServer Class : ConnectClient Method

client

Glossary Item Box

Establishes the SSL connection for this client.

Syntax

Visual Basic (Declaration)
Protected Overrides Function ConnectClient( _
   ByVal client As TcpClient _
) As Stream
C#
protected override Stream ConnectClient(
   TcpClient client
)

Parameters

client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslServer Class
SslServer Members
Base Implementation in ConnectClient


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamRedirect Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : StreamRedirect Class

Glossary Item Box

Used to forward data from one stream to another as soon as it's available.

Syntax

Visual Basic (Declaration)
Public Class StreamRedirect
C#
public class StreamRedirect

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.StreamRedirect

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamRedirect Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/StreamRedirect.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
StreamRedirect Class Members
See Also Properties Methods Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : StreamRedirect Class

Glossary Item Box

The following tables list the members exposed by StreamRedirect.

Public Constructors

 | Name | Description
Public Constructor | StreamRedirect Constructor | Overloaded.
Top

Public Properties

 | Name | Description
Public Property | WaitClosed | Returns a WaitHandle that will be signaled when the connection is closed
Top

Public Methods

 | Name | Description
Public Method | Close | Forces the connection to close
Top

See Also

Reference

StreamRedirect Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/StreamRedirect.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamRedirect Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > StreamRedirect Class : StreamRedirect Constructor

Glossary Item Box

Overload List

Overload | Description
StreamRedirect Constructor(Stream,Stream,String) | Creates a redirector between the two streams
StreamRedirect Constructor(Stream,Stream,String,BinaryLogWrite) | Creates a redirector between the two streams

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamRedirect Class
StreamRedirect Members


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamRedirect Constructor(Stream,Stream,String)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > StreamRedirect Class > StreamRedirect Constructor : StreamRedirect Constructor(Stream,Stream,String)

from
to
connInfo

Glossary Item Box

Creates a redirector between the two streams

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal from As Stream, _
   ByVal to As Stream, _
   ByVal connInfo As String _
)
C#
public StreamRedirect(
   Stream from,
   Stream to,
   string connInfo
)

Parameters

from
to
connInfo

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamRedirect Class
StreamRedirect Members
Overload List

Source Code

SslTunnel/Library/StreamRedirect.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamRedirect Constructor(Stream,Stream,String,BinaryLogWrite)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > StreamRedirect Class > StreamRedirect Constructor : StreamRedirect Constructor(Stream,Stream,String,BinaryLogWrite)

from
to
connInfo
logger

Glossary Item Box

Creates a redirector between the two streams

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal from As Stream, _
   ByVal to As Stream, _
   ByVal connInfo As String, _
   ByVal logger As StreamRedirect.BinaryLogWrite _
)
C#
public StreamRedirect(
   Stream from,
   Stream to,
   string connInfo,
   StreamRedirect.BinaryLogWrite logger
)

Parameters

from
to
connInfo
logger

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamRedirect Class
StreamRedirect Members
Overload List

Source Code

SslTunnel/Library/StreamRedirect.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
StreamRedirect Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : StreamRedirect Class

Glossary Item Box

For a list of all members of this type, see StreamRedirect members.

Public Methods

 | Name | Description
Public Method | Close | Forces the connection to close
Top

See Also

Reference

StreamRedirect Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/StreamRedirect.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > StreamRedirect Class : Close Method

Glossary Item Box

Forces the connection to close

Syntax

Visual Basic (Declaration)
Public Sub Close()
C#
public void Close()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamRedirect Class
StreamRedirect Members

Source Code

SslTunnel/Library/StreamRedirect.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
StreamRedirect Class Properties
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : StreamRedirect Class

Glossary Item Box

For a list of all members of this type, see StreamRedirect members.

Public Properties

 | Name | Description
Public Property | WaitClosed | Returns a WaitHandle that will be signaled when the connection is closed
Top

See Also

Reference

StreamRedirect Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/StreamRedirect.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WaitClosed Property
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > StreamRedirect Class : WaitClosed Property

Glossary Item Box

Returns a WaitHandle that will be signaled when the connection is closed

Syntax

Visual Basic (Declaration)
Public ReadOnly Property WaitClosed As WaitHandle
C#
public WaitHandle WaitClosed {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamRedirect Class
StreamRedirect Members

Source Code

SslTunnel/Library/StreamRedirect.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpClient Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpClient Class

Glossary Item Box

Wraps the System.Net.Sockets.TcpClient

Syntax

Visual Basic (Declaration)
Public Class TcpClient
C#
public class TcpClient

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TcpClient
CSharpTest.Net.SslTunnel.SslClient

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Members
CSharpTest.Net.SslTunnel Namespace
TcpClient SslClient.Clone()

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TcpClient Class Members
See Also Properties Methods Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpClient Class

Glossary Item Box

The following tables list the members exposed by TcpClient.

Public Constructors

 | Name | Description
Public Constructor | TcpClient Constructor | Creates a tcp client to the given server name/ip and port
Top

Public Properties

 | Name | Description
Public Property | Client | Returns the underlying client soket after a call to Connect()
Public Property | ServerName | Returns the server name that this client connects to
Public Property | ServerPort | Returns the port that this client connects to
Public Property | Stream | Returns the network stream after a call to Connect()
Top

Public Methods

 | Name | Description
Public Method | Clone | Creates a new client connection to the same server endpoint
Public Method | Connect | Estabilishes the connection with the server
Public Method | Dispose | Disposes of the client connection.
Top

Protected Methods

 | Name | Description
Protected Method | ConnectServer | Allows customization of the connection handshake (SSL)
Top

See Also

Reference

TcpClient Class
CSharpTest.Net.SslTunnel Namespace
TcpClient SslClient.Clone()

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpClient Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : TcpClient Constructor

serverName
bindingPort

Glossary Item Box

Creates a tcp client to the given server name/ip and port

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal serverName As String, _
   ByVal bindingPort As Integer _
)
C#
public TcpClient(
   string serverName,
   int bindingPort
)

Parameters

serverName
bindingPort

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Used By

TestClientServer.TestCommandRun()
TcpClient TcpClient.Clone()

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TcpClient Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpClient Class

Glossary Item Box

For a list of all members of this type, see TcpClient members.

Public Methods

 | Name | Description
Public Method | Clone | Creates a new client connection to the same server endpoint
Public Method | Connect | Estabilishes the connection with the server
Public Method | Dispose | Disposes of the client connection.
Top

Protected Methods

 | Name | Description
Protected Method | ConnectServer | Allows customization of the connection handshake (SSL)
Top

See Also

Reference

TcpClient Class
CSharpTest.Net.SslTunnel Namespace
TcpClient SslClient.Clone()

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Clone Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : Clone Method

Glossary Item Box

Creates a new client connection to the same server endpoint

Syntax

Visual Basic (Declaration)
Public Overridable Function Clone() As TcpClient
C#
public virtual TcpClient Clone()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Connect Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : Connect Method

Glossary Item Box

Estabilishes the connection with the server

Syntax

Visual Basic (Declaration)
Public Sub Connect()
C#
public void Connect()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Used By

TestClientServer.TestCommandRun()

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ConnectServer Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : ConnectServer Method

client

Glossary Item Box

Allows customization of the connection handshake (SSL)

Syntax

Visual Basic (Declaration)
Protected Overridable Function ConnectServer( _
   ByVal client As TcpClient _
) As Stream
C#
protected virtual Stream ConnectServer(
   TcpClient client
)

Parameters

client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Used By

TcpClient.Connect()


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : Dispose Method

Glossary Item Box

Disposes of the client connection.

Syntax

Visual Basic (Declaration)
Public Sub Dispose()
C#
public void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Source Code

SslTunnel/Library/TcpClient.cs

Used By

TcpRedirector.Dispose()


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TcpClient Class Properties
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpClient Class

Glossary Item Box

For a list of all members of this type, see TcpClient members.

Public Properties

 | Name | Description
Public Property | Client | Returns the underlying client soket after a call to Connect()
Public Property | ServerName | Returns the server name that this client connects to
Public Property | ServerPort | Returns the port that this client connects to
Public Property | Stream | Returns the network stream after a call to Connect()
Top

See Also

Reference

TcpClient Class
CSharpTest.Net.SslTunnel Namespace
TcpClient SslClient.Clone()

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Client Property
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : Client Property

Glossary Item Box

Returns the underlying client soket after a call to Connect()

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Client As Socket
C#
public Socket Client {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ServerName Property
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : ServerName Property

Glossary Item Box

Returns the server name that this client connects to

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ServerName As String
C#
public string ServerName {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Source Code

SslTunnel/Library/TcpClient.cs

Used By

TcpClient SslClient.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
ServerPort Property
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : ServerPort Property

Glossary Item Box

Returns the port that this client connects to

Syntax

Visual Basic (Declaration)
Public ReadOnly Property ServerPort As Integer
C#
public int ServerPort {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Source Code

SslTunnel/Library/TcpClient.cs

Used By

TcpClient SslClient.Clone()


%%PageItemTitle%%

[image]
CSharpTest.Net
Stream Property
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpClient Class : Stream Property

Glossary Item Box

Returns the network stream after a call to Connect()

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Stream As Stream
C#
public Stream Stream {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpClient Class
TcpClient Members

Used By

TestClientServer.TestCommandRun()

Source Code

SslTunnel/Library/TcpClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpForwardingBase Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpForwardingBase Class

Glossary Item Box

An abstract class for handling the connection of clients and establishing a forwarding route to another tcp connection.

Syntax

Visual Basic (Declaration)
Public MustInherit Class TcpForwardingBase
C#
public abstract class TcpForwardingBase

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TcpForwardingBase
CSharpTest.Net.SslTunnel.TcpRedirector

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpForwardingBase.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TcpForwardingBase Class Members
See Also Methods Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpForwardingBase Class

Glossary Item Box

The following tables list the members exposed by TcpForwardingBase.

Public Constructors

 | Name | Description
Public Constructor | TcpForwardingBase Constructor | Overloaded.
Top

Public Methods

 | Name | Description
Public Method | Dispose | Stops and disposes of all servers
Public Method | SetLogDirectory | Provided with a directory it will log the communications there
Public Method | Start | Starts all servers
Top

Protected Methods

 | Name | Description
Protected Method | AddServer | Adds another server to forward connections for
Protected Method | OnConnectionEstablished | Called to handle a handshake when connecting to the forwarding target host
Protected Method | OnConnectTarget | Called as a connection is established to determin the target of the forwarding
Top

See Also

Reference

TcpForwardingBase Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpForwardingBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpForwardingBase Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class : TcpForwardingBase Constructor

Glossary Item Box

Overload List

Overload | Description
TcpForwardingBase Constructor() | Constructs the instance without a server
TcpForwardingBase Constructor(TcpServer) | Constructs the instance with a server

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpForwardingBase Constructor()
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class > TcpForwardingBase Constructor : TcpForwardingBase Constructor()

Glossary Item Box

Constructs the instance without a server

Syntax

Visual Basic (Declaration)
Protected Function New()
C#
protected TcpForwardingBase()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members
Overload List


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpForwardingBase Constructor(TcpServer)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class > TcpForwardingBase Constructor : TcpForwardingBase Constructor(TcpServer)

server

Glossary Item Box

Constructs the instance with a server

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal server As TcpServer _
)
C#
public TcpForwardingBase(
   TcpServer server
)

Parameters

server

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members
Overload List

Source Code

SslTunnel/Library/TcpForwardingBase.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TcpForwardingBase Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpForwardingBase Class

Glossary Item Box

For a list of all members of this type, see TcpForwardingBase members.

Public Methods

 | Name | Description
Public Method | Dispose | Stops and disposes of all servers
Public Method | SetLogDirectory | Provided with a directory it will log the communications there
Public Method | Start | Starts all servers
Top

Protected Methods

 | Name | Description
Protected Method | AddServer | Adds another server to forward connections for
Protected Method | OnConnectionEstablished | Called to handle a handshake when connecting to the forwarding target host
Protected Method | OnConnectTarget | Called as a connection is established to determin the target of the forwarding
Top

See Also

Reference

TcpForwardingBase Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpForwardingBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
AddServer Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class : AddServer Method

server

Glossary Item Box

Adds another server to forward connections for

Syntax

Visual Basic (Declaration)
Protected Sub AddServer( _
   ByVal server As TcpServer _
)
C#
protected void AddServer(
   TcpServer server
)

Parameters

server

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class : Dispose Method

Glossary Item Box

Stops and disposes of all servers

Syntax

Visual Basic (Declaration)
Public Overridable Sub Dispose()
C#
public virtual void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members

Source Code

SslTunnel/Library/TcpForwardingBase.cs

Used By

TcpRedirector.Dispose()


%%PageItemTitle%%

[image]
CSharpTest.Net
OnConnectionEstablished Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class : OnConnectionEstablished Method

args
client

Glossary Item Box

Called to handle a handshake when connecting to the forwarding target host

Syntax

Visual Basic (Declaration)
Protected MustOverride Sub OnConnectionEstablished( _
   ByVal args As TcpServer.ConnectedEventArgs, _
   ByVal client As TcpClient _
)
C#
protected abstract void OnConnectionEstablished(
   TcpServer.ConnectedEventArgs args,
   TcpClient client
)

Parameters

args
client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members


%%PageItemTitle%%

[image]
CSharpTest.Net
OnConnectTarget Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class : OnConnectTarget Method

args

Glossary Item Box

Called as a connection is established to determin the target of the forwarding

Syntax

Visual Basic (Declaration)
Protected MustOverride Function OnConnectTarget( _
   ByVal args As TcpServer.ConnectedEventArgs _
) As TcpClient
C#
protected abstract TcpClient OnConnectTarget(
   TcpServer.ConnectedEventArgs args
)

Parameters

args

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members


%%PageItemTitle%%

[image]
CSharpTest.Net
SetLogDirectory Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class : SetLogDirectory Method

directory

Glossary Item Box

Provided with a directory it will log the communications there

Syntax

Visual Basic (Declaration)
Public Sub SetLogDirectory( _
   ByVal directory As String _
)
C#
public void SetLogDirectory(
   string directory
)

Parameters

directory

Exceptions

Exception | Description
System.IO.DirectoryNotFoundException | The exception that is thrown when part of a file or directory cannot be found.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members

Source Code

SslTunnel/Library/TcpForwardingBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpForwardingBase Class : Start Method

Glossary Item Box

Starts all servers

Syntax

Visual Basic (Declaration)
Public Overridable Function Start() As IDisposable
C#
public virtual IDisposable Start()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpForwardingBase Class
TcpForwardingBase Members

Source Code

SslTunnel/Library/TcpForwardingBase.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpRedirector Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpRedirector Class

Glossary Item Box

A simple class that implements the abstract forwarding object to forward to a single destination endpoint

Syntax

Visual Basic (Declaration)
Public Class TcpRedirector
   Inherits TcpForwardingBase
C#
public class TcpRedirector : TcpForwardingBase

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TcpForwardingBase
CSharpTest.Net.SslTunnel.TcpRedirector

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpRedirector Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpRedirector.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TcpRedirector Class Members
See Also Methods Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpRedirector Class

Glossary Item Box

The following tables list the members exposed by TcpRedirector.

Public Constructors

 | Name | Description
Public Constructor | TcpRedirector Constructor | Forwards this server to the supplied target
Top

Public Methods

 | Name | Description
Public Method | Dispose | Overridden. Disposes of the instance
Public Method | SetLogDirectory | Provided with a directory it will log the communications there (Inherited from CSharpTest.Net.SslTunnel.TcpForwardingBase)
Public Method | Start | Starts all servers (Inherited from CSharpTest.Net.SslTunnel.TcpForwardingBase)
Top

Protected Methods

 | Name | Description
Protected Method | AddServer | Adds another server to forward connections for (Inherited from CSharpTest.Net.SslTunnel.TcpForwardingBase)
Protected Method | OnConnectionEstablished | Overridden.
Protected Method | OnConnectTarget | Overridden. Returns the target of the forwarding channel
Top

See Also

Reference

TcpRedirector Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpRedirector.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpRedirector Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpRedirector Class : TcpRedirector Constructor

server
target

Glossary Item Box

Forwards this server to the supplied target

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal server As TcpServer, _
   ByVal target As TcpClient _
)
C#
public TcpRedirector(
   TcpServer server,
   TcpClient target
)

Parameters

server
target

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpRedirector Class
TcpRedirector Members

Source Code

SslTunnel/Library/TcpRedirector.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TcpRedirector Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpRedirector Class

Glossary Item Box

For a list of all members of this type, see TcpRedirector members.

Public Methods

 | Name | Description
Public Method | Dispose | Overridden. Disposes of the instance
Public Method | SetLogDirectory | Provided with a directory it will log the communications there (Inherited from CSharpTest.Net.SslTunnel.TcpForwardingBase)
Public Method | Start | Starts all servers (Inherited from CSharpTest.Net.SslTunnel.TcpForwardingBase)
Top

Protected Methods

 | Name | Description
Protected Method | AddServer | Adds another server to forward connections for (Inherited from CSharpTest.Net.SslTunnel.TcpForwardingBase)
Protected Method | OnConnectionEstablished | Overridden.
Protected Method | OnConnectTarget | Overridden. Returns the target of the forwarding channel
Top

See Also

Reference

TcpRedirector Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpRedirector.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpRedirector Class : Dispose Method

Glossary Item Box

Disposes of the instance

Syntax

Visual Basic (Declaration)
Public Overrides Sub Dispose()
C#
public override void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpRedirector Class
TcpRedirector Members
Base Implementation in Dispose

Source Code

SslTunnel/Library/TcpRedirector.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OnConnectionEstablished Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpRedirector Class : OnConnectionEstablished Method

args
client

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Overrides Sub OnConnectionEstablished( _
   ByVal args As TcpServer.ConnectedEventArgs, _
   ByVal client As TcpClient _
)
C#
protected override void OnConnectionEstablished(
   TcpServer.ConnectedEventArgs args,
   TcpClient client
)

Parameters

args
client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpRedirector Class
TcpRedirector Members
Base Implementation in OnConnectionEstablished


%%PageItemTitle%%

[image]
CSharpTest.Net
OnConnectTarget Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpRedirector Class : OnConnectTarget Method

args

Glossary Item Box

Returns the target of the forwarding channel

Syntax

Visual Basic (Declaration)
Protected Overrides Function OnConnectTarget( _
   ByVal args As TcpServer.ConnectedEventArgs _
) As TcpClient
C#
protected override TcpClient OnConnectTarget(
   TcpServer.ConnectedEventArgs args
)

Parameters

args

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpRedirector Class
TcpRedirector Members
Base Implementation in OnConnectTarget


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpServer Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpServer Class

Glossary Item Box

A wrapper around the TcpListener

Syntax

Visual Basic (Declaration)
Public Class TcpServer
C#
public class TcpServer

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TcpServer
CSharpTest.Net.SslTunnel.SslServer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TcpServer Class Members
See Also Methods Events Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpServer Class

Glossary Item Box

The following tables list the members exposed by TcpServer.

Public Constructors

 | Name | Description
Public Constructor | TcpServer Constructor | Constructs a server using the the given ip or host name and port number
Top

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of the server, stops listening if needed.
Public Method | Start | Starts listening for requests
Public Method | Stop | Stops listening for requests
Top

Protected Methods

 | Name | Description
Protected Method | ConnectClient | Allows customization of the connection handshake (SSL)
Top

Public Events

 | Name | Description
Public Event | Connected | Raised when a client establishes a connection.
Top

See Also

Reference

TcpServer Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpServer Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer Class : TcpServer Constructor

bindingName
bindingPort

Glossary Item Box

Constructs a server using the the given ip or host name and port number

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal bindingName As String, _
   ByVal bindingPort As Integer _
)
C#
public TcpServer(
   string bindingName,
   int bindingPort
)

Parameters

bindingName
bindingPort

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TcpServer Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpServer Class

Glossary Item Box

For a list of all members of this type, see TcpServer members.

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of the server, stops listening if needed.
Public Method | Start | Starts listening for requests
Public Method | Stop | Stops listening for requests
Top

Protected Methods

 | Name | Description
Protected Method | ConnectClient | Allows customization of the connection handshake (SSL)
Top

See Also

Reference

TcpServer Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ConnectClient Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer Class : ConnectClient Method

client

Glossary Item Box

Allows customization of the connection handshake (SSL)

Syntax

Visual Basic (Declaration)
Protected Overridable Function ConnectClient( _
   ByVal client As TcpClient _
) As Stream
C#
protected virtual Stream ConnectClient(
   TcpClient client
)

Parameters

client

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Dispose Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer Class : Dispose Method

Glossary Item Box

Disposes of the server, stops listening if needed.

Syntax

Visual Basic (Declaration)
Public Overridable Sub Dispose()
C#
public virtual void Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Used By

TcpForwardingBase.Dispose()

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer Class : Start Method

Glossary Item Box

Starts listening for requests

Syntax

Visual Basic (Declaration)
Public Sub Start()
C#
public void Start()

Exceptions

Exception | Description
System.ApplicationException | The exception that is thrown when a non-fatal application error occurs.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Used By

IDisposable TcpForwardingBase.Start()

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Stop Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer Class : Stop Method

Glossary Item Box

Stops listening for requests

Syntax

Visual Basic (Declaration)
Public Sub Stop()
C#
public void Stop()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Used By

TcpForwardingBase.Dispose()
TcpServer.Dispose()

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
TcpServer Class Events
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpServer Class

Glossary Item Box

For a list of all members of this type, see TcpServer members.

Public Events

 | Name | Description
Public Event | Connected | Raised when a client establishes a connection.
Top

See Also

Reference

TcpServer Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Connected Event
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer Class : Connected Event

Glossary Item Box

Raised when a client establishes a connection.

Syntax

Visual Basic (Declaration)
Public Event Connected As EventHandler(Of TcpServer.ConnectedEventArgs)
C#
public event EventHandler<TcpServer.ConnectedEventArgs> Connected

Event Data

The event handler receives an argument of type TcpServer.ConnectedEventArgs containing data related to this event. The following TcpServer.ConnectedEventArgs properties provide information specific to this event.

Property | Description
LocalEndPoint | Returns the local endpoint the client connected to
RemoteEndPoint | Returns the remote endpoint of the client connection
Stream | The network stream for this connection

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer Class
TcpServer Members

Source Code

Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpServer.ConnectedEventArgs Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpServer.ConnectedEventArgs Class

Glossary Item Box

The event argument used to handling inbound connections

Syntax

Visual Basic (Declaration)
Public Class TcpServer.ConnectedEventArgs
   Inherits System.EventArgs
C#
public class TcpServer.ConnectedEventArgs : System.EventArgs

Inheritance Hierarchy

System.Object
System.EventArgs
CSharpTest.Net.SslTunnel.TcpServer.ConnectedEventArgs

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer.ConnectedEventArgs Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TcpServer.ConnectedEventArgs Class Members
See Also Properties Methods Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpServer.ConnectedEventArgs Class

Glossary Item Box

The following tables list the members exposed by TcpServer.ConnectedEventArgs.

Public Properties

 | Name | Description
Public Property | LocalEndPoint | Returns the local endpoint the client connected to
Public Property | RemoteEndPoint | Returns the remote endpoint of the client connection
Public Property | Stream | The network stream for this connection
Top

Public Methods

 | Name | Description
Public Method | Close | Closes the connection on this client
Top

See Also

Reference

TcpServer.ConnectedEventArgs Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TcpServer.ConnectedEventArgs Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpServer.ConnectedEventArgs Class

Glossary Item Box

For a list of all members of this type, see TcpServer.ConnectedEventArgs members.

Public Methods

 | Name | Description
Public Method | Close | Closes the connection on this client
Top

See Also

Reference

TcpServer.ConnectedEventArgs Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Close Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer.ConnectedEventArgs Class : Close Method

Glossary Item Box

Closes the connection on this client

Syntax

Visual Basic (Declaration)
Public Sub Close()
C#
public void Close()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer.ConnectedEventArgs Class
TcpServer.ConnectedEventArgs Members

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TcpServer.ConnectedEventArgs Class Properties
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpServer.ConnectedEventArgs Class

Glossary Item Box

For a list of all members of this type, see TcpServer.ConnectedEventArgs members.

Public Properties

 | Name | Description
Public Property | LocalEndPoint | Returns the local endpoint the client connected to
Public Property | RemoteEndPoint | Returns the remote endpoint of the client connection
Public Property | Stream | The network stream for this connection
Top

See Also

Reference

TcpServer.ConnectedEventArgs Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
LocalEndPoint Property
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer.ConnectedEventArgs Class : LocalEndPoint Property

Glossary Item Box

Returns the local endpoint the client connected to

Syntax

Visual Basic (Declaration)
Public ReadOnly Property LocalEndPoint As IPEndPoint
C#
public IPEndPoint LocalEndPoint {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer.ConnectedEventArgs Class
TcpServer.ConnectedEventArgs Members

Source Code

SslTunnel/Library/TcpServer.cs
Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
RemoteEndPoint Property
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer.ConnectedEventArgs Class : RemoteEndPoint Property

Glossary Item Box

Returns the remote endpoint of the client connection

Syntax

Visual Basic (Declaration)
Public ReadOnly Property RemoteEndPoint As IPEndPoint
C#
public IPEndPoint RemoteEndPoint {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer.ConnectedEventArgs Class
TcpServer.ConnectedEventArgs Members

Source Code

SslTunnel/Library/TcpServer.cs
Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Stream Property
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpServer.ConnectedEventArgs Class : Stream Property

Glossary Item Box

The network stream for this connection

Syntax

Visual Basic (Declaration)
Public ReadOnly Property Stream As Stream
C#
public Stream Stream {get;}

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpServer.ConnectedEventArgs Class
TcpServer.ConnectedEventArgs Members

Source Code

SslTunnel/Library/TcpServer.cs
Library/Http/TcpServer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TcpSettings Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpSettings Class

Glossary Item Box

Some basic global timeout setting that can be modified.

Syntax

Visual Basic (Declaration)
Public MustInherit NotInheritable Class TcpSettings
C#
public static class TcpSettings

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TcpSettings

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpSettings Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpSettings.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TcpSettings Class Members
See Also Fields Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpSettings Class

Glossary Item Box

The following tables list the members exposed by TcpSettings.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | ActivityTimeout | Timeout used to close an inactive connection
static (Shared in Visual Basic) | ReadTimeout | Timeout when recieving data from foreign systems
static (Shared in Visual Basic) | WriteTimeout | Timeout when writting data to foreign systems
Top

See Also

Reference

TcpSettings Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpSettings.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TcpSettings Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TcpSettings Class

Glossary Item Box

For a list of all members of this type, see TcpSettings members.

Public Fields

 | Name | Description
static (Shared in Visual Basic) | ActivityTimeout | Timeout used to close an inactive connection
static (Shared in Visual Basic) | ReadTimeout | Timeout when recieving data from foreign systems
static (Shared in Visual Basic) | WriteTimeout | Timeout when writting data to foreign systems
Top

See Also

Reference

TcpSettings Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TcpSettings.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ActivityTimeout Field
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpSettings Class : ActivityTimeout Field

Glossary Item Box

Timeout used to close an inactive connection

Syntax

Visual Basic (Declaration)
Public Shared ActivityTimeout As Integer
C#
public static int ActivityTimeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpSettings Class
TcpSettings Members

Used By

TcpClient.Connect()

Source Code

SslTunnel/Library/TcpSettings.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ReadTimeout Field
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpSettings Class : ReadTimeout Field

Glossary Item Box

Timeout when recieving data from foreign systems

Syntax

Visual Basic (Declaration)
Public Shared ReadTimeout As Integer
C#
public static int ReadTimeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpSettings Class
TcpSettings Members

Used By

TcpClient.Connect()

Source Code

SslTunnel/Library/TcpSettings.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteTimeout Field
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TcpSettings Class : WriteTimeout Field

Glossary Item Box

Timeout when writting data to foreign systems

Syntax

Visual Basic (Declaration)
Public Shared WriteTimeout As Integer
C#
public static int WriteTimeout

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TcpSettings Class
TcpSettings Members

Used By

TcpClient.Connect()

Source Code

SslTunnel/Library/TcpSettings.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelConfig Class
Members Example See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelConfig Class

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Class TunnelConfig
C#
public class TunnelConfig

Example

SslTunnel/Test/TestTunnel.cs

C# Copy Code
using (TcpTestServer testserver = new TcpTestServer())
{
    TunnelConfig config = new TunnelConfig();
    AddServer(config, new IPEndPoint(IPAddress.Loopback, testserver.Port));

    using (config.Start())
    {
        //Send to the serverPort, forwards to testserver.Port
        TcpTestServer.Test(LoopBack, ServerPort, 10, 50, 500, 5000, 50000, 500000);
    }
}
VB.NET Copy Code
Using testserver As New TcpTestServer()
    Dim config As New TunnelConfig()
    AddServer(config, New IPEndPoint(IPAddress.Loopback, testserver.Port))

    Using config.Start()
        'Send to the serverPort, forwards to testserver.Port
        TcpTestServer.Test(LoopBack, ServerPort, 10, 50, 500, 5000, _
            50000, 500000)
    End Using
End Using

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TunnelConfig

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TunnelConfig Class Members
See Also Fields Methods Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelConfig Class

Glossary Item Box

The following tables list the members exposed by TunnelConfig.

Public Constructors

 | Name | Description
Public Constructor | TunnelConfig Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | Listeners |
Top

Public Methods

 | Name | Description
Public Method | Add | Overloaded.
static (Shared in Visual Basic) | Load | Overloaded.
Public Method | Start |
Top

See Also

Reference

TunnelConfig Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelConfig Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class : TunnelConfig Constructor

Glossary Item Box

Overload List

Overload | Description
TunnelConfig Constructor() |
TunnelConfig Constructor(TunnelListenerBase[]) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelConfig Constructor()
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class > TunnelConfig Constructor : TunnelConfig Constructor()

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public TunnelConfig()

Example

SslTunnel/Test/TestTunnel.cs

C# Copy Code
using (TcpTestServer testserver = new TcpTestServer())
{
    TunnelConfig config = new TunnelConfig();
    AddServer(config, new IPEndPoint(IPAddress.Loopback, testserver.Port));

    using (config.Start())
    {
        //Send to the serverPort, forwards to testserver.Port
        TcpTestServer.Test(LoopBack, ServerPort, 10, 50, 500, 5000, 50000, 500000);
    }
}
VB.NET Copy Code
Using testserver As New TcpTestServer()
    Dim config As New TunnelConfig()
    AddServer(config, New IPEndPoint(IPAddress.Loopback, testserver.Port))

    Using config.Start()
        'Send to the serverPort, forwards to testserver.Port
        TcpTestServer.Test(LoopBack, ServerPort, 10, 50, 500, 5000, _
            50000, 500000)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members
Overload List

Used By

TestTunnelBase.TestChainForward()
TestTunnelBase.TestConcurrentChainForward()
TestTunnel.TestSingleForward()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelConfig Constructor(TunnelListenerBase[])
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class > TunnelConfig Constructor : TunnelConfig Constructor(TunnelListenerBase[])

install

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal ParamArray install() As TunnelListenerBase _
)
C#
public TunnelConfig(
   params TunnelListenerBase[] install
)

Parameters

install

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
TunnelConfig Class Methods
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelConfig Class

Glossary Item Box

For a list of all members of this type, see TunnelConfig members.

Public Methods

 | Name | Description
Public Method | Add | Overloaded.
static (Shared in Visual Basic) | Load | Overloaded.
Public Method | Start |
Top

See Also

Reference

TunnelConfig Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class : Add Method

Glossary Item Box

Overload List

Overload | Description
Add(TunnelListener) |
Add(TunnelMultiplexer) |
Add(TunnelDemultiplexer) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(TunnelListener) Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class > Add Method : Add(TunnelListener) Method

service

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal service As TunnelListener _
)
C#
public void Add(
   TunnelListener service
)

Parameters

service

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members
Overload List
TunnelListener

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(TunnelMultiplexer) Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class > Add Method : Add(TunnelMultiplexer) Method

service

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal service As TunnelMultiplexer _
)
C#
public void Add(
   TunnelMultiplexer service
)

Parameters

service

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members
Overload List
TunnelMultiplexer

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Add(TunnelDemultiplexer) Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class > Add Method : Add(TunnelDemultiplexer) Method

service

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Overloads Sub Add( _
   ByVal service As TunnelDemultiplexer _
)
C#
public void Add(
   TunnelDemultiplexer service
)

Parameters

service

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members
Overload List
TunnelDemultiplexer

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Load Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class : Load Method

Glossary Item Box

Overload List

Overload | Description
Load() |
Load(XmlReader) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Load() Method
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class > Load Method : Load() Method

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Load() As TunnelConfig
C#
public static TunnelConfig Load()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Load(XmlReader) Method
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class > Load Method : Load(XmlReader) Method

reader

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Overloads Shared Function Load( _
   ByVal reader As XmlReader _
) As TunnelConfig
C#
public static TunnelConfig Load(
   XmlReader reader
)

Parameters

reader

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members
Overload List

Used By

TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Start Method
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class : Start Method

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function Start() As IDisposable
C#
public IDisposable Start()

Example

SslTunnel/Test/TestTunnel.cs

C# Copy Code
using (TcpTestServer testserver = new TcpTestServer())
{
    TunnelConfig config = new TunnelConfig();
    AddServer(config, new IPEndPoint(IPAddress.Loopback, testserver.Port));

    using (config.Start())
    {
        //Send to the serverPort, forwards to testserver.Port
        TcpTestServer.Test(LoopBack, ServerPort, 10, 50, 500, 5000, 50000, 500000);
    }
}
VB.NET Copy Code
Using testserver As New TcpTestServer()
    Dim config As New TunnelConfig()
    AddServer(config, New IPEndPoint(IPAddress.Loopback, testserver.Port))

    Using config.Start()
        'Send to the serverPort, forwards to testserver.Port
        TcpTestServer.Test(LoopBack, ServerPort, 10, 50, 500, 5000, _
            50000, 500000)
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members

Used By

TestTunnelBase.TestChainForward()
TestTunnelBase.TestConcurrentChainForward()
TestTunnel.TestSingleForward()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TunnelConfig Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelConfig Class

Glossary Item Box

For a list of all members of this type, see TunnelConfig members.

Public Fields

 | Name | Description
Public Field | Listeners |
Top

See Also

Reference

TunnelConfig Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Listeners Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelConfig Class : Listeners Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Listeners As TunnelListenerBase()
C#
public TunnelListenerBase[] Listeners

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelConfig Class
TunnelConfig Members

Used By

TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelDemultiplexer Class
Members Example See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelDemultiplexer Class

Glossary Item Box

A one-to-many port forwarding protocol that receives requests from a multiplexer and dispatches the the data stream to the services selected by the originating port.

Syntax

Visual Basic (Declaration)
Public Class TunnelDemultiplexer
   Inherits TunnelListenerBase
C#
public class TunnelDemultiplexer : TunnelListenerBase

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelDemultiplexer), config.Listeners[1].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelDemultiplexer)config.Listeners[1]).IpEndpoint);
Assert.AreEqual(10443, ((TunnelDemultiplexer)config.Listeners[1]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertificate);
Assert.AreEqual("password", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertPassword);
//<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IssuedTo);
//  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].Hash);
//  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].PublicKey);
//  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IgnoredErrors);
Assert.AreEqual(2, ((TunnelDemultiplexer)config.Listeners[1]).Targets.Length);
//  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].OriginalPort);
Assert.AreEqual("google.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].IpEndpoint);
Assert.AreEqual(443, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].Port);
Assert.AreEqual(true, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].UseSsl);
Assert.AreEqual("client.google.com.cer", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].ClientCertificate);
//  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].OriginalPort);
Assert.AreEqual("yahoo.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].IpEndpoint);
Assert.AreEqual(80, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].Port);
Assert.AreEqual(false, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].UseSsl);
//</demultiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelDemultiplexer), config.Listeners(1).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertPassword)
'<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IssuedTo)
'  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).Hash)
'  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).PublicKey)
'  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IgnoredErrors)
Assert.AreEqual(2, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets.Length)
'  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).OriginalPort)
Assert.AreEqual("google.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).UseSsl)
Assert.AreEqual("client.google.com.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).ClientCertificate)
'  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).OriginalPort)
Assert.AreEqual("yahoo.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).IpEndpoint)
Assert.AreEqual(80, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).Port)
Assert.AreEqual(False, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).UseSsl)
'</demultiplexer>

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TunnelListenerBase
CSharpTest.Net.SslTunnel.TunnelDemultiplexer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelDemultiplexer Members
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelDemultiplexer)

Used By

TestSampleConfig.TestConfigDemultiplexer()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TunnelDemultiplexer Class Members
See Also Fields Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelDemultiplexer Class

Glossary Item Box

The following tables list the members exposed by TunnelDemultiplexer.

Public Constructors

 | Name | Description
Public Constructor | TunnelDemultiplexer Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | AllowedClients | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | IpEndpoint |
Public Field | MonitoringDirectory | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Port |
Public Field | ServerCertificate | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | ServerCertPassword | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Targets |
Top

See Also

Reference

TunnelDemultiplexer Class
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelDemultiplexer)

Used By

TestSampleConfig.TestConfigDemultiplexer()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelDemultiplexer Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelDemultiplexer Class : TunnelDemultiplexer Constructor

Glossary Item Box

Overload List

Overload | Description
TunnelDemultiplexer Constructor() |
TunnelDemultiplexer Constructor(String,Int32,TunnelSenderFromPort[]) |
TunnelDemultiplexer Constructor(String,Int32,TunnelSenderFromPort[],String,String,ExpectedCertificate[]) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelDemultiplexer Class
TunnelDemultiplexer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelDemultiplexer Constructor()
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelDemultiplexer Class > TunnelDemultiplexer Constructor : TunnelDemultiplexer Constructor()

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public TunnelDemultiplexer()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelDemultiplexer Class
TunnelDemultiplexer Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelDemultiplexer Constructor(String,Int32,TunnelSenderFromPort[])
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelDemultiplexer Class > TunnelDemultiplexer Constructor : TunnelDemultiplexer Constructor(String,Int32,TunnelSenderFromPort[])

endpoint
port
target

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal endpoint As String, _
   ByVal port As Integer, _
   ByVal target() As TunnelSenderFromPort _
)
C#
public TunnelDemultiplexer(
   string endpoint,
   int port,
   TunnelSenderFromPort[] target
)

Parameters

endpoint
port
target

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelDemultiplexer Class
TunnelDemultiplexer Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelDemultiplexer Constructor(String,Int32,TunnelSenderFromPort[],String,String,ExpectedCertificate[])
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelDemultiplexer Class > TunnelDemultiplexer Constructor : TunnelDemultiplexer Constructor(String,Int32,TunnelSenderFromPort[],String,String,ExpectedCertificate[])

endpoint
port
targets
certificate
password
accept

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal endpoint As String, _
   ByVal port As Integer, _
   ByVal targets() As TunnelSenderFromPort, _
   ByVal certificate As String, _
   ByVal password As String, _
   ByVal ParamArray accept() As ExpectedCertificate _
)
C#
public TunnelDemultiplexer(
   string endpoint,
   int port,
   TunnelSenderFromPort[] targets,
   string certificate,
   string password,
   params ExpectedCertificate[] accept
)

Parameters

endpoint
port
targets
certificate
password
accept

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelDemultiplexer Class
TunnelDemultiplexer Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TunnelDemultiplexer Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelDemultiplexer Class

Glossary Item Box

For a list of all members of this type, see TunnelDemultiplexer members.

Public Fields

 | Name | Description
Public Field | AllowedClients | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | IpEndpoint |
Public Field | MonitoringDirectory | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Port |
Public Field | ServerCertificate | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | ServerCertPassword | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Targets |
Top

See Also

Reference

TunnelDemultiplexer Class
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelDemultiplexer)

Used By

TestSampleConfig.TestConfigDemultiplexer()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpEndpoint Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelDemultiplexer Class : IpEndpoint Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public IpEndpoint As String
C#
public string IpEndpoint

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelDemultiplexer), config.Listeners[1].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelDemultiplexer)config.Listeners[1]).IpEndpoint);
Assert.AreEqual(10443, ((TunnelDemultiplexer)config.Listeners[1]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertificate);
Assert.AreEqual("password", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertPassword);
//<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IssuedTo);
//  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].Hash);
//  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].PublicKey);
//  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IgnoredErrors);
Assert.AreEqual(2, ((TunnelDemultiplexer)config.Listeners[1]).Targets.Length);
//  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].OriginalPort);
Assert.AreEqual("google.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].IpEndpoint);
Assert.AreEqual(443, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].Port);
Assert.AreEqual(true, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].UseSsl);
Assert.AreEqual("client.google.com.cer", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].ClientCertificate);
//  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].OriginalPort);
Assert.AreEqual("yahoo.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].IpEndpoint);
Assert.AreEqual(80, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].Port);
Assert.AreEqual(false, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].UseSsl);
//</demultiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelDemultiplexer), config.Listeners(1).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertPassword)
'<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IssuedTo)
'  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).Hash)
'  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).PublicKey)
'  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IgnoredErrors)
Assert.AreEqual(2, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets.Length)
'  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).OriginalPort)
Assert.AreEqual("google.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).UseSsl)
Assert.AreEqual("client.google.com.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).ClientCertificate)
'  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).OriginalPort)
Assert.AreEqual("yahoo.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).IpEndpoint)
Assert.AreEqual(80, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).Port)
Assert.AreEqual(False, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).UseSsl)
'</demultiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelDemultiplexer Class
TunnelDemultiplexer Members

Used By

TestSampleConfig.TestConfigDemultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
Port Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelDemultiplexer Class : Port Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Port As Integer
C#
public int Port

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelDemultiplexer), config.Listeners[1].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelDemultiplexer)config.Listeners[1]).IpEndpoint);
Assert.AreEqual(10443, ((TunnelDemultiplexer)config.Listeners[1]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertificate);
Assert.AreEqual("password", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertPassword);
//<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IssuedTo);
//  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].Hash);
//  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].PublicKey);
//  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IgnoredErrors);
Assert.AreEqual(2, ((TunnelDemultiplexer)config.Listeners[1]).Targets.Length);
//  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].OriginalPort);
Assert.AreEqual("google.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].IpEndpoint);
Assert.AreEqual(443, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].Port);
Assert.AreEqual(true, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].UseSsl);
Assert.AreEqual("client.google.com.cer", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].ClientCertificate);
//  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].OriginalPort);
Assert.AreEqual("yahoo.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].IpEndpoint);
Assert.AreEqual(80, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].Port);
Assert.AreEqual(false, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].UseSsl);
//</demultiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelDemultiplexer), config.Listeners(1).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertPassword)
'<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IssuedTo)
'  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).Hash)
'  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).PublicKey)
'  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IgnoredErrors)
Assert.AreEqual(2, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets.Length)
'  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).OriginalPort)
Assert.AreEqual("google.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).UseSsl)
Assert.AreEqual("client.google.com.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).ClientCertificate)
'  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).OriginalPort)
Assert.AreEqual("yahoo.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).IpEndpoint)
Assert.AreEqual(80, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).Port)
Assert.AreEqual(False, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).UseSsl)
'</demultiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelDemultiplexer Class
TunnelDemultiplexer Members

Used By

TestSampleConfig.TestConfigDemultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
Targets Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelDemultiplexer Class : Targets Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Targets As TunnelSenderFromPort()
C#
public TunnelSenderFromPort[] Targets

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelDemultiplexer), config.Listeners[1].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelDemultiplexer)config.Listeners[1]).IpEndpoint);
Assert.AreEqual(10443, ((TunnelDemultiplexer)config.Listeners[1]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertificate);
Assert.AreEqual("password", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertPassword);
//<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IssuedTo);
//  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].Hash);
//  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].PublicKey);
//  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IgnoredErrors);
Assert.AreEqual(2, ((TunnelDemultiplexer)config.Listeners[1]).Targets.Length);
//  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].OriginalPort);
Assert.AreEqual("google.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].IpEndpoint);
Assert.AreEqual(443, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].Port);
Assert.AreEqual(true, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].UseSsl);
Assert.AreEqual("client.google.com.cer", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].ClientCertificate);
//  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].OriginalPort);
Assert.AreEqual("yahoo.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].IpEndpoint);
Assert.AreEqual(80, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].Port);
Assert.AreEqual(false, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].UseSsl);
//</demultiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelDemultiplexer), config.Listeners(1).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertPassword)
'<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IssuedTo)
'  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).Hash)
'  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).PublicKey)
'  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IgnoredErrors)
Assert.AreEqual(2, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets.Length)
'  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).OriginalPort)
Assert.AreEqual("google.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).UseSsl)
Assert.AreEqual("client.google.com.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).ClientCertificate)
'  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).OriginalPort)
Assert.AreEqual("yahoo.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).IpEndpoint)
Assert.AreEqual(80, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).Port)
Assert.AreEqual(False, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).UseSsl)
'</demultiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelDemultiplexer Class
TunnelDemultiplexer Members

Used By

TestSampleConfig.TestConfigDemultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelListener Class
Members Example See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelListener Class

Glossary Item Box

A simple one-to-one port forwarding protocol

Syntax

Visual Basic (Declaration)
Public Class TunnelListener
   Inherits TunnelListenerBase
C#
public class TunnelListener : TunnelListenerBase

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TunnelListenerBase
CSharpTest.Net.SslTunnel.TunnelListener

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListener Members
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelListener)

Used By

TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TunnelListener Class Members
See Also Fields Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelListener Class

Glossary Item Box

The following tables list the members exposed by TunnelListener.

Public Constructors

 | Name | Description
Public Constructor | TunnelListener Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | AllowedClients | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | IpEndpoint |
Public Field | MonitoringDirectory | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Port |
Public Field | ServerCertificate | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | ServerCertPassword | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Target |
Top

See Also

Reference

TunnelListener Class
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelListener)

Used By

TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelListener Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListener Class : TunnelListener Constructor

Glossary Item Box

Overload List

Overload | Description
TunnelListener Constructor() |
TunnelListener Constructor(String,Int32,TunnelSender) |
TunnelListener Constructor(String,Int32,TunnelSender,String,String,ExpectedCertificate[]) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListener Class
TunnelListener Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelListener Constructor()
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListener Class > TunnelListener Constructor : TunnelListener Constructor()

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public TunnelListener()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListener Class
TunnelListener Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelListener Constructor(String,Int32,TunnelSender)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListener Class > TunnelListener Constructor : TunnelListener Constructor(String,Int32,TunnelSender)

endpoint
port
target

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal endpoint As String, _
   ByVal port As Integer, _
   ByVal target As TunnelSender _
)
C#
public TunnelListener(
   string endpoint,
   int port,
   TunnelSender target
)

Parameters

endpoint
port
target

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListener Class
TunnelListener Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelListener Constructor(String,Int32,TunnelSender,String,String,ExpectedCertificate[])
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListener Class > TunnelListener Constructor : TunnelListener Constructor(String,Int32,TunnelSender,String,String,ExpectedCertificate[])

endpoint
port
target
certificate
password
accept

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal endpoint As String, _
   ByVal port As Integer, _
   ByVal target As TunnelSender, _
   ByVal certificate As String, _
   ByVal password As String, _
   ByVal ParamArray accept() As ExpectedCertificate _
)
C#
public TunnelListener(
   string endpoint,
   int port,
   TunnelSender target,
   string certificate,
   string password,
   params ExpectedCertificate[] accept
)

Parameters

endpoint
port
target
certificate
password
accept

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListener Class
TunnelListener Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TunnelListener Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelListener Class

Glossary Item Box

For a list of all members of this type, see TunnelListener members.

Public Fields

 | Name | Description
Public Field | AllowedClients | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | IpEndpoint |
Public Field | MonitoringDirectory | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Port |
Public Field | ServerCertificate | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | ServerCertPassword | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Target |
Top

See Also

Reference

TunnelListener Class
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelListener)

Used By

TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpEndpoint Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListener Class : IpEndpoint Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public IpEndpoint As String
C#
public string IpEndpoint

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListener Class
TunnelListener Members

Used By

TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
Port Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListener Class : Port Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Port As Integer
C#
public int Port

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListener Class
TunnelListener Members

Used By

TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
Target Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListener Class : Target Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Target As TunnelSender
C#
public TunnelSender Target

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListener Class
TunnelListener Members

Used By

TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelListenerBase Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelListenerBase Class

Glossary Item Box

A common base class for the server listener types, listener, mux, and demux

Syntax

Visual Basic (Declaration)
Public MustInherit Class TunnelListenerBase
C#
public abstract class TunnelListenerBase

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TunnelListenerBase
CSharpTest.Net.SslTunnel.TunnelDemultiplexer
CSharpTest.Net.SslTunnel.TunnelListener
CSharpTest.Net.SslTunnel.TunnelMultiplexer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListenerBase Members
CSharpTest.Net.SslTunnel Namespace


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TunnelListenerBase Class Members
See Also Fields Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelListenerBase Class

Glossary Item Box

The following tables list the members exposed by TunnelListenerBase.

Protected Constructors

 | Name | Description
Protected Constructor | TunnelListenerBase Constructor |
Top

Public Fields

 | Name | Description
Public Field | AllowedClients |
Public Field | MonitoringDirectory |
Public Field | ServerCertificate |
Public Field | ServerCertPassword |
Top

See Also

Reference

TunnelListenerBase Class
CSharpTest.Net.SslTunnel Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelListenerBase Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListenerBase Class : TunnelListenerBase Constructor

certificate
password
accept

Glossary Item Box

Syntax

Visual Basic (Declaration)
Protected Function New( _
   ByVal certificate As String, _
   ByVal password As String, _
   ByVal ParamArray accept() As ExpectedCertificate _
)
C#
protected TunnelListenerBase(
   string certificate,
   string password,
   params ExpectedCertificate[] accept
)

Parameters

certificate
password
accept

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListenerBase Class
TunnelListenerBase Members


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TunnelListenerBase Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelListenerBase Class

Glossary Item Box

For a list of all members of this type, see TunnelListenerBase members.

Public Fields

 | Name | Description
Public Field | AllowedClients |
Public Field | MonitoringDirectory |
Public Field | ServerCertificate |
Public Field | ServerCertPassword |
Top

See Also

Reference

TunnelListenerBase Class
CSharpTest.Net.SslTunnel Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
AllowedClients Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListenerBase Class : AllowedClients Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public AllowedClients As ExpectedCertificate()
C#
public ExpectedCertificate[] AllowedClients

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListenerBase Class
TunnelListenerBase Members

Used By

TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
MonitoringDirectory Field
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListenerBase Class : MonitoringDirectory Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public MonitoringDirectory As String
C#
public string MonitoringDirectory

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListenerBase Class
TunnelListenerBase Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ServerCertificate Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListenerBase Class : ServerCertificate Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public ServerCertificate As String
C#
public string ServerCertificate

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListenerBase Class
TunnelListenerBase Members

Used By

TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
ServerCertPassword Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelListenerBase Class : ServerCertPassword Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public ServerCertPassword As String
C#
public string ServerCertPassword

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelListenerBase Class
TunnelListenerBase Members

Used By

TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelMultiplexer Class
Members Example See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelMultiplexer Class

Glossary Item Box

A many-to-one port forwarding protocol that embeds the originating port into the communication so that the demultiplexer on the other end can forward to the appropriate ip and port

Syntax

Visual Basic (Declaration)
Public Class TunnelMultiplexer
   Inherits TunnelListenerBase
C#
public class TunnelMultiplexer : TunnelListenerBase

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<multiplexer ip="127.0.0.1">
Assert.AreEqual(typeof(TunnelMultiplexer), config.Listeners[0].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).IpEndpoint);
//  <accept ?
Assert.IsNull(((TunnelMultiplexer)config.Listeners[0]).AllowedClients);
//  <add port="10080"/>
Assert.AreEqual(10080, ((TunnelMultiplexer)config.Listeners[0]).Ports[0].Port);
//  <add port="10081"/>
Assert.AreEqual(10081, ((TunnelMultiplexer)config.Listeners[0]).Ports[1].Port);
//  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).Target.IpEndpoint);
Assert.AreEqual(10443, ((TunnelMultiplexer)config.Listeners[0]).Target.Port);
Assert.AreEqual("client.localhost.nunit.cer", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertificate);
Assert.AreEqual("password", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertPassword);
//    <!--expect publicKey = server.localhost.nunit.cer-->
//    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001",
    ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.PublicKey);
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.IgnoredErrors);
//  </target>
//</multiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<multiplexer ip="127.0.0.1">
Assert.AreEqual(GetType(TunnelMultiplexer), config.Listeners(0).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).IpEndpoint)
'  <accept ?
Assert.IsNull((DirectCast(config.Listeners(0), TunnelMultiplexer)).AllowedClients)
'  <add port="10080"/>
Assert.AreEqual(10080, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(0).Port)
'  <add port="10081"/>
Assert.AreEqual(10081, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(1).Port)
'  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.Port)
Assert.AreEqual("client.localhost.nunit.cer", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertPassword)
'    <!--expect publicKey = server.localhost.nunit.cer-->
'    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.PublicKey)
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.IgnoredErrors)
'  </target>
'</multiplexer>

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TunnelListenerBase
CSharpTest.Net.SslTunnel.TunnelMultiplexer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelMultiplexer Members
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelMultiplexer)

Used By

TestSampleConfig.TestConfigMultiplexer()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TunnelMultiplexer Class Members
See Also Fields Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelMultiplexer Class

Glossary Item Box

The following tables list the members exposed by TunnelMultiplexer.

Public Constructors

 | Name | Description
Public Constructor | TunnelMultiplexer Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | AllowedClients | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | IpEndpoint |
Public Field | MonitoringDirectory | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Ports |
Public Field | ServerCertificate | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | ServerCertPassword | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Target |
Top

See Also

Reference

TunnelMultiplexer Class
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelMultiplexer)

Used By

TestSampleConfig.TestConfigMultiplexer()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelMultiplexer Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelMultiplexer Class : TunnelMultiplexer Constructor

Glossary Item Box

Overload List

Overload | Description
TunnelMultiplexer Constructor() |
TunnelMultiplexer Constructor(String,Int32[],TunnelSender) |
TunnelMultiplexer Constructor(String,Int32[],TunnelSender,String,String,ExpectedCertificate[]) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelMultiplexer Class
TunnelMultiplexer Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelMultiplexer Constructor()
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelMultiplexer Class > TunnelMultiplexer Constructor : TunnelMultiplexer Constructor()

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public TunnelMultiplexer()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelMultiplexer Class
TunnelMultiplexer Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelMultiplexer Constructor(String,Int32[],TunnelSender)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelMultiplexer Class > TunnelMultiplexer Constructor : TunnelMultiplexer Constructor(String,Int32[],TunnelSender)

endpoint
ports
target

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal endpoint As String, _
   ByVal ports() As Integer, _
   ByVal target As TunnelSender _
)
C#
public TunnelMultiplexer(
   string endpoint,
   int[] ports,
   TunnelSender target
)

Parameters

endpoint
ports
target

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelMultiplexer Class
TunnelMultiplexer Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelMultiplexer Constructor(String,Int32[],TunnelSender,String,String,ExpectedCertificate[])
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelMultiplexer Class > TunnelMultiplexer Constructor : TunnelMultiplexer Constructor(String,Int32[],TunnelSender,String,String,ExpectedCertificate[])

endpoint
ports
target
certificate
password
accept

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal endpoint As String, _
   ByVal ports() As Integer, _
   ByVal target As TunnelSender, _
   ByVal certificate As String, _
   ByVal password As String, _
   ByVal ParamArray accept() As ExpectedCertificate _
)
C#
public TunnelMultiplexer(
   string endpoint,
   int[] ports,
   TunnelSender target,
   string certificate,
   string password,
   params ExpectedCertificate[] accept
)

Parameters

endpoint
ports
target
certificate
password
accept

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelMultiplexer Class
TunnelMultiplexer Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TunnelMultiplexer Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelMultiplexer Class

Glossary Item Box

For a list of all members of this type, see TunnelMultiplexer members.

Public Fields

 | Name | Description
Public Field | AllowedClients | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | IpEndpoint |
Public Field | MonitoringDirectory | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Ports |
Public Field | ServerCertificate | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | ServerCertPassword | (Inherited from CSharpTest.Net.SslTunnel.TunnelListenerBase)
Public Field | Target |
Top

See Also

Reference

TunnelMultiplexer Class
CSharpTest.Net.SslTunnel Namespace
TunnelConfig.Add(TunnelMultiplexer)

Used By

TestSampleConfig.TestConfigMultiplexer()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
IpEndpoint Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelMultiplexer Class : IpEndpoint Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public IpEndpoint As String
C#
public string IpEndpoint

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<multiplexer ip="127.0.0.1">
Assert.AreEqual(typeof(TunnelMultiplexer), config.Listeners[0].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).IpEndpoint);
//  <accept ?
Assert.IsNull(((TunnelMultiplexer)config.Listeners[0]).AllowedClients);
//  <add port="10080"/>
Assert.AreEqual(10080, ((TunnelMultiplexer)config.Listeners[0]).Ports[0].Port);
//  <add port="10081"/>
Assert.AreEqual(10081, ((TunnelMultiplexer)config.Listeners[0]).Ports[1].Port);
//  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).Target.IpEndpoint);
Assert.AreEqual(10443, ((TunnelMultiplexer)config.Listeners[0]).Target.Port);
Assert.AreEqual("client.localhost.nunit.cer", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertificate);
Assert.AreEqual("password", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertPassword);
//    <!--expect publicKey = server.localhost.nunit.cer-->
//    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001",
    ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.PublicKey);
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.IgnoredErrors);
//  </target>
//</multiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<multiplexer ip="127.0.0.1">
Assert.AreEqual(GetType(TunnelMultiplexer), config.Listeners(0).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).IpEndpoint)
'  <accept ?
Assert.IsNull((DirectCast(config.Listeners(0), TunnelMultiplexer)).AllowedClients)
'  <add port="10080"/>
Assert.AreEqual(10080, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(0).Port)
'  <add port="10081"/>
Assert.AreEqual(10081, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(1).Port)
'  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.Port)
Assert.AreEqual("client.localhost.nunit.cer", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertPassword)
'    <!--expect publicKey = server.localhost.nunit.cer-->
'    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.PublicKey)
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.IgnoredErrors)
'  </target>
'</multiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelMultiplexer Class
TunnelMultiplexer Members

Used By

TestSampleConfig.TestConfigMultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
Ports Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelMultiplexer Class : Ports Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Ports As AddPort()
C#
public AddPort[] Ports

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<multiplexer ip="127.0.0.1">
Assert.AreEqual(typeof(TunnelMultiplexer), config.Listeners[0].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).IpEndpoint);
//  <accept ?
Assert.IsNull(((TunnelMultiplexer)config.Listeners[0]).AllowedClients);
//  <add port="10080"/>
Assert.AreEqual(10080, ((TunnelMultiplexer)config.Listeners[0]).Ports[0].Port);
//  <add port="10081"/>
Assert.AreEqual(10081, ((TunnelMultiplexer)config.Listeners[0]).Ports[1].Port);
//  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).Target.IpEndpoint);
Assert.AreEqual(10443, ((TunnelMultiplexer)config.Listeners[0]).Target.Port);
Assert.AreEqual("client.localhost.nunit.cer", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertificate);
Assert.AreEqual("password", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertPassword);
//    <!--expect publicKey = server.localhost.nunit.cer-->
//    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001",
    ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.PublicKey);
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.IgnoredErrors);
//  </target>
//</multiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<multiplexer ip="127.0.0.1">
Assert.AreEqual(GetType(TunnelMultiplexer), config.Listeners(0).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).IpEndpoint)
'  <accept ?
Assert.IsNull((DirectCast(config.Listeners(0), TunnelMultiplexer)).AllowedClients)
'  <add port="10080"/>
Assert.AreEqual(10080, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(0).Port)
'  <add port="10081"/>
Assert.AreEqual(10081, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(1).Port)
'  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.Port)
Assert.AreEqual("client.localhost.nunit.cer", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertPassword)
'    <!--expect publicKey = server.localhost.nunit.cer-->
'    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.PublicKey)
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.IgnoredErrors)
'  </target>
'</multiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelMultiplexer Class
TunnelMultiplexer Members

Used By

TestSampleConfig.TestConfigMultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
Target Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelMultiplexer Class : Target Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Target As TunnelSender
C#
public TunnelSender Target

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<multiplexer ip="127.0.0.1">
Assert.AreEqual(typeof(TunnelMultiplexer), config.Listeners[0].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).IpEndpoint);
//  <accept ?
Assert.IsNull(((TunnelMultiplexer)config.Listeners[0]).AllowedClients);
//  <add port="10080"/>
Assert.AreEqual(10080, ((TunnelMultiplexer)config.Listeners[0]).Ports[0].Port);
//  <add port="10081"/>
Assert.AreEqual(10081, ((TunnelMultiplexer)config.Listeners[0]).Ports[1].Port);
//  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).Target.IpEndpoint);
Assert.AreEqual(10443, ((TunnelMultiplexer)config.Listeners[0]).Target.Port);
Assert.AreEqual("client.localhost.nunit.cer", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertificate);
Assert.AreEqual("password", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertPassword);
//    <!--expect publicKey = server.localhost.nunit.cer-->
//    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001",
    ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.PublicKey);
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.IgnoredErrors);
//  </target>
//</multiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<multiplexer ip="127.0.0.1">
Assert.AreEqual(GetType(TunnelMultiplexer), config.Listeners(0).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).IpEndpoint)
'  <accept ?
Assert.IsNull((DirectCast(config.Listeners(0), TunnelMultiplexer)).AllowedClients)
'  <add port="10080"/>
Assert.AreEqual(10080, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(0).Port)
'  <add port="10081"/>
Assert.AreEqual(10081, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(1).Port)
'  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.Port)
Assert.AreEqual("client.localhost.nunit.cer", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertPassword)
'    <!--expect publicKey = server.localhost.nunit.cer-->
'    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.PublicKey)
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.IgnoredErrors)
'  </target>
'</multiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelMultiplexer Class
TunnelMultiplexer Members

Used By

TestSampleConfig.TestConfigMultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSender Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelSender Class

Glossary Item Box

A service endpoint to connect to, setting UseSsl=true or provide either a client certificate or an expected server certificate to ensure the connection is secured with ssl.

Syntax

Visual Basic (Declaration)
Public Class TunnelSender
C#
public class TunnelSender

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TunnelSender
CSharpTest.Net.SslTunnel.TunnelSenderFromPort

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TunnelSender Class Members
See Also Fields Properties Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelSender Class

Glossary Item Box

The following tables list the members exposed by TunnelSender.

Public Constructors

 | Name | Description
Public Constructor | TunnelSender Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | ClientCertificate |
Public Field | ClientCertPassword |
Public Field | ExpectedCert |
Public Field | IpEndpoint |
Public Field | Port |
Top

Public Properties

 | Name | Description
Public Property | UseSsl |
Top

See Also

Reference

TunnelSender Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSender Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class : TunnelSender Constructor

Glossary Item Box

Overload List

Overload | Description
TunnelSender Constructor() |
TunnelSender Constructor(String,Int32,Boolean) |
TunnelSender Constructor(String,Int32,Boolean,ExpectedCertificate,String,String) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSender Constructor()
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class > TunnelSender Constructor : TunnelSender Constructor()

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public TunnelSender()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSender Constructor(String,Int32,Boolean)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class > TunnelSender Constructor : TunnelSender Constructor(String,Int32,Boolean)

endpoint
port
useSsl

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal endpoint As String, _
   ByVal port As Integer, _
   ByVal useSsl As Boolean _
)
C#
public TunnelSender(
   string endpoint,
   int port,
   bool useSsl
)

Parameters

endpoint
port
useSsl

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSender Constructor(String,Int32,Boolean,ExpectedCertificate,String,String)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class > TunnelSender Constructor : TunnelSender Constructor(String,Int32,Boolean,ExpectedCertificate,String,String)

endpoint
port
useSsl
expected
certificate
password

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal endpoint As String, _
   ByVal port As Integer, _
   ByVal useSsl As Boolean, _
   ByVal expected As ExpectedCertificate, _
   ByVal certificate As String, _
   ByVal password As String _
)
C#
public TunnelSender(
   string endpoint,
   int port,
   bool useSsl,
   ExpectedCertificate expected,
   string certificate,
   string password
)

Parameters

endpoint
port
useSsl
expected
certificate
password

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TunnelSender Class Properties
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelSender Class

Glossary Item Box

For a list of all members of this type, see TunnelSender members.

Public Properties

 | Name | Description
Public Property | UseSsl |
Top

See Also

Reference

TunnelSender Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
UseSsl Property
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class : UseSsl Property

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Property UseSsl As Boolean
C#
public bool UseSsl {get; set;}

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members

Used By

TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TunnelSender Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelSender Class

Glossary Item Box

For a list of all members of this type, see TunnelSender members.

Public Fields

 | Name | Description
Public Field | ClientCertificate |
Public Field | ClientCertPassword |
Public Field | ExpectedCert |
Public Field | IpEndpoint |
Public Field | Port |
Top

See Also

Reference

TunnelSender Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
ClientCertificate Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class : ClientCertificate Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public ClientCertificate As String
C#
public string ClientCertificate

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11080">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[2].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[2]).IpEndpoint);
Assert.AreEqual(11080, ((TunnelListener)config.Listeners[2]).Port);
//  <target ip="127.0.0.1" port="11443" ssl="true" clientCertFile="client.localhost.nunit.cer">
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[2]).Target.IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[2]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[2]).Target.UseSsl);
Assert.AreEqual("client.localhost.nunit.cer", ((TunnelListener)config.Listeners[2]).Target.ClientCertificate);
//    <!--expect publicKey = server.localhost.nunit.cer-->
//    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[2]).Target.ExpectedCert.IgnoredErrors);
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001",
    ((TunnelListener)config.Listeners[2]).Target.ExpectedCert.PublicKey);
//  </target>
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11080">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(2).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(2), TunnelListener)).IpEndpoint)
Assert.AreEqual(11080, (DirectCast(config.Listeners(2), TunnelListener)).Port)
'  <target ip="127.0.0.1" port="11443" ssl="true" clientCertFile="client.localhost.nunit.cer">
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(2), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(2), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(2), TunnelListener)).Target.UseSsl)
Assert.AreEqual("client.localhost.nunit.cer", (DirectCast(config.Listeners(2), TunnelListener)).Target.ClientCertificate)
'    <!--expect publicKey = server.localhost.nunit.cer-->
'    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(2), TunnelListener)).Target.ExpectedCert.IgnoredErrors)
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001", (DirectCast(config.Listeners(2), TunnelListener)).Target.ExpectedCert.PublicKey)
'  </target>
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members

Used By

TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()


%%PageItemTitle%%

[image]
CSharpTest.Net
ClientCertPassword Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class : ClientCertPassword Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public ClientCertPassword As String
C#
public string ClientCertPassword

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<multiplexer ip="127.0.0.1">
Assert.AreEqual(typeof(TunnelMultiplexer), config.Listeners[0].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).IpEndpoint);
//  <accept ?
Assert.IsNull(((TunnelMultiplexer)config.Listeners[0]).AllowedClients);
//  <add port="10080"/>
Assert.AreEqual(10080, ((TunnelMultiplexer)config.Listeners[0]).Ports[0].Port);
//  <add port="10081"/>
Assert.AreEqual(10081, ((TunnelMultiplexer)config.Listeners[0]).Ports[1].Port);
//  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", ((TunnelMultiplexer)config.Listeners[0]).Target.IpEndpoint);
Assert.AreEqual(10443, ((TunnelMultiplexer)config.Listeners[0]).Target.Port);
Assert.AreEqual("client.localhost.nunit.cer", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertificate);
Assert.AreEqual("password", ((TunnelMultiplexer)config.Listeners[0]).Target.ClientCertPassword);
//    <!--expect publicKey = server.localhost.nunit.cer-->
//    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001",
    ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.PublicKey);
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelMultiplexer)config.Listeners[0]).Target.ExpectedCert.IgnoredErrors);
//  </target>
//</multiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<multiplexer ip="127.0.0.1">
Assert.AreEqual(GetType(TunnelMultiplexer), config.Listeners(0).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).IpEndpoint)
'  <accept ?
Assert.IsNull((DirectCast(config.Listeners(0), TunnelMultiplexer)).AllowedClients)
'  <add port="10080"/>
Assert.AreEqual(10080, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(0).Port)
'  <add port="10081"/>
Assert.AreEqual(10081, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Ports(1).Port)
'  <target ip="127.0.0.1" port="10443" clientCertFile="client.localhost.nunit.cer" clientCertPassword="password">
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.Port)
Assert.AreEqual("client.localhost.nunit.cer", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ClientCertPassword)
'    <!--expect publicKey = server.localhost.nunit.cer-->
'    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001", (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.PublicKey)
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(0), TunnelMultiplexer)).Target.ExpectedCert.IgnoredErrors)
'  </target>
'</multiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members

Used By

TestSampleConfig.TestConfigMultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
ExpectedCert Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class : ExpectedCert Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public ExpectedCert As ExpectedCertificate
C#
public ExpectedCertificate ExpectedCert

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11080">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[2].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[2]).IpEndpoint);
Assert.AreEqual(11080, ((TunnelListener)config.Listeners[2]).Port);
//  <target ip="127.0.0.1" port="11443" ssl="true" clientCertFile="client.localhost.nunit.cer">
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[2]).Target.IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[2]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[2]).Target.UseSsl);
Assert.AreEqual("client.localhost.nunit.cer", ((TunnelListener)config.Listeners[2]).Target.ClientCertificate);
//    <!--expect publicKey = server.localhost.nunit.cer-->
//    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[2]).Target.ExpectedCert.IgnoredErrors);
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001",
    ((TunnelListener)config.Listeners[2]).Target.ExpectedCert.PublicKey);
//  </target>
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11080">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(2).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(2), TunnelListener)).IpEndpoint)
Assert.AreEqual(11080, (DirectCast(config.Listeners(2), TunnelListener)).Port)
'  <target ip="127.0.0.1" port="11443" ssl="true" clientCertFile="client.localhost.nunit.cer">
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(2), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(2), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(2), TunnelListener)).Target.UseSsl)
Assert.AreEqual("client.localhost.nunit.cer", (DirectCast(config.Listeners(2), TunnelListener)).Target.ClientCertificate)
'    <!--expect publicKey = server.localhost.nunit.cer-->
'    <expect ignoreErrors="All" publicKey="30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(2), TunnelListener)).Target.ExpectedCert.IgnoredErrors)
Assert.AreEqual("30818902818100A3F81009F73AC50EDA186F8EDBB846C63A8BB8F0E8C25179DEA8FA376372E9394D470B071A76AA0F8D6250B98B8665FF2C03097D7055080AD237F1038404C99F44F2235BC319FFEBF70505225DAD4D47A1868FC92B4E9DEECA06F7BC5171CD96603B35AA6F7816DE294885E0AEF5B62EA981983822174CFDF2C46F392276DA8F0203010001", (DirectCast(config.Listeners(2), TunnelListener)).Target.ExpectedCert.PublicKey)
'  </target>
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members

Used By

TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigListener1()


%%PageItemTitle%%

[image]
CSharpTest.Net
IpEndpoint Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class : IpEndpoint Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public IpEndpoint As String
C#
public string IpEndpoint

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members

Used By

TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
Port Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSender Class : Port Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Port As Integer
C#
public int Port

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSender Class
TunnelSender Members

Used By

TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSenderFromPort Class
Members See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelSenderFromPort Class

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Class TunnelSenderFromPort
   Inherits TunnelSender
C#
public class TunnelSenderFromPort : TunnelSender

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.TunnelSender
CSharpTest.Net.SslTunnel.TunnelSenderFromPort

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSenderFromPort Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Members$$

[image]
CSharpTest.Net
TunnelSenderFromPort Class Members
See Also Fields Properties Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelSenderFromPort Class

Glossary Item Box

The following tables list the members exposed by TunnelSenderFromPort.

Public Constructors

 | Name | Description
Public Constructor | TunnelSenderFromPort Constructor | Overloaded.
Top

Public Fields

 | Name | Description
Public Field | ClientCertificate | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Public Field | ClientCertPassword | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Public Field | ExpectedCert | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Public Field | IpEndpoint | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Public Field | OriginalPort |
Public Field | Port | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Top

Public Properties

 | Name | Description
Public Property | UseSsl | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Top

See Also

Reference

TunnelSenderFromPort Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSenderFromPort Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSenderFromPort Class : TunnelSenderFromPort Constructor

Glossary Item Box

Overload List

Overload | Description
TunnelSenderFromPort Constructor() |
TunnelSenderFromPort Constructor(Int32,String,Int32,Boolean) |
TunnelSenderFromPort Constructor(Int32,String,Int32,Boolean,ExpectedCertificate,String,String) |

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSenderFromPort Class
TunnelSenderFromPort Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSenderFromPort Constructor()
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSenderFromPort Class > TunnelSenderFromPort Constructor : TunnelSenderFromPort Constructor()

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New()
C#
public TunnelSenderFromPort()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSenderFromPort Class
TunnelSenderFromPort Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSenderFromPort Constructor(Int32,String,Int32,Boolean)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSenderFromPort Class > TunnelSenderFromPort Constructor : TunnelSenderFromPort Constructor(Int32,String,Int32,Boolean)

originalPort
endpoint
port
useSsl

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal originalPort As Integer, _
   ByVal endpoint As String, _
   ByVal port As Integer, _
   ByVal useSsl As Boolean _
)
C#
public TunnelSenderFromPort(
   int originalPort,
   string endpoint,
   int port,
   bool useSsl
)

Parameters

originalPort
endpoint
port
useSsl

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSenderFromPort Class
TunnelSenderFromPort Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
TunnelSenderFromPort Constructor(Int32,String,Int32,Boolean,ExpectedCertificate,String,String)
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSenderFromPort Class > TunnelSenderFromPort Constructor : TunnelSenderFromPort Constructor(Int32,String,Int32,Boolean,ExpectedCertificate,String,String)

originalPort
endpoint
port
useSsl
expected
certificate
password

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Function New( _
   ByVal originalPort As Integer, _
   ByVal endpoint As String, _
   ByVal port As Integer, _
   ByVal useSsl As Boolean, _
   ByVal expected As ExpectedCertificate, _
   ByVal certificate As String, _
   ByVal password As String _
)
C#
public TunnelSenderFromPort(
   int originalPort,
   string endpoint,
   int port,
   bool useSsl,
   ExpectedCertificate expected,
   string certificate,
   string password
)

Parameters

originalPort
endpoint
port
useSsl
expected
certificate
password

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSenderFromPort Class
TunnelSenderFromPort Members
Overload List

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
TunnelSenderFromPort Class Fields
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelSenderFromPort Class

Glossary Item Box

For a list of all members of this type, see TunnelSenderFromPort members.

Public Fields

 | Name | Description
Public Field | ClientCertificate | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Public Field | ClientCertPassword | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Public Field | ExpectedCert | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Public Field | IpEndpoint | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Public Field | OriginalPort |
Public Field | Port | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Top

See Also

Reference

TunnelSenderFromPort Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
OriginalPort Field
See Also Example Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > TunnelSenderFromPort Class : OriginalPort Field

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public OriginalPort As Integer
C#
public int OriginalPort

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelDemultiplexer), config.Listeners[1].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelDemultiplexer)config.Listeners[1]).IpEndpoint);
Assert.AreEqual(10443, ((TunnelDemultiplexer)config.Listeners[1]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertificate);
Assert.AreEqual("password", ((TunnelDemultiplexer)config.Listeners[1]).ServerCertPassword);
//<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IssuedTo);
//  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].Hash);
//  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].PublicKey);
//  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelDemultiplexer)config.Listeners[1]).AllowedClients[0].IgnoredErrors);
Assert.AreEqual(2, ((TunnelDemultiplexer)config.Listeners[1]).Targets.Length);
//  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].OriginalPort);
Assert.AreEqual("google.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].IpEndpoint);
Assert.AreEqual(443, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].Port);
Assert.AreEqual(true, ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].UseSsl);
Assert.AreEqual("client.google.com.cer", ((TunnelDemultiplexer)config.Listeners[1]).Targets[0].ClientCertificate);
//  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].OriginalPort);
Assert.AreEqual("yahoo.com", ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].IpEndpoint);
Assert.AreEqual(80, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].Port);
Assert.AreEqual(false, ((TunnelDemultiplexer)config.Listeners[1]).Targets[1].UseSsl);
//</demultiplexer>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<demultiplexer ip="127.0.0.1" port="10443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelDemultiplexer), config.Listeners(1).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).IpEndpoint)
Assert.AreEqual(10443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).ServerCertPassword)
'<accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IssuedTo)
'  hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).Hash)
'  publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).PublicKey)
'  ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).AllowedClients(0).IgnoredErrors)
Assert.AreEqual(2, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets.Length)
'  <target forwardingPort="10080" ip="google.com" port="443" ssl="true" clientCertFile="client.google.com.cer" />
Assert.AreEqual(10080, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).OriginalPort)
Assert.AreEqual("google.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).UseSsl)
Assert.AreEqual("client.google.com.cer", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(0).ClientCertificate)
'  <target forwardingPort="10081" ip="yahoo.com" port="80" />
Assert.AreEqual(10081, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).OriginalPort)
Assert.AreEqual("yahoo.com", (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).IpEndpoint)
Assert.AreEqual(80, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).Port)
Assert.AreEqual(False, (DirectCast(config.Listeners(1), TunnelDemultiplexer)).Targets(1).UseSsl)
'</demultiplexer>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TunnelSenderFromPort Class
TunnelSenderFromPort Members

Used By

TestSampleConfig.TestConfigDemultiplexer()


%%PageItemTitle%%

[image]
CSharpTest.Net
IgnorePolicyErrors Enumeration
Example See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : IgnorePolicyErrors Enumeration

Glossary Item Box

Syntax

Visual Basic (Declaration)
Public Enum IgnorePolicyErrors
   Inherits System.Enum
C#
public enum IgnorePolicyErrors : System.Enum

Members

Member | Description
All |
ChainErrors |
NameMismatch |
None |

Example

SslTunnel/Test/TestSampleConfig.cs

C# Copy Code
TunnelConfig config = null;
using (XmlReader rdr = new XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config")))
    config = TunnelConfig.Load(rdr);
Assert.IsNotNull(config);
Assert.AreEqual(4, config.Listeners.Length);

//<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(typeof(TunnelListener), config.Listeners[3].GetType());
Assert.AreEqual("127.0.0.1", ((TunnelListener)config.Listeners[3]).IpEndpoint);
Assert.AreEqual(11443, ((TunnelListener)config.Listeners[3]).Port);
Assert.AreEqual("server.localhost.nunit.cer", ((TunnelListener)config.Listeners[3]).ServerCertificate);
Assert.AreEqual("password", ((TunnelListener)config.Listeners[3]).ServerCertPassword);
//  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
//  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, ((TunnelListener)config.Listeners[3]).AllowedClients.Length);
Assert.AreEqual("client.localhost.nunit", ((TunnelListener)config.Listeners[3]).AllowedClients[0].IssuedTo);
//    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", ((TunnelListener)config.Listeners[3]).AllowedClients[0].Hash);
//    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001",
    ((TunnelListener)config.Listeners[3]).AllowedClients[0].PublicKey);
//    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, ((TunnelListener)config.Listeners[3]).AllowedClients[0].IgnoredErrors);
//  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", ((TunnelListener)config.Listeners[3]).Target.IpEndpoint);
Assert.AreEqual(443, ((TunnelListener)config.Listeners[3]).Target.Port);
Assert.AreEqual(true, ((TunnelListener)config.Listeners[3]).Target.UseSsl);
//</listener>
VB.NET Copy Code
Dim config As TunnelConfig = Nothing
Using rdr As XmlReader = New XmlTextReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SslTunnel.Test.Sample.config"))
    config = TunnelConfig.Load(rdr)
End Using
Assert.IsNotNull(config)
Assert.AreEqual(4, config.Listeners.Length)

'<listener ip="127.0.0.1" port="11443" serverCertFile="server.localhost.nunit.cer" serverCertPassword="password">
Assert.AreEqual(GetType(TunnelListener), config.Listeners(3).[GetType]())
Assert.AreEqual("127.0.0.1", (DirectCast(config.Listeners(3), TunnelListener)).IpEndpoint)
Assert.AreEqual(11443, (DirectCast(config.Listeners(3), TunnelListener)).Port)
Assert.AreEqual("server.localhost.nunit.cer", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertificate)
Assert.AreEqual("password", (DirectCast(config.Listeners(3), TunnelListener)).ServerCertPassword)
'  <!--only allow name/hash/publicKey = client.localhost.nunit.cer-->
'  <accept issuedTo="client.localhost.nunit"
Assert.AreEqual(1, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients.Length)
Assert.AreEqual("client.localhost.nunit", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IssuedTo)
'    hash="68D757B929A1A91806C098C9BF89297EAB16675D"
Assert.AreEqual("68D757B929A1A91806C098C9BF89297EAB16675D", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).Hash)
'    publicKey="30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001"
Assert.AreEqual("30818902818100CF2B2CCF01956ADE2725104674FE107173446061A694BEFF31FDCAC134EA69125E1704CD0BBFBE1806F29909C60416FFEF811A03C8A3A248CD7086F7BDE959BC29DE4999A8A44191BCE8102DDC56E245476B91F773C2E7A47C32BC3935AF8766082F391E165976A46D6A57B609540B92E4BE681EC4E2EFB8C3F1C12B5709DFE90203010001", (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).PublicKey)
'    ignoreErrors="All" />
Assert.AreEqual(IgnorePolicyErrors.All, (DirectCast(config.Listeners(3), TunnelListener)).AllowedClients(0).IgnoredErrors)
'  <target ip="google.com" port="443" ssl="true" />
Assert.AreEqual("google.com", (DirectCast(config.Listeners(3), TunnelListener)).Target.IpEndpoint)
Assert.AreEqual(443, (DirectCast(config.Listeners(3), TunnelListener)).Target.Port)
Assert.AreEqual(True, (DirectCast(config.Listeners(3), TunnelListener)).Target.UseSsl)
'</listener>

Inheritance Hierarchy

System.Object
System.ValueType
System.Enum
CSharpTest.Net.SslTunnel.IgnorePolicyErrors

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

CSharpTest.Net.SslTunnel Namespace

Used By

TestSampleConfig.TestConfigMultiplexer()
TestSampleConfig.TestConfigDemultiplexer()
TestSampleConfig.TestConfigListener1()
TestSampleConfig.TestConfigListener2()


%%PageItemTitle%%

[image]
CSharpTest.Net
StreamRedirect.BinaryLogWrite Delegate
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : StreamRedirect.BinaryLogWrite Delegate

bytes
length

Glossary Item Box

An event to monitor the bytes being sent between client/server

Syntax

Visual Basic (Declaration)
Public Delegate Sub StreamRedirect.BinaryLogWrite( _
   ByVal bytes() As Byte, _
   ByVal length As Integer _
)
C#
public delegate void StreamRedirect.BinaryLogWrite(
   byte[] bytes,
   int length
)

Parameters

bytes
length

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

StreamRedirect.BinaryLogWrite Members
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/StreamRedirect.cs


%%ItemTitle%%

Command-Line Tools
Send Feedback Download Help File

Glossary Item Box

Command-Line Tools

The following command-line tools are included within this repository:

CmdTool.exe Overview | Visual Studio multi-file code generator that supports any command-line right from Visual Studio 2005-2010.
CSBuild.exe Overview | CSBuild is an MSBuild automation tool that sorts and builds entire an source tree of projects.
CSharpTest.Net.CoverageReport.exe Overview | CoverageReport builds NCover 1.x reports quickly and much more reliably that the original NCover.Explorer.exe.
CSharpTest.Net.Generators.exe Overview | Code generation utility currently containing code generators for ResX files.
SslCert.exe Overview | SslCert is a stand-alone tool used primarily to create self-signed certificates for use in IIS.
SslTunnel.Server.exe Overview | SslTunnel.Server provides both a command-line and a windows service secure tcp/ip port tunnel.
StampCopyright.exe Overview | StampCopyright injects copyright code regions at the top of any source files missing the provided text.
StampVersion.exe Overview | StampVersion modifies part or all of the assembly and file version attributes in the file(s) provided.
XhtmlValidate.exe Overview | XhtmlValidate validates html files on disk against the w3c DTD and reports details about any errors found.

Note: Command-line options are specified on the command line with a switch ('/' or '-') and if required the value may be specified by using a colon ':' or equals '=' to separate the name from the value.

Examples:
/name
/name=value
-name:value


%%ItemTitle%%

CmdTool.exe Overview
Send Feedback Download Help File
Command-Line Tools > CmdTool.exe Overview

Glossary Item Box

Usage:

C:\> CmdTool.exe COMMAND [arguments]

Visual Studio code generator that supports any command-line right from Visual Studio 2005-2010. CmdTool has a complete command-line interface as well for integration into builds you can easily regenerate all your code in one simple command-line operation.

Most commands require a search pattern or base directory to locate projects. For each project located in that set CmdTool will crawl the contents and find any project items bound to the "CmdTool" custom tool, then for each project and source file it:

  1. Scans up the directory tree from the source file to locate all "CmdTool.config" files.
  2. Loads the exe's configuration file.
  3. Looks for any matches on the source file's name based on the configuration files loaded.
  4. Assuming your building, it then runs each process in sequence capturing the output.
  5. If the specific tool has indicated to capture the output as the generator result it will be written to the generated file.
  6. When running in Visual Studio, errors and other progress information will be written to the Output Window.

Options:

  • /fast runs the commands in parallel, please note this may not work with all command-line tools.
  • /quiet limits output to the console to warnings and errors only.
  • /verbose outputs detailed diagnostics to the console.
  • /wait waits for user input before exiting the process.

Commands:

build

Rebuilds the output generated by the projects specified.

Usage:

C:\> CmdTool.exe BUILD project-file

Arguments:

  • project-file - One or more project files or wild-card patterns that specify the locations to recursively search for projects.

clean

Removes all output generated by the projects specified.

Usage:

C:\> CmdTool.exe CLEAN project-file

Arguments:

  • project-file - One or more project files or wild-card patterns that specify the locations to recursively search for projects.

Help

Gets the help for a specific command or lists available commands.

Usage:

C:\> CmdTool.exe HELP [[/name=]String] [/html]

Arguments:

  • [[/name=]String] - The name of the command or option to show help for.
  • [/html] = (False) - Output the full help content to HTML and view in the local browser.

help-config

Outputs a sample configuration file that demonstrates the available options.

Usage:

C:\> CmdTool.exe HELP-CONFIG

help-vars

Outputs the available replacement variables for the first generated file in the provided project.

Usage:

C:\> CmdTool.exe HELP-VARS project-file

Arguments:

  • project-file - One or more project files or wild-card patterns that specify the locations to recursively search for projects.

register

Registers the CmdTool custom generator with Visual Studio 2005, 2008, and 2010.

Usage:

C:\> CmdTool.exe REGISTER

unregister

Removes the CmdTool custom generator from Visual Studio 2005, 2008, and 2010.

Usage:

C:\> CmdTool.exe UNREGISTER


%%ItemTitle%%

CmdTool.exe Configuration
Send Feedback Download Help File
Command-Line Tools > CmdTool.exe Overview > CmdTool.exe Configuration

Glossary Item Box

Configuration Files:

You can run this generator by assigning a project item the custom generator of "CmdTool" in the Properties pane. Once you've done this there are three ways to invoke the code-generation:

1. Simply edit the original file and save it, Visual Studio will then run the generator
2. Right-click the item in Visual studio and select "Run Custom Tool"
3. From the command-line run the following: CmdTool.exe build <Project file.csproj>

Once code generation begins, CmdTool will start at the source file's directory and search up the directory tree. For each file named "CmdTool.config" it finds it will load the configuration below and merge it into the results. Finally CmdTool will load it's own CmdTool.exe.config and, if the section CmdTool is defined, merge it as well.

Once all configurations are merged it will begin attempting to match the original source file against all the patterns defined in the filespec attribute of the root match tags. This set of match tags is then walked and
will be excluded if the following conditions are met: a) there are one or more applies-to tags defined, and b) the input source is not contained in any of the directories defined by one of the applies-to tags. These folders are evaluated as relative to the configuration file they are defined within.

This final subset defines the collection of generators that will be applied to the input source file.

Hint: It's most common to just use a single CmdTool.config file located in the root of your source tree.

Input Variables:

A key part of configuring CmdTool is the use of input variables in the configuration file. Most of the time this small subset will suffice for most configurations:

Common Variables:

  • $(Namespace) - The namespace that should be used by the tool
  • $(ClassName) - The class name derived from the file name as a valid identifier
  • $(InputPath) - The fully qualified input file name to generate from
  • $(InputDir) - The qualified directory name for the input file
  • $(InputName) - The file name and extension of the input file
  • $(ConfigDir) - The directory where the configuration was loaded, also the working directory

There are of course tons more defined by MSBuild and from Visual Studio all of those are available. From the command-line you have a slightly more limited set of variables at your disposal but you can always run the "help-vars" command on the project to see what is and is not available.

Macro Replacements:

Macros like $(Namespace) can also be modified before use by a simple search and replace.

  • $(VARIABLE) = will be replaced with the variable as-is
  • $(VARIABLE:xxx=yyy) = will be replaced with the variable and then it replaces the literal string 'xxx' with the substitution value of 'yyy'
  • $(VARIABLE:xxx=yyy:aaa=bbb) = will be replaced with the variable and then it replaces both the literal string 'xxx' with the substitution value of 'yyy' and again replacing 'aaa' with 'bbb'

For example:

  • $(Namespace:.=) gives you a namespace without any '.' dots.
  • $(InputName:.cs=.vb) changes the name of the ".cs" file to have a ".vb" extension.

Configuration Example:

<?xml version="1.0" encoding="utf-8" ?>
<CmdTool xsi:noNamespaceSchemaLocation="http://csharptest.net/downloads/schema/CmdTool.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- The match is evaluated against the input file, use '*' or '?' for wild-cards -->
  <match filespec="*.test">
    <!-- applies if in one of the following directories relative to this configuration file -->
    <applies-to folder="c:\projects"/>
    <applies-to folder="."/>
    <!--
    A generator, one or more can be defined.  You may set debug=true for more verbose output including
    the modified script/file and arguments.  This will only be displayed on the console if you do not
    provide the '/quiet' option.  Use '/verbose' to produce the same effect on the command-line.
    -->
    <generator debug="false">
      <!--
      The type of executable can be either a script or an execute tag.  For either, the contents may
      include variables via the nmake macro expansion syntax '$(xxx)' see help-vars for more info.
      The script may be inline as shown here, or may be included from an external source via the
      'src=' attribute.  If the src attribute is defined the contents of the script block will not
      be used.  The path provided in the src attribute is again relative to this configuration file.
      Please be aware that scripts included via the attribute will not have variables replaced in
      their content.
      -->
      <script type="JScript">
        try {
        WScript.StdOut.WriteLine("// Generated from input:  " + WScript.Arguments(0));
        WScript.StdOut.Write(WScript.StdIn.ReadAll());
        }
        catch(e) {
        WScript.StdErr.Write(e.message);
        WScript.Quit(1);
        }
      </script>
      <!-- Provides one or more additional command-line arguments, this specifies the input file -->
      <arg value="$(inputPath)"/>
      <!-- Redirect the spawned process' std::in to read the input source file's content -->
      <std-input redirect="true"/>
      <!-- Optional, redirect std::out to a file with this extension -->
      <std-output extension=".JScript.cs"/>
      <!-- One or more files that the above program might generate -->
      <output extension=".missing.cs"/>
    </generator>
    <generator>
      <!-- Demonstrates generating multiple files and not using std::out -->
      <script type="Cmd">
        Echo // generated from source: %~1 > %2
        Echo // generated from source: %~1 > %3
      </script>
      <arg value="$(inputpath)"/>
      <arg value="$(inputpath:.test=.test1.cs)"/>
      <arg value="$(inputpath:.test=.test2.cs)"/>
      <output extension=".test1.cs"/>
      <output extension=".test2.cs"/>
    </generator>
    <generator>
      <!--
      Executables may use environment variables, or be found in the local %PATH% or current directory.
      Additionally, as with other paths, they can be a relative path to this configuration file.
      -->
      <execute exe="%SystemRoot%\system32\Cmd.exe"/>
      <arg value="/c"/>
      <arg value="@Echo // Generated from input: $(inputPath)"/>
      <std-output extension=".Exec.cs"/>
    </generator>
  </match>
</CmdTool>


%%ItemTitle%%

Integrating CmdTool with ResX
Send Feedback Download Help File
Command-Line Tools > CmdTool.exe Overview > CmdTool.exe Configuration Examples > Integrating CmdTool with ResX

Glossary Item Box

Integration Concepts:

The CSharpTest.Net.Generators.exe's ResX command provides several added benefits when used to replace Microsoft's default ResXFileCodeGenerator.

Example Configuration:

<?xml version="1.0" encoding="utf-8" ?>
<CmdTool xsi:noNamespaceSchemaLocation="CmdTool.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- Apply to any .ResX file configured to use "CmdTool" as the Custom Tool in Visual Studio -->
  <match filespec="*.resx">
    <generator debug="false">
      <!-- Use the CSharpTest.Net.Generators.exe from the same directory as CmdTool.exe -->
      <execute exe="$(CmdToolDir)CSharpTest.Net.Generators.exe" />
      <!-- Command name and arguments -->
      <arg value="ResX"/>
      <arg value="-input=$(InputPath)"/>
      <arg value="-namespace=$(Namespace)"/>
      <arg value="-class=$(ClassName)"/>
      <arg value="-public=false"/>
      <arg value="-partial=true"/>
      <arg value="-test=true"/>
      <arg value="-rxns=$(DefaultNamespace)"/>
      <!-- Capture the sdt::out stream and output to this file extension -->
      <std-output extension=".Designer.cs"/>
    </generator>
  </match>
</CmdTool>
Note: Just save the above xml to a file called "CmdTool.config" and place it in the directory tree either with, or above, the source resx files.


%%ItemTitle%%

Integrating CmdTool with Protobuffers
See Also Send Feedback Download Help File
Command-Line Tools > CmdTool.exe Overview > CmdTool.exe Configuration Examples > Integrating CmdTool with Protobuffers

Glossary Item Box

Integration Concepts:

The power of CmdTool Visual Studio integration is being able to take 3rd party applications and quickly integrate them into Visual Studio. Case in point is using Google's proto-buffers tools and generators.

Protoc.exe Configuration:

The following uses protoc.exe to turn the ".proto" file into a descriptor buffer file called ".buffer":

<?xml version="1.0" encoding="utf-8" ?>
<CmdTool xsi:noNamespaceSchemaLocation="CmdTool.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- Match any proto files -->
  <match filespec="*.proto">
    <generator debug="false">
      <!-- protoc.exe is in the environment's path so we don't need to qualify it -->
      <execute exe="protoc.exe" />
      <!-- protoc.exe arguments -->
      <arg value="--include_imports"/>
      <arg value="--proto_path=$(InputDir)\"/>
      <arg value="--descriptor_set_out=$(InputPath:.proto=.buffer)"/>
      <arg value="$(InputPath)"/>
      <!-- The output path we had protoc output to -->
      <output extension=".buffer"/>
    </generator>
  </match>
</CmdTool>

ProtoGen.exe Configuration:

The following uses ProtoGen's new ability to execute protoc at the same time.

Your build must be dated 2011 or later to work with this configuration you can obtain the source and build it easily enough.

<?xml version="1.0" encoding="utf-8" ?>
<CmdTool xsi:noNamespaceSchemaLocation="CmdTool.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <match filespec="*.proto">
    <generator debug="true">
      <execute exe="ProtoGen.exe" />
      <!-- protoc.exe arguments -->
      <arg value="--proto_path=$(InputDir)\"/>
      <arg value="--include_imports"/>
      <arg value="$(InputPath)"/>
      <!-- protogen.exe arguments -->
      <arg value="-file_extension=.Designer.cs"/>
      <arg value="-namespace=$(Namespace)"/>
      <arg value="-umbrella_namespace=Generated"/>
      <arg value="-output_directory=$(InputDir)\"/>
      <arg value="-ignore_google_protobuf=true"/>
      <arg value="-public_classes=false"/>
      <arg value="-cls_compliance=false"/>
      <arg value="-nest_classes=false"/>
      <output extension=".Designer.cs"/>
    </generator>
  </match>
</CmdTool>

See Also

Google Protocol Buffers Home
Protocol Buffers Developer Guide
Protocol Buffers .NET Port


%%ItemTitle%%

CmdTool.exe Variables
Send Feedback Download Help File
Command-Line Tools > CmdTool.exe Overview > CmdTool.exe Variables

Glossary Item Box

Macro Variables Available:

Besides the common variables mentioned in the Configuration topic, the following also may be available based on your version of Visual Studio and project configuration:

AppDesignerFolder = 'Properties'
AssemblyFoldersSuffix = 'AssemblyFoldersEx'
AssemblyName = 'CSharpTest.Net.Library'
AssemblyOriginatorKeyFile = '..\..\keys\csharptest.net.snk'
BaseIntermediateOutputPath = 'obj\'
ClassName = 'Resources'
CleanFile = 'Library.csproj.FileListAbsolute.txt'
CmdToolDir = 'C:\Project\bin\'
Configuration = 'Debug'
ConfigurationName = 'Debug'
DebugSymbols = 'True'
DebugType = 'pdbonly'
DefaultLanguageSourceExtension = '.cs'
DefaultNamespace = 'CSharpTest.Net'
DefineConstants = 'NET20;TRACE'
DelaySign = ''
DevEnvDir = '*Undefined*' (only available in Visual Studio)
DocumentationFile = '..\bin\CSharpTest.Net.Library.xml'
ErrorReport = 'none'
FrameworkDir = (only available in Visual Studio)
FrameworkRegistryBase = 'Software\Microsoft\.NetFramework'
FrameworkSDKDir = (only available in Visual Studio)
InputDir = 'C:\Project\Library\'
InputName = 'Resources.resx'
InputPath = 'C:\Project\Library\Resources.resx'
IntermediateOutputPath = '..\bin\obj\CSharpTest.Net.Library\'
Language = 'C#'
MSBuildToolsPath = 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\'
Namespace = 'CSharpTest.Net'
OutDir = '..\bin\'
OutputPath = '..\bin\'
OutputType = 'Library'
Platform = 'HPD'
PlatformName = 'HPD'
ProductVersion = '9.0.30729'
ProjectDir = 'C:\Project\Library\'
ProjectExt = '.csproj'
ProjectFileName = 'Library.csproj'
ProjectFlavor = 'Client'
ProjectGuid = '{7BD5EDD1-445C-46D1-A0B2-4B68CB51EADB}'
ProjectName = 'Library'
ProjectPath = 'C:\Project\Library\Library.csproj'
ProjectView = 'ProjectFiles'
PseudoPath = 'C:\Project\Library\Resources.resx'
PublishDir = '..\bin\CSharpTest.Net.Library.publish\'
RootNamespace = 'CSharpTest.Net'
SignAssembly = 'true'
SolutionDir = '*Undefined*' (only available in Visual Studio)
SolutionExt = '*Undefined*' (only available in Visual Studio)
SolutionFileName = '*Undefined*' (only available in Visual Studio)
SolutionName = '*Undefined*' (only available in Visual Studio)
SolutionPath = '*Undefined*' (only available in Visual Studio)
TargetDeployManifestFileName = 'CSharpTest.Net.Library.application'
TargetDir = (only available in Visual Studio)
TargetExt = '.dll'
TargetFileName = 'CSharpTest.Net.Library.dll'
TargetFrameworkVersion = 'v2.0'
TargetName = 'CSharpTest.Net.Library'
TargetPath = (only available in Visual Studio)
TreatWarningsAsErrors = 'True'
WarningLevel = '4'

Note: This is an incomplete list, but shortened to the more useful things.


%%ItemTitle%%

CmdTool.exe in Visual Studio
Send Feedback Download Help File
Command-Line Tools > CmdTool.exe Overview > CmdTool.exe in Visual Studio

Glossary Item Box

Installation:

There really isn't much. Put CmdTool.exe on your hard-drive somewhere. It's a stand-alone assembly so no need to copy anything but the "CmdTool.exe" if you want. Then run the following command:

> CmdTool.exe Register

To later remove CmdTool from your system, run the following command:

> CmdTool.exe Unregister

That's all there is to it for the setup, there is no harm in running the registration multiple times, so run it at the beginning of your build if you like.

Using in Visual Studio:

CmdTool can be set as the custom tool for any type of project item. To configure Visual Studio to use CmdTool for a given source file in a project perform the following:

  1. Right-click the desired source file.
  2. Select the "Properties" menu option.
  3. Under the entry called "Custom Tool" enter the value "CmdTool".

Not exactly rocket-science is it ;) Now you just need the configuration files...

Troubleshooting Errors:

First things first, if it complains check the output window. There should be an entry for "CmdTool" in the dropdown box labeled "Show output from:" as seen here:

If your not seeing enough details here to diagnose the issue you should then check the log files.

  • Command Line Logs: %AppData%\..\Local\CmdTool\LogFile.txt
  • Visual Studio Logs: %AppData%\..\Local\devenv\LogFile.txt

Still not getting anywhere? Try adding the debug=true attribute to the "<generator>" attribute(s) that are causing problems. If all else fails, run another copy of Visual Studio, from the menu select "Debug" -> "Attach to Process..." and select the other copy of Visual Studio. Then again under the Debug menu set the "Exceptions..." options to break on all errors and try again.


%%LocalItemTitle%%

CmdTool.xsd Schema
CmdTool.xsd Schema
Send Feedback Download Help File

Glossary Item Box

Elements

Element | Description
CmdTool |

Complex Types

Complex Type | Description
CmdToolConfig |
FileMatch |
GeneratorArgument |
GeneratorConfig |
GeneratorExec |
GeneratorInput |
GeneratorOutput |
GeneratorScript |
MatchAppliesTo |

Simple Types

Simple Type | Description
FileExtensionPattern |
FileMatchPattern |
FilePathPattern |
GeneratorScriptType |


%%ItemTitle%%

CSBuild.exe Overview
Send Feedback Download Help File
Command-Line Tools > CSBuild.exe Overview

Glossary Item Box

Usage:

C:\> CSBuild.exe [target] [/p:name=value] [/group=name1,name2] [/config=path\to\csbuild.config] [/log=logfile.txt] [/quiet] [/verbose] [/verbosity={Level}]

CSBuild is an MSBuild automation project to solve several key issues with using MSBuild directly. The following outlines some of the goals that CSBuild attempts to resolve:

Benefits of CSBuild

  • No more 'master' solutions - CSBuild takes an entire source tree worth of projects and builds them in the right order.
  • No more 'dead' projects - projects that have been removed from the aforementioned master solution that no longer build :( CSBuild keeps every project building.
  • Forced project options - controlling project options like output directories, target frameworks, etc takes a mother-load of a command-line in MSBuild.
  • Use specific assemblies - MSBuild does not allow you to easily control what assemblies are used in your build, thus a 2.0 build suddenly relies on a 3.5-only API like WaitHandle.WaitOne(0).
  • 2008 projects don't work - Using MSBuild from the Framework 2.0 directory will fail to build projects created in Visual Studio 2008 and later, CSBuild works.
  • MSBuild syntax sucks - controlling properties on the command-line every time you build just stinks, it's not enough to just give it a project/solution you have to specify more information. With CSBuild you have only to type the word "csbuild", press enter, and away you go...

Options:

  • target Targets are specified on the command line without a preceding switch. You may specify any number of targets, each as their own argument. All projects must support all the targets specified or MsBuild will fail.
  • /p:name=value properties can be defined just as you would when using MSBuild.exe directly (see below).
  • /group=name1,name2 specifies one or more names of configuration target groups to build.
  • /config=path\to\csbuild.config path to the configuration file to use (relative to cwd) instead of using CSBuild.exe.config.
  • /log=logfile.txt overrides the path to log file to write (relative to cwd).
  • /quiet produces console output only on errors and warnings.
  • /verbose produces verbose console output.
  • /verbosity={Level} where {Level} is one of the MsBuild defined verbosity levels: Quiet, Minimal, Normal, Detailed, Diagnostic.
  • /wait after processing wait for user input before exiting the process.

MSBuild Properties:

Properties can be defined that are passed directly to MsBuild. You can use multiple property definitions as needed.

Examples:

    /p:name=value
    -p=name:value
    /property:name=value
    -property=name:value

Common Properties:

    /p:Platform:AnyCPU
    /p:Configuration=Release
    /p:OutputPath=Release\AnyCPU\v3.5
    /p:TargetFrameworkVersion=v3.5
    /p:FrameworkBinPathv35=%windir%\Microsoft.NET\Framework\v3.5

Common Targets:

  • build Runs the build target on all projects. This is also the default target when one is not specified.
  • clean Runs the clean target on all projects.
  • rebuild Rebuilds all projects.
  • [other] Any MsBuild target supported by the projects included.


%%ItemTitle%%

CSBuild.exe Configuration
Send Feedback Download Help File
Command-Line Tools > CSBuild.exe Overview > CSBuild.exe Configuration

Glossary Item Box

CSBuild Configuration Schema:

Do you need to configure CSBuild? The simple answer is "No", it really depends on what your trying to accomplish. The default configuration (shown below) is enough to get you started. Just run CSBuild from a directory that contains some ".csproj" files and CSBuild will do the rest.

What can I do with and/or why would I configure CSBuild? You will want to manually configure CSBuild when you want to achieve one or more of the following:

Configurable Features

  • Exclude specific projects or directories from the build.
  • Define custom locations and detail levels of log files.
  • Add global paths to resolve referenced assemblies from.
  • Group several unrelated directories into a single build.
  • Specify configuration/platform targets and which toolset and framework to use.
  • Create multiple build output groups, even for the same assemblies.
  • Redirect all intermediate files to a common location.
  • Add or remove preprocessor constants (#define) to all projects.
  • Restrict project references to only the configured reference directories.
  • Continue building other projects even if one or more fail to compile.

Once you grow to love CSBuild as much as I do, you can configure it directly in the exe's config file, or in a separate file that is specified on the command line. For information about the available elements that can be specified see the CSBuild.xsd Schema.

Sample Configuration:

    <CSBuildConfig xsi:noNamespaceSchemaLocation="CSBuild.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <options>
            <console level="Minimal"/>
            <logfile path="%AppData%\CSBuild\CSBuild.log"/>
        </options>

        <projects>
            <add path=".\" relative-to="working-folder"/>
        </projects>
        <target tools="v3.5">
            <log relative-to="working-folder" path="msbuild.txt" level="Detailed"/>
            <xml relative-to="working-folder" path="msbuild.xml" level="Normal"/>
        </target>
    </CSBuildConfig>

Configuration File Paths:

  1. All paths that are not explicitly stated otherwise are relative to the current working directory.
  2. Paths may contain environment variables in the form of "%OPTION%".
  3. Paths may include properties (see above) or values from an included file (see /CSBuildConfig/options/include element) by using an make-macro style reference: "$(name)".
  4. The format of the include file element (/CSBuildConfig/options/include) is simply 'name=value' text lines. You may use ':' instead of '='. If the line of text does not include either it will be ignored.


%%ItemTitle%%

CSBuild.exe Configuration Example
Send Feedback Download Help File
Command-Line Tools > CSBuild.exe Overview > CSBuild.exe Configuration Example

Glossary Item Box

The following sample illustrate usage of all elements/attributes that were in place at the time of this writing:

<?xml version="1.0" encoding="utf-8" ?>
<CSBuildConfig xsi:noNamespaceSchemaLocation="CSBuild.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- Global settings and options -->
  <options>
    <!-- Configure the default output level for the console -->
    <console level="Minimal" enabled="true" />
    <!-- Defines the path to the text log file to write for CSBuild logging (not related to MSBuild log) -->
    <logfile path=".\CSBuild.log" relative-to="csbuild.exe"  enabled="false" />
    <!-- Save any changes made to projects, level defines the output type where Error will stop the build -->
    <save-project-changes enabled="false" level="Warning" />
    <!-- Import settings from a text file that contains "Name: Value" or "Name = Value" -->
    <import path="%userprofile%\environment.txt" relative-to="absolute-path" />
    <!-- Specify a single global property that can used in MSBuild or in the paths of this file -->
    <global-property name="MyCustomProperty" value="Value" global="true" />
    <!-- Adds the NoStdLib property to add projects and adds an explicit reference to mscorlib from the reference paths -->
    <no-standard-references enabled="false"/>
    <!-- Enforces that all references come from a reference directory specified in this file -->
    <strict-references enabled="false"/>
    <!-- Changes any Project-to-Project references into file references pointing to that project's primary output -->
    <force-file-references enabled="false"/>
    <!-- When enabled CSBuild will continue building all projects reguardless of how many errors are produced -->
    <continue-on-error enabled="false"/>
  </options>
  <!-- Inclusions and reference directories that apply to all target groups -->
  <projects>
    <!-- Adds all projects recursivly found in this path to all build targets defined below -->
    <add path=".\src\common" relative-to="csbuild.exe" />
    <!-- Excludes all projects found in this directory, excludes overwrite the add -->
    <remove path=".\src\common\tests" relative-to="csbuild.exe" />
    <!-- Reference assemblies from these directories -->
    <reference path="%SystemRoot%\Microsoft.Net\Framework\v2.0.50727\" relative-to="absolute-path" recursive="false" />
  </projects>
  <!-- Define the .NET 2.0 build, using only 2.0 tools (i.e. Linq will not work) -->
  <target group="v20" tools="v2.0" configuration="Debug" platform="AnyCPU">
    <!-- Set every project's TargetFrameworkVersion to this value, omit to leave alone -->
    <framework version="v2.0"/>
    <!-- Define "FRAMEWORK20" and undefine "FRAMEWORK35" -->
    <define value="FRAMEWORK20;-FRAMEWORK35" />
    <!-- Force all projects to use the same output directory -->
    <output path=".\bin\2.0\$(Configuration)\$(Platform)\obj" relative-to="csbuild.exe" />
    <!-- Force all projects to write intermediate files to this location -->
    <intermediateFiles path=".\bin\2.0\$(Configuration)\$(Platform)\obj\$(AssemblyName)\" relative-to="csbuild.exe"/>
    <!-- Disable the missing comment warning on all projects -->
    <property name="NoWarn" value="1591" global="false" />
    <!-- Set all warnings should be treated as errors -->
    <property name="TreatWarningsAsErrors" value="True" global="false" />
    <!-- Save the changes and fail the build if any of the non-global settings are modified -->
    <save-project-changes enabled="true" level="Error" />
    <!-- Add the projects specific to this target -->
    <add path="src\2.0" relative-to="csbuild.exe" />
    <!-- Remove anything you don't want -->
    <remove path="src\2.0\tests\BrokenNunit\BrokenNunit.csproj" relative-to="csbuild.exe" />
    <!-- Set the log output and detail level desired for text logging -->
    <log relative-to="csbuild.exe" path=".\bin\2.0\$(Configuration)\$(Platform)\msbuild.txt" level="Detailed"/>
    <!-- Set the log output and detail level desired for xml logging -->
    <xml relative-to="csbuild.exe" path=".\bin\2.0\$(Configuration)\$(Platform)\msbuild.xml" level="Normal"/>
  </target>
  <!-- Same thing again for the next target -->
  <target tools="v3.5" configuration="Debug" platform="AnyCPU">
    <framework version="v3.5"/>
    <!-- Allow 3.0/3.5 specific includes -->
    <reference path="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\" relative-to="absolute-path" recursive="true"/>
    <reference path="%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.5\" relative-to="absolute-path" recursive="true"/>
    <!-- Undefine "FRAMEWORK20" and Define "FRAMEWORK35" -->
    <define value="-FRAMEWORK20;FRAMEWORK35" />
    <!-- Force all projects to use the same output directory -->
    <output path=".\bin\3.5\$(Configuration)\$(Platform)\obj" relative-to="csbuild.exe" />
    <!-- Force all projects to write intermediate files to this location -->
    <intermediateFiles path=".\bin\3.5\$(Configuration)\$(Platform)\obj\$(AssemblyName)\" relative-to="csbuild.exe"/>
    <!-- Disable the missing comment warning on all projects -->
    <property name="NoWarn" value="1591" global="false" />
    <!-- Set all warnings should be treated as errors -->
    <property name="TreatWarningsAsErrors" value="True" global="false" />
    <!-- Don't save project changes -->
    <save-project-changes enabled="false" level="Verbose" />
    <!-- Add the projects specific to this target -->
    <add path="src\3.5" relative-to="csbuild.exe" />
    <!-- Set the log output and detail level desired for text logging -->
    <log relative-to="csbuild.exe" path=".\bin\3.5\$(Configuration)\$(Platform)\msbuild.txt" level="Detailed"/>
    <!-- Set the log output and detail level desired for xml logging -->
    <xml relative-to="csbuild.exe" path=".\bin\3.5\$(Configuration)\$(Platform)\msbuild.xml" level="Normal"/>
  </target>
</CSBuildConfig>


%%LocalItemTitle%%

CSBuild.xsd Schema
CSBuild.xsd Schema
Send Feedback Download Help File

Glossary Item Box

Elements

Element | Description
CSBuildConfig | The root configuration element for CSBuild. When placed in the exe's configuration file, this is the section rather than the xml root node, otherwise this is the root node.

Complex Types

Complex Type | Description
AddProjects |
BaseBuildSettingOfString |
BaseFileItem |
BaseFileOutput |
BaseOutput |
BooleanBuildOption |
BuildContinueOnError |
BuildDefineConst |
BuildIntermediateFiles |
BuildOptions | Global configuration options
BuildOutput |
BuildProperty |
BuildStrictReferences |
BuildTarget | Defines a group of projects that are built as a unit. Interdependencies are automatically sorted out by CSBuild and projects are built in the appropriate order based on their references. Individual projects can belong to many groups at the same time.
ConsoleOutputLevel |
CSBuildConfig |
DependsUpon |
ImportOptionsPath |
LogFileOutput |
LogFilePath |
NoStdReferences |
ProjectIncludes | Allows defining projects and references that are common across all build target groups.
ProjectReferencesToFile |
ReferenceFolder |
RemoveProjects |
SaveProjectChanges |
TargetFramework |
XmlFileOutput |

Simple Types

Simple Type | Description
BuildPlatforms |
FrameworkVersions |
LoggerVerbosity |
OutputRelative |
TraceLevel |


%%ItemTitle%%

CSharpTest.Net.CoverageReport.exe Overview
Send Feedback Download Help File
Command-Line Tools > CSharpTest.Net.CoverageReport.exe Overview

Glossary Item Box

Usage:

C:\> CSharpTest.Net.CoverageReport.exe [/s] [/wait] /module=[outputfile] /namespace=[outputfile] /combine=[outputfile] /class=[outputfile] /exclude=[regex pattern] coverage.xml [coverage2.xml] [coverage*.xml]

CSharpTest.Net.CoverageReport builds NCover 1.x reports quickly and much more reliably that the original NCover.Explorer.exe which often crashes when trying to merge output files.

Options:

  • /module will write a module-based summary of the coverage data
  • /namespace will write a namespace-based summary of the coverage data
  • /class will write a class-based summary of the coverage data
  • /combine will rewrite a combined coverage data file. Always list one or more coverage xml files generated by NCover 1.x. You may supply a relative or qualified file path and simple wildcards are allowed (* and ?).
  • /exclude will ignore classes/methods whos full name matches the provided regex pattern. This argument can be specified multiple times.
  • /s will recurse directories named on the command-line to match the files
  • /nologo hides the startup message.
  • /wait after processing wait for user input before exiting the process.

Sample Output:

http://csharptest.net/src/coverage_classes.xml


%%ItemTitle%%

CSharpTest.Net.Generators.exe Overview
Send Feedback Download Help File
Command-Line Tools > CSharpTest.Net.Generators.exe Overview

Glossary Item Box

Usage:

C:\> CSharpTest.Net.Generators.exe COMMAND [arguments]

Code generation utility currently containing code generators for ResX files. Currently the following types of code generation are possible:

  • Produce un-typed format methods from string that contain format arguments like '{0}'.
  • Optionally produce strongly typed format methods from format string.
  • Produce Exception classes from format strings by a simple naming convention: ending the identifier with "Exception".
  • Generate ".mc" files directly from a ResX file or from one or more embedded in a project.
  • Generate a complete message assembly for use with the Event Viewer from a project's ResX file(s).
  • Generate a resource script ".rc" or compiled Win32 resource file ".res" from a project's ResX file(s).

Commands:

Config

Writes a default CmdTool.config for this toolset to the console.

Usage:

C:\> CSharpTest.Net.Generators.exe CONFIG

Help

Gets the help for a specific command or lists available commands.

Usage:

C:\> CSharpTest.Net.Generators.exe HELP [[/name=]String] [/html]

Arguments:

  • [[/name=]String] - The name of the command or option to show help for.
  • [/html] = (False) - Output the full help content to HTML and view in the local browser.

ProjectResX

Generates the message files from a project and injects them into the project.

Usage:

C:\> CSharpTest.Net.Generators.exe PROJECTRESX [/csproj=]String [[/name=]String] [[/versionInfo=]String] [[/tools=]String]

Arguments:

  • [/csproj=]String - The csproj to generate message file for.
  • [[/name=]String] = (Resources) - The relative path and name of the generated resource files.
  • [[/versionInfo=]String] - A csproj containing or an AssemblyInfo.cs file -- or -- a dll to extract version info from.
  • [[/tools=]String] - The directory used to locate the mc.exe and rc.exe command line tools.

ResX

Generates strongly typed resources from .resx files with formatting and exceptions.

Usage:

C:\> CSharpTest.Net.Generators.exe RESX [/input=]String [/namespace=]String [/class=]String [[/resxNamespace=]String] [/public] [/partial] [/test] [/sealed] [[/base=]String]

Arguments:

  • [/input=]String - The input resx file to generate resources from.
  • [/namespace=]String - The resulting namespace to use when generating resource classes.
  • [/class=]String - The name of the containing class to use for the generated resources.
  • [[/resxNamespace=]String] - The namespace that the resource file will be embedded with.
  • [/public] = (False) - Determines if the output resource class should be public or internal.
  • [/partial] = (True) - Makes generated resource classes partial.
  • [/test] = (True) - Attempts to run String.Format over all formatting strings.
  • [/sealed] = (False) - Generates exceptions as sealed classes.
  • [[/base=]String] = (System.ApplicationException) - The default base exception to derive from.

ResXtoMc

Generates a Windows event log message file from a resx input file.

Usage:

C:\> CSharpTest.Net.Generators.exe RESXTOMC [/output=]String [/input=]String[]

Arguments:

  • [/output=]String - The target file path of the mc file to generate.
  • [/input=]String[] - The file path of either a resx file, or a project to scan for resx files within.

ResXtoMessageDll

Generates and compiles a Windows event log message assembly.

Usage:

C:\> CSharpTest.Net.Generators.exe RESXTOMESSAGEDLL [/output=]String [/input=]String[] [[/intermediate=]String] [[/versionInfo=]String] [[/namespace=]String] [[/tools=]String] [[/csc=]String]

Arguments:

  • [/output=]String - The target assembly name to generate.
  • [/input=]String[] - The file path of either a resx file, or a project to scan for resx files within.
  • [[/intermediate=]String] = (%TEMP%) - A directory used for intermediate files.
  • [[/versionInfo=]String] - A csproj containing or an AssemblyInfo.cs file -- or -- a dll to extract version info from.
  • [[/namespace=]String] - The namespace to use for the embedded constants and install utility classes.
  • [[/tools=]String] - The directory used to locate the mc.exe and rc.exe command line tools.
  • [[/csc=]String] = () - Additional options to provide to the csc command line compiler.


%%ItemTitle%%

GZipViewer.exe Overview
Send Feedback Download Help File
Command-Line Tools > GZipViewer.exe Overview

Glossary Item Box

Usage:

C:\> GZipViewer.exe file1.txt [file2.txt]

GZipViewer is a windows executable that can be used to extract/compress or quickly view gzip (*.gz) files. When registered with the "-register" argument you will see all files have a "GZip File" option in the right-click menu from Windows Explorer. Additionally files with the extension of ".gz" will have an "Extract" and an "Extract & View" option with the later as the shell default.

The "Extract & View" (or the "-view" option) means that you can simply double-click any file with an extension like ".ext.gz" to view it with associated program. When that program exits the temp file is removed. This works very well if you gzip compress log files, allowing you to double-click and view as if they were never compressed.

Options:

  • -register integrates GZipViewer with Windows Explorer.
  • -view after processing wait for user input before exiting the process.


%%ItemTitle%%

SslCert.exe Overview
Send Feedback Download Help File
Command-Line Tools > SslCert.exe Overview

Glossary Item Box

Usage:

C:\> SslCert.exe COMMAND [arguments]

SslCert is a stand-alone (dependency free) version of SslTunnel.Server's certificate commands. Used primarily to create self-signed certificates for use in IIS.

Options:

  • /nologo hides the startup message.

Commands:

DumpCert

Dumps the details of the certificate file specified to the console.

Usage:

C:\> SslCert.exe DUMPCERT [/file=]String [[/password=]String]

Arguments:

  • [/file=]String - The path to the certificate file to inspect.
  • [[/password=]String] - Optional password for the certificate file.

Help

Gets the help for a specific command or lists available commands.

Usage:

C:\> SslCert.exe HELP [[/name=]String] [/html]

Arguments:

  • [[/name=]String] - The name of the command or option to show help for.
  • [/html] = (False) - Output the full help content to HTML and view in the local browser.

MakeCert

Creates a self-signed certificate for client or server authentication.

Usage:

C:\> SslCert.exe MAKECERT [/name=]String

Arguments:

  • [/name=]String - The qualified host name of the machine to create the certificate for.


%%ItemTitle%%

SslTunnel.Server.exe Overview
Send Feedback Download Help File
Command-Line Tools > SslTunnel.Server.exe Overview

Glossary Item Box

Usage:

C:\> SslTunnel.Server.exe COMMAND [arguments]

SslTunnel.Server provides both a command-line and a windows service secure tcp/ip port tunnel.

Options:

  • /nologo hides the startup message.

Commands:

DumpCert

Dumps the details of the certificate file specified to the console.

Usage:

C:\> SslTunnel.Server.exe DUMPCERT [/file=]String [[/password=]String]

Arguments:

  • [/file=]String - The path to the certificate file to inspect.
  • [[/password=]String] - Optional password for the certificate file.

Sample Output:

File Path = C:\sample.org.cer
Issuer = CN=sample.org
Subject = CN=sample.org
SerialNumber = 223F7279108B848C4E293710F5988D3A
CertHash = 62B8421F9F5BFB6279E491F7EC5EB79ECB9687D8
EffectiveDate = 12/31/1999 11:00:00 PM
ExpirationDate = 12/31/2035 11:00:00 PM
Format = X509
KeyAlgorithm = 1.2.840.113549.1.1.1
KeyParameters = 0500
PublicKey = 30818902818100BA008E6D4669EAF5DBB6EA5E8 ... (full public key in hexadecimal)

Help

Gets the help for a specific command or lists available commands.

Usage:

C:\> SslTunnel.Server.exe HELP [[/name=]String] [/html]

Arguments:

  • [[/name=]String] - The name of the command or option to show help for.
  • [/html] = (False) - Output the full help content to HTML and view in the local browser.

Install

Installs the SslTunnel service, displayed as 'SSL Tunnel Service'.

Usage:

C:\> SslTunnel.Server.exe INSTALL

MakeCert

Creates a self-signed certificate for client or server authentication.

Usage:

C:\> SslTunnel.Server.exe MAKECERT [/name=]String

Arguments:

  • [/name=]String - The qualified host name of the machine to create the certificate for.

Sample Output:

C:\>SslTunnel.Server.exe makecert sample.org

Issuer = CN=sample.org
Subject = CN=sample.org
SerialNumber = C7835BC8A87DBE9745BE4A5E901E75A1
CertHash = D7AA8F390A5807AD373CD36838436D874A970265
EffectiveDate = 12/31/1999 11:00:00 PM
ExpirationDate = 12/31/2035 11:00:00 PM
Format = X509
KeyAlgorithm = 1.2.840.113549.1.1.1
KeyParameters = 0500
PublicKey = 30818902818100BB9A675813C577AE70267FDC3B ... (full public key in hexadecimal)
Key Access:
   Allow               NT AUTHORITY\SYSTEM  FullControl
   Allow      NT AUTHORITY\NETWORK SERVICE  FullControl
   Allow            BUILTIN\Administrators  FullControl
   Allow                  S-1-5-5-0-222282  ReadAndExecute, Synchronize

Run

Runs the listener in the interactive console to monitor activity.

Usage:

C:\> SslTunnel.Server.exe RUN

Uninstall

Uninstalls the SslTunnel service.

Usage:

C:\> SslTunnel.Server.exe UNINSTALL


%%ItemTitle%%

SslTunnel.Server.exe Configuration
Send Feedback Download Help File
Command-Line Tools > SslTunnel.Server.exe Overview > SslTunnel.Server.exe Configuration

Glossary Item Box

Sample Configuration:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="TunnelConfig" type="CSharpTest.Net.SslTunnel.Config, SslTunnel.Library" />
  </configSections>
  <TunnelConfig xsi:noNamespaceSchemaLocation="SslTunnel.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <multiplexer ip="127.0.0.1">
      <add port="10080"/>
      <add port="10081"/>
      <target ip="127.0.0.1" port="10443">
        <expect ignoreErrors="All"
          publicKey="30818902818100A3F8 ... DF2C46F392276DA8F0203010001"
          />
      </target>
    </multiplexer>
    <demultiplexer ip="127.0.0.1" port="10443"><!-- serverCertFile="client.cer">-->
      <target forwardingPort="10080" ip="google.com" port="80" />
      <target forwardingPort="10081" ip="yahoo.com" port="80" />
    </demultiplexer>
    <listener ip="127.0.0.1" port="11080">
      <target ip="127.0.0.1" port="11443">
        <expect
          hash="68D757B929A1A91806C098C9BF89297EAB16675D"
          publicKey="30818902818100CF2B ... 8C3F1C12B5709DFE90203010001"
          ignoreErrors="All" />
      </target>
    </listener>
    <listener ip="127.0.0.1" port="11443" serverCertFile="localhost.pfx" serverCertPassword="password">
      <target ip="google.com" port="80" />
    </listener>
  </TunnelConfig>
</configuration>


%%LocalItemTitle%%

SslTunnel.xsd Schema
SslTunnel.xsd Schema
Send Feedback Download Help File

Glossary Item Box

Elements

Element | Description
TunnelConfig |

Complex Types

Complex Type | Description
AddPort |
ExpectedCertificate |
TunnelConfig |
TunnelDemultiplexer |
TunnelListener |
TunnelListenerBase |
TunnelMultiplexer |
TunnelSender |
TunnelSenderFromPort |

Simple Types

Simple Type | Description
IgnorePolicyErrors |


%%ItemTitle%%

StampCopyright.exe Overview
Send Feedback Download Help File
Command-Line Tools > StampCopyright.exe Overview

Glossary Item Box

Usage:

C:\> StampCopyright.exe copyright.txt src\*.csproj [/svn=Path\to\svn.exe] [/nologo] [/wait]

StampCopyright takes the first argument and reads the copyright notice from it. It then searches each subsequent argument recursively for project files. For every project it finds it then walks the non-generated source files (*.cs) included and inserts the copyright notice.

Options:

  • copyright.txt the first parameter is always the copyright prefix to be inserted into the sources files
  • src\*.csproj all subsequent parameters that do not begin with a switch (/ or -) will be treated as a recursive file search pattern for projects
  • /svn=Path\to\svn.exe when provided, the program will obtain the first-seen year from subversion, see Copyright Text Handling below
  • /nologo hides the startup message.
  • /wait after processing wait for user input before exiting the process.

Copyright Text Handling

Usually the copyright notice is encased in a #region statement. Whether this is true or not the first text line must always contain the word "Copyright" and the last non-empty line can't contain some special characters as it is injected into a regular expression. Occurrences of the words "YEAR" or "yyyy" will be replaced with the current year. Moreover, if the current copyright on the source file already exists and contains a year less than the current year, these strings will be replace with the appropriate year range, i.e. "2005-2012". The following example is used in this library for copyright insertion:

#region Copyright yyyy by Roger Knapp, Licensed under the Apache License, Version 2.0
/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#endregion


%%ItemTitle%%

StampVersion.exe Overview
Send Feedback Download Help File
Command-Line Tools > StampVersion.exe Overview

Glossary Item Box

Usage:

C:\> StampVersion.exe [/nologo] [/wait] /build:{Number}|{File Path} [/revision={Number}|{File Path}]

StampVersion crawls the current directory for all files named "AssemblyInfo.cs" and for each of those files it searches for the AssemblyVersion or AssemblyFileVersion attribute. For each occurrence found it then replaces the version with the information provided on the command-line. For any value that is not specified on the command-line it will not be modified.

Options:

  • /major:{Number} - defines the major (2th part) of the version
    /major:{File Path} - file path of a text file contain a line with:
    Major: {Number}
  • /minor:{Number} - defines the minor (2th part) of the version
    /minor:{File Path} - file path of a text file contain a line with:
    Minor: {Number}
  • /build:{Number} - defines the build (3th part) of the version
    /build:{File Path} - file path of a text file contain a line with:
    Build: {Number}
  • /revision:{Number} - defines the revision (4th part) of the version
    /revision:{File Path} - file path of a text file contain a line with:
    Revision: {Number}
  • /nologo hides the startup message.
  • /wait after processing wait for user input before exiting the process.


%%ItemTitle%%

XhtmlValidate.exe Overview
Send Feedback Download Help File
Command-Line Tools > XhtmlValidate.exe Overview

Glossary Item Box

Usage:

C:\> XhtmlValidate.exe file1.htm [*.html]

XhtmlValidate takes each argument and treats it as a recursive file pattern, searching the directory portion for all files by the name or pattern specified. If an existing directory is specified without a file pattern, *.* is assumed.

Options:

  • /nologo hides the startup message.
  • /wait after processing wait for user input before exiting the process.


%%LocalItemTitle%%

CmdTool.xsd Schema
CmdTool Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema : CmdTool Element

Glossary Item Box

Namespace (none)

Type

CmdToolConfig Complex Type

Diagram

Sequence match Element Sequence CmdTool Element

Overview

CmdTool CmdToolConfig Complex Type
Sequence
match 0..∞ FileMatch Complex Type
filespec required FileMatchPattern Simple Type
stop optional xs:boolean
Sequence
applies-to 0..∞ MatchAppliesTo Complex Type
generator 1..∞ GeneratorConfig Complex Type

Source

<xs:element name="CmdTool" nillable="true" type="CmdToolConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
CmdToolConfig Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : CmdToolConfig Complex Type

Glossary Item Box

Namespace (none)

Diagram

Sequence match Element Sequence CmdToolConfig Complex Type

Overview

CmdToolConfig
Sequence
match 0..∞ FileMatch Complex Type
filespec required FileMatchPattern Simple Type
stop optional xs:boolean
Sequence
applies-to 0..∞ MatchAppliesTo Complex Type
generator 1..∞ GeneratorConfig Complex Type

Used By

CmdTool Element

Source

<xs:complexType name="CmdToolConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="match" type="FileMatch" />
  </xs:sequence>
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
FileMatch Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : FileMatch Complex Type

Glossary Item Box

Namespace (none)

Diagram

Sequence generator Element applies-to Element Sequence FileMatch Complex Type

Overview

FileMatch
filespec required FileMatchPattern Simple Type
stop optional xs:boolean
Sequence
applies-to 0..∞ MatchAppliesTo Complex Type
folder required FilePathPattern Simple Type
generator 1..∞ GeneratorConfig Complex Type
debug optional xs:boolean
Sequence
Choice
script GeneratorScript Complex Type
execute GeneratorExec Complex Type
arg 0..∞ GeneratorArgument Complex Type
std-input optional GeneratorInput Complex Type
std-output optional GeneratorOutput Complex Type
output 0..∞ GeneratorOutput Complex Type

Used By

match Element

Attributes

Name | Type | Use | Default | Fixed | Description
filespec | FileMatchPattern Simple Type | required |  |  |
stop | xs:boolean | optional | false |  |

Source

<xs:complexType name="FileMatch" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="applies-to" type="MatchAppliesTo" />
    <xs:element minOccurs="1" maxOccurs="unbounded" name="generator" type="GeneratorConfig" />
  </xs:sequence>
  <xs:attribute name="filespec" type="FileMatchPattern" use="required" />
  <xs:attribute name="stop" type="xs:boolean" use="optional" default="false" />
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
GeneratorArgument Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : GeneratorArgument Complex Type

Glossary Item Box

Namespace (none)

Overview

GeneratorArgument
value required xs:string

Used By

arg Element

Attributes

Name | Type | Use | Default | Fixed | Description
value | xs:string | required |  |  |

Source

<xs:complexType name="GeneratorArgument" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="value" type="xs:string" use="required" />
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
GeneratorConfig Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : GeneratorConfig Complex Type

Glossary Item Box

Namespace (none)

Diagram

output Element std-output Element std-input Element arg Element execute Element script Element Choice Sequence GeneratorConfig Complex Type

Overview

GeneratorConfig
debug optional xs:boolean
Sequence
Choice
script GeneratorScript Complex Type
type required GeneratorScriptType Simple Type
src optional FilePathPattern Simple Type
execute GeneratorExec Complex Type
exe required FilePathPattern Simple Type
arg 0..∞ GeneratorArgument Complex Type
value required xs:string
std-input optional GeneratorInput Complex Type
redirect required xs:boolean
std-output optional GeneratorOutput Complex Type
extension required xs:string
output 0..∞ GeneratorOutput Complex Type
extension required xs:string

Used By

generator Element

Attributes

Name | Type | Use | Default | Fixed | Description
debug | xs:boolean | optional | false |  |

Source

<xs:complexType name="GeneratorConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:choice minOccurs="1" maxOccurs="1">
      <xs:element minOccurs="1" maxOccurs="1" name="script" type="GeneratorScript" />
      <xs:element minOccurs="1" maxOccurs="1" name="execute" type="GeneratorExec" />
    </xs:choice>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="arg" type="GeneratorArgument" />
    <xs:element minOccurs="0" maxOccurs="1" name="std-input" type="GeneratorInput" />
    <xs:element minOccurs="0" maxOccurs="1" name="std-output" type="GeneratorOutput" />
    <xs:element minOccurs="0" maxOccurs="unbounded" name="output" type="GeneratorOutput" />
  </xs:sequence>
  <xs:attribute name="debug" type="xs:boolean" default="false" use="optional" />
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
GeneratorExec Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : GeneratorExec Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of xs:string

Overview

GeneratorExec Extension of xs:string
exe required FilePathPattern Simple Type

Used By

execute Element

Attributes

Name | Type | Use | Default | Fixed | Description
exe | FilePathPattern Simple Type | required |  |  |

Source

<xs:complexType name="GeneratorExec" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleContent>
    <xs:extension base="xs:string">
      <xs:attribute name="exe" type="FilePathPattern" use="required" />
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
GeneratorInput Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : GeneratorInput Complex Type

Glossary Item Box

Namespace (none)

Overview

GeneratorInput
redirect required xs:boolean

Used By

std-input Element

Attributes

Name | Type | Use | Default | Fixed | Description
redirect | xs:boolean | required |  |  |

Source

<xs:complexType name="GeneratorInput" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="redirect" type="xs:boolean" use="required" />
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
GeneratorOutput Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : GeneratorOutput Complex Type

Glossary Item Box

Namespace (none)

Overview

GeneratorOutput
extension required xs:string

Used By

std-output Element
output Element

Attributes

Name | Type | Use | Default | Fixed | Description
extension | xs:string | required |  |  |

Source

<xs:complexType name="GeneratorOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="extension" type="xs:string" use="required" />
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
GeneratorScript Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : GeneratorScript Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of xs:string

Overview

GeneratorScript Extension of xs:string
type required GeneratorScriptType Simple Type
src optional FilePathPattern Simple Type

Used By

script Element

Attributes

Name | Type | Use | Default | Fixed | Description
type | GeneratorScriptType Simple Type | required |  |  |
src | FilePathPattern Simple Type | optional |  |  |

Source

<xs:complexType name="GeneratorScript" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleContent>
    <xs:extension base="xs:string">
      <xs:attribute name="type" type="GeneratorScriptType" use="required" />
      <xs:attribute name="src" type="FilePathPattern" use="optional" />
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
MatchAppliesTo Complex Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : MatchAppliesTo Complex Type

Glossary Item Box

Namespace (none)

Overview

MatchAppliesTo
folder required FilePathPattern Simple Type

Used By

applies-to Element

Attributes

Name | Type | Use | Default | Fixed | Description
folder | FilePathPattern Simple Type | required |  |  |

Source

<xs:complexType name="MatchAppliesTo" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="folder" type="FilePathPattern" use="required" />
</xs:complexType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
FileExtensionPattern Simple Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : FileExtensionPattern Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

FileExtensionPattern Restriction of xs:string

Facets

Pattern ^.[^\\/:*?"|<>]*$

Source

<xs:simpleType name="FileExtensionPattern" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:pattern value="^.[^\\/:*?&quot;|&lt;&gt;]*$" />
  </xs:restriction>
</xs:simpleType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
FileMatchPattern Simple Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : FileMatchPattern Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

FileMatchPattern Restriction of xs:string

Facets

Pattern ^[^\\/:"|<>]+$

Source

<xs:simpleType name="FileMatchPattern" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:pattern value="^[^\\/:&quot;|&lt;&gt;]+$" />
  </xs:restriction>
</xs:simpleType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
FilePathPattern Simple Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : FilePathPattern Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

FilePathPattern Restriction of xs:string

Facets

Pattern ^[^*?"|<>]+$

Source

<xs:simpleType name="FilePathPattern" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:pattern value="^[^*?&quot;|&lt;&gt;]+$" />
  </xs:restriction>
</xs:simpleType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
GeneratorScriptType Simple Type
See Also Send Feedback Download Help File
CmdTool.xsd Schema : GeneratorScriptType Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

GeneratorScriptType Restriction of xs:string

Facets

Enumeration | JScript
Enumeration | VBScript
Enumeration | Cmd
Enumeration | PowerShell
Enumeration | CSharp
Enumeration | VBNet

Source

<xs:simpleType name="GeneratorScriptType" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:enumeration value="JScript" />
    <xs:enumeration value="VBScript" />
    <xs:enumeration value="Cmd" />
    <xs:enumeration value="PowerShell" />
    <xs:enumeration value="CSharp" />
    <xs:enumeration value="VBNet" />
  </xs:restriction>
</xs:simpleType>

See Also

CmdTool.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
CSBuildConfig Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema : CSBuildConfig Element

Glossary Item Box

Description

The root configuration element for CSBuild. When placed in the exe's configuration file, this is the section rather than the xml root node, otherwise this is the root node.
Namespace (none)

Type

CSBuildConfig Complex Type

Diagram

target Element projects Element options Element Choice Sequence CSBuildConfig Element

Overview

CSBuildConfig CSBuildConfig Complex Type
The root configuration element for CSBuild. When placed in the exe's configuration file, this is the section rather than the xml root node, otherwise this is the root node.
Sequence
Choice 0..∞
options optional BuildOptions Complex Type
timeout-hours optional xs:int
Sequence
Choice 0..∞
logfile optional LogFilePath Complex Type
strict-references optional BuildStrictReferences Complex Type
import optional ImportOptionsPath Complex Type
global-property optional BuildProperty Complex Type
no-standard-references optional NoStdReferences Complex Type
force-file-references optional ProjectReferencesToFile Complex Type
continue-on-error optional BuildContinueOnError Complex Type
save-project-changes optional SaveProjectChanges Complex Type
console optional ConsoleOutputLevel Complex Type
projects optional ProjectIncludes Complex Type
Sequence
Choice 0..∞
remove optional RemoveProjects Complex Type
reference optional ReferenceFolder Complex Type
add optional AddProjects Complex Type
target optional BuildTarget Complex Type
tools optional FrameworkVersions Simple Type
group optional xs:string
platform optional BuildPlatforms Simple Type
configuration optional xs:string
Sequence
Choice 0..∞
define optional BuildDefineConst Complex Type
reference optional ReferenceFolder Complex Type
output optional BuildOutput Complex Type
property optional BuildProperty Complex Type
intermediateFiles optional BuildIntermediateFiles Complex Type
save-project-changes optional SaveProjectChanges Complex Type
framework optional TargetFramework Complex Type
add optional AddProjects Complex Type
xml optional XmlFileOutput Complex Type
remove optional RemoveProjects Complex Type
log optional LogFileOutput Complex Type

Remarks

Example Definition:

<?xml version="1.0" encoding="utf-8" ?>
<CSBuildConfig xsi:noNamespaceSchemaLocation="CSBuild.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</CSBuildConfig>

Source

<xs:element name="CSBuildConfig" nillable="true" type="CSBuildConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
AddProjects Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : AddProjects Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Diagram

dependsOn Element Sequence AddProjects Complex Type

Overview

AddProjects Extension of BaseFileItem Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
Sequence
dependsOn 0..∞ DependsUpon Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

add Element
add Element

Attributes

Name | Type | Use | Default | Fixed | Description
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="AddProjects" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="dependsOn" type="DependsUpon" />
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BaseBuildSettingOfString Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BaseBuildSettingOfString Complex Type

Glossary Item Box

Namespace (none)

Overview

BaseBuildSettingOfString
value optional xs:string

Attributes

Name | Type | Use | Default | Fixed | Description
value | xs:string | optional |  |  |

Source

<xs:complexType name="BaseBuildSettingOfString" abstract="true" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="value" type="xs:string" />
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BaseFileItem Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BaseFileItem Complex Type

Glossary Item Box

Namespace (none)

Overview

BaseFileItem
relative-to optional OutputRelative Simple Type
path optional xs:string

Attributes

Name | Type | Use | Default | Fixed | Description
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="BaseFileItem" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute default="csbuild.exe" name="relative-to" type="OutputRelative" />
  <xs:attribute name="path" type="xs:string" />
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BaseFileOutput Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BaseFileOutput Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Overview

BaseFileOutput Extension of BaseFileItem Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string

Attributes

Name | Type | Use | Default | Fixed | Description
level | LoggerVerbosity Simple Type | required |  |  |
file | xs:string | optional |  |  |
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="BaseFileOutput" abstract="true" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem">
      <xs:attribute name="level" type="LoggerVerbosity" use="required" />
      <xs:attribute name="file" type="xs:string" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BaseOutput Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BaseOutput Complex Type

Glossary Item Box

Namespace (none)

Overview

BaseOutput
level optional LoggerVerbosity Simple Type

Attributes

Name | Type | Use | Default | Fixed | Description
level | LoggerVerbosity Simple Type | optional | Normal |  |

Source

<xs:complexType name="BaseOutput" abstract="true" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute default="Normal" name="level" type="LoggerVerbosity" />
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BooleanBuildOption Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BooleanBuildOption Complex Type

Glossary Item Box

Namespace (none)

Overview

BooleanBuildOption
enabled optional xs:boolean

Attributes

Name | Type | Use | Default | Fixed | Description
enabled | xs:boolean | optional | true |  |

Source

<xs:complexType name="BooleanBuildOption" abstract="true" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute default="true" name="enabled" type="xs:boolean" />
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildContinueOnError Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildContinueOnError Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BooleanBuildOption Complex Type

Overview

BuildContinueOnError Extension of BooleanBuildOption Complex Type
enabled optional xs:boolean

Used By

continue-on-error Element

Attributes

Name | Type | Use | Default | Fixed | Description
enabled | xs:boolean | optional | true |  |

Source

<xs:complexType name="BuildContinueOnError" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BooleanBuildOption" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildDefineConst Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildDefineConst Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseBuildSettingOfString Complex Type

Overview

BuildDefineConst Extension of BaseBuildSettingOfString Complex Type
value optional xs:string

Used By

define Element

Attributes

Name | Type | Use | Default | Fixed | Description
value | xs:string | optional |  |  |

Source

<xs:complexType name="BuildDefineConst" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseBuildSettingOfString" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildIntermediateFiles Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildIntermediateFiles Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Overview

BuildIntermediateFiles Extension of BaseFileItem Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

intermediateFiles Element

Attributes

Name | Type | Use | Default | Fixed | Description
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="BuildIntermediateFiles" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildOptions Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildOptions Complex Type

Glossary Item Box

Description

Global configuration options
Namespace (none)

Diagram

console Element save-project-changes Element continue-on-error Element force-file-references Element no-standard-references Element global-property Element import Element strict-references Element logfile Element Choice Sequence BuildOptions Complex Type

Overview

BuildOptions
Global configuration options
timeout-hours optional xs:int
Sequence
Choice 0..∞
logfile optional LogFilePath Complex Type
enabled optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string
strict-references optional BuildStrictReferences Complex Type
enabled optional xs:boolean
import optional ImportOptionsPath Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
global-property optional BuildProperty Complex Type
global optional xs:boolean
name optional xs:string
value optional xs:string
no-standard-references optional NoStdReferences Complex Type
enabled optional xs:boolean
force-file-references optional ProjectReferencesToFile Complex Type
enabled optional xs:boolean
continue-on-error optional BuildContinueOnError Complex Type
enabled optional xs:boolean
save-project-changes optional SaveProjectChanges Complex Type
enabled required xs:boolean
level optional TraceLevel Simple Type
console optional ConsoleOutputLevel Complex Type
enabled optional xs:boolean
level optional LoggerVerbosity Simple Type

Used By

options Element

Attributes

Name | Type | Use | Default | Fixed | Description
timeout-hours | xs:int | optional | 4 |  |

Source

<xs:complexType name="BuildOptions" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element minOccurs="0" maxOccurs="1" name="logfile" type="LogFilePath" />
      <xs:element minOccurs="0" maxOccurs="1" name="strict-references" type="BuildStrictReferences" />
      <xs:element minOccurs="0" maxOccurs="1" name="import" type="ImportOptionsPath" />
      <xs:element minOccurs="0" maxOccurs="1" name="global-property" type="BuildProperty" />
      <xs:element minOccurs="0" maxOccurs="1" name="no-standard-references" type="NoStdReferences" />
      <xs:element minOccurs="0" maxOccurs="1" name="force-file-references" type="ProjectReferencesToFile" />
      <xs:element minOccurs="0" maxOccurs="1" name="continue-on-error" type="BuildContinueOnError" />
      <xs:element minOccurs="0" maxOccurs="1" name="save-project-changes" type="SaveProjectChanges" />
      <xs:element minOccurs="0" maxOccurs="1" name="console" type="ConsoleOutputLevel" />
    </xs:choice>
  </xs:sequence>
  <xs:attribute default="4" name="timeout-hours" type="xs:int" />
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildOutput Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildOutput Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Overview

BuildOutput Extension of BaseFileItem Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

output Element

Attributes

Name | Type | Use | Default | Fixed | Description
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="BuildOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildProperty Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildProperty Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseBuildSettingOfString Complex Type

Overview

BuildProperty Extension of BaseBuildSettingOfString Complex Type
global optional xs:boolean
name optional xs:string
value optional xs:string

Used By

global-property Element
property Element

Attributes

Name | Type | Use | Default | Fixed | Description
global | xs:boolean | optional | false |  |
name | xs:string | optional |  |  |
value | xs:string | optional |  |  |

Source

<xs:complexType name="BuildProperty" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseBuildSettingOfString">
      <xs:attribute default="false" name="global" type="xs:boolean" />
      <xs:attribute name="name" type="xs:string" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildStrictReferences Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildStrictReferences Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BooleanBuildOption Complex Type

Overview

BuildStrictReferences Extension of BooleanBuildOption Complex Type
enabled optional xs:boolean

Used By

strict-references Element

Attributes

Name | Type | Use | Default | Fixed | Description
enabled | xs:boolean | optional | true |  |

Source

<xs:complexType name="BuildStrictReferences" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BooleanBuildOption" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildTarget Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildTarget Complex Type

Glossary Item Box

Description

Defines a group of projects that are built as a unit. Interdependencies are automatically sorted out by CSBuild and projects are built in the appropriate order based on their references. Individual projects can belong to many groups at the same time.
Namespace (none)

Diagram

log Element remove Element xml Element add Element framework Element save-project-changes Element intermediateFiles Element property Element output Element reference Element define Element Choice Sequence BuildTarget Complex Type

Overview

BuildTarget
Defines a group of projects that are built as a unit. Interdependencies are automatically sorted out by CSBuild and projects are built in the appropriate order based on their references. Individual projects can belong to many groups at the same time.
tools optional FrameworkVersions Simple Type
group optional xs:string
platform optional BuildPlatforms Simple Type
configuration optional xs:string
Sequence
Choice 0..∞
define optional BuildDefineConst Complex Type
value optional xs:string
reference optional ReferenceFolder Complex Type
recursive optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string
output optional BuildOutput Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
property optional BuildProperty Complex Type
global optional xs:boolean
name optional xs:string
value optional xs:string
intermediateFiles optional BuildIntermediateFiles Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
save-project-changes optional SaveProjectChanges Complex Type
enabled required xs:boolean
level optional TraceLevel Simple Type
framework optional TargetFramework Complex Type
version required FrameworkVersions Simple Type
add optional AddProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
Sequence
dependsOn 0..∞ DependsUpon Complex Type
xml optional XmlFileOutput Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string
remove optional RemoveProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
log optional LogFileOutput Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

target Element

Attributes

Name | Type | Use | Default | Fixed | Description
tools | FrameworkVersions Simple Type | optional | v3.5 |  |
group | xs:string | optional |  |  |
platform | BuildPlatforms Simple Type | optional | AnyCPU |  |
configuration | xs:string | optional | Debug |  |

Source

<xs:complexType name="BuildTarget" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element minOccurs="0" maxOccurs="1" name="define" type="BuildDefineConst" />
      <xs:element minOccurs="0" maxOccurs="1" name="reference" type="ReferenceFolder" />
      <xs:element minOccurs="0" maxOccurs="1" name="output" type="BuildOutput" />
      <xs:element minOccurs="0" maxOccurs="1" name="property" type="BuildProperty" />
      <xs:element minOccurs="0" maxOccurs="1" name="intermediateFiles" type="BuildIntermediateFiles" />
      <xs:element minOccurs="0" maxOccurs="1" name="save-project-changes" type="SaveProjectChanges" />
      <xs:element minOccurs="0" maxOccurs="1" name="framework" type="TargetFramework" />
      <xs:element minOccurs="0" maxOccurs="1" name="add" type="AddProjects" />
      <xs:element minOccurs="0" maxOccurs="1" name="xml" type="XmlFileOutput" />
      <xs:element minOccurs="0" maxOccurs="1" name="remove" type="RemoveProjects" />
      <xs:element minOccurs="0" maxOccurs="1" name="log" type="LogFileOutput" />
    </xs:choice>
  </xs:sequence>
  <xs:attribute default="v3.5" name="tools" type="FrameworkVersions" />
  <xs:attribute default="" name="group" type="xs:string" />
  <xs:attribute default="AnyCPU" name="platform" type="BuildPlatforms" />
  <xs:attribute default="Debug" name="configuration" type="xs:string" />
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
ConsoleOutputLevel Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : ConsoleOutputLevel Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseOutput Complex Type

Overview

ConsoleOutputLevel Extension of BaseOutput Complex Type
enabled optional xs:boolean
level optional LoggerVerbosity Simple Type

Used By

console Element

Attributes

Name | Type | Use | Default | Fixed | Description
enabled | xs:boolean | optional | true |  |
level | LoggerVerbosity Simple Type | optional | Normal |  |

Source

<xs:complexType name="ConsoleOutputLevel" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseOutput">
      <xs:attribute default="true" name="enabled" type="xs:boolean" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
CSBuildConfig Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : CSBuildConfig Complex Type

Glossary Item Box

Namespace (none)

Diagram

target Element projects Element options Element Choice Sequence CSBuildConfig Complex Type

Overview

CSBuildConfig
Sequence
Choice 0..∞
options optional BuildOptions Complex Type
timeout-hours optional xs:int
Sequence
Choice 0..∞
logfile optional LogFilePath Complex Type
strict-references optional BuildStrictReferences Complex Type
import optional ImportOptionsPath Complex Type
global-property optional BuildProperty Complex Type
no-standard-references optional NoStdReferences Complex Type
force-file-references optional ProjectReferencesToFile Complex Type
continue-on-error optional BuildContinueOnError Complex Type
save-project-changes optional SaveProjectChanges Complex Type
console optional ConsoleOutputLevel Complex Type
projects optional ProjectIncludes Complex Type
Sequence
Choice 0..∞
remove optional RemoveProjects Complex Type
reference optional ReferenceFolder Complex Type
add optional AddProjects Complex Type
target optional BuildTarget Complex Type
tools optional FrameworkVersions Simple Type
group optional xs:string
platform optional BuildPlatforms Simple Type
configuration optional xs:string
Sequence
Choice 0..∞
define optional BuildDefineConst Complex Type
reference optional ReferenceFolder Complex Type
output optional BuildOutput Complex Type
property optional BuildProperty Complex Type
intermediateFiles optional BuildIntermediateFiles Complex Type
save-project-changes optional SaveProjectChanges Complex Type
framework optional TargetFramework Complex Type
add optional AddProjects Complex Type
xml optional XmlFileOutput Complex Type
remove optional RemoveProjects Complex Type
log optional LogFileOutput Complex Type

Used By

CSBuildConfig Element

Source

<xs:complexType name="CSBuildConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element minOccurs="0" maxOccurs="1" name="options" type="BuildOptions" />
      <xs:element minOccurs="0" maxOccurs="1" name="projects" type="ProjectIncludes" />
      <xs:element minOccurs="0" maxOccurs="1" name="target" type="BuildTarget" />
    </xs:choice>
  </xs:sequence>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
DependsUpon Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : DependsUpon Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Overview

DependsUpon Extension of BaseFileItem Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

dependsOn Element

Attributes

Name | Type | Use | Default | Fixed | Description
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="DependsUpon" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
ImportOptionsPath Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : ImportOptionsPath Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Overview

ImportOptionsPath Extension of BaseFileItem Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

import Element

Attributes

Name | Type | Use | Default | Fixed | Description
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="ImportOptionsPath" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
LogFileOutput Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : LogFileOutput Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileOutput Complex Type

Overview

LogFileOutput Extension of BaseFileOutput Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

log Element

Attributes

Name | Type | Use | Default | Fixed | Description
level | LoggerVerbosity Simple Type | required |  |  |
file | xs:string | optional |  |  |
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="LogFileOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileOutput" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
LogFilePath Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : LogFilePath Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Overview

LogFilePath Extension of BaseFileItem Complex Type
enabled optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

logfile Element

Attributes

Name | Type | Use | Default | Fixed | Description
enabled | xs:boolean | optional | true |  |
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="LogFilePath" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem">
      <xs:attribute default="true" name="enabled" type="xs:boolean" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
NoStdReferences Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : NoStdReferences Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BooleanBuildOption Complex Type

Overview

NoStdReferences Extension of BooleanBuildOption Complex Type
enabled optional xs:boolean

Used By

no-standard-references Element

Attributes

Name | Type | Use | Default | Fixed | Description
enabled | xs:boolean | optional | true |  |

Source

<xs:complexType name="NoStdReferences" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BooleanBuildOption" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
ProjectIncludes Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : ProjectIncludes Complex Type

Glossary Item Box

Description

Allows defining projects and references that are common across all build target groups.
Namespace (none)

Diagram

add Element reference Element remove Element Choice Sequence ProjectIncludes Complex Type

Overview

ProjectIncludes
Allows defining projects and references that are common across all build target groups.
Sequence
Choice 0..∞
remove optional RemoveProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
reference optional ReferenceFolder Complex Type
recursive optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string
add optional AddProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
Sequence
dependsOn 0..∞ DependsUpon Complex Type

Used By

projects Element

Source

<xs:complexType name="ProjectIncludes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element minOccurs="0" maxOccurs="1" name="remove" type="RemoveProjects" />
      <xs:element minOccurs="0" maxOccurs="1" name="reference" type="ReferenceFolder" />
      <xs:element minOccurs="0" maxOccurs="1" name="add" type="AddProjects" />
    </xs:choice>
  </xs:sequence>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
ProjectReferencesToFile Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : ProjectReferencesToFile Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BooleanBuildOption Complex Type

Overview

ProjectReferencesToFile Extension of BooleanBuildOption Complex Type
enabled optional xs:boolean

Used By

force-file-references Element

Attributes

Name | Type | Use | Default | Fixed | Description
enabled | xs:boolean | optional | true |  |

Source

<xs:complexType name="ProjectReferencesToFile" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BooleanBuildOption" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
ReferenceFolder Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : ReferenceFolder Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Overview

ReferenceFolder Extension of BaseFileItem Complex Type
recursive optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

reference Element
reference Element

Attributes

Name | Type | Use | Default | Fixed | Description
recursive | xs:boolean | optional | false |  |
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="ReferenceFolder" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem">
      <xs:attribute default="false" name="recursive" type="xs:boolean" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
RemoveProjects Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : RemoveProjects Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileItem Complex Type

Overview

RemoveProjects Extension of BaseFileItem Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

remove Element
remove Element

Attributes

Name | Type | Use | Default | Fixed | Description
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="RemoveProjects" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileItem" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
SaveProjectChanges Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : SaveProjectChanges Complex Type

Glossary Item Box

Namespace (none)

Overview

SaveProjectChanges
enabled required xs:boolean
level optional TraceLevel Simple Type

Used By

save-project-changes Element
save-project-changes Element

Attributes

Name | Type | Use | Default | Fixed | Description
enabled | xs:boolean | required |  |  |
level | TraceLevel Simple Type | optional | Warning |  |

Source

<xs:complexType name="SaveProjectChanges" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="enabled" type="xs:boolean" use="required" />
  <xs:attribute default="Warning" name="level" type="TraceLevel" />
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
TargetFramework Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : TargetFramework Complex Type

Glossary Item Box

Namespace (none)

Overview

TargetFramework
version required FrameworkVersions Simple Type

Used By

framework Element

Attributes

Name | Type | Use | Default | Fixed | Description
version | FrameworkVersions Simple Type | required |  |  |

Source

<xs:complexType name="TargetFramework" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="version" type="FrameworkVersions" use="required" />
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
XmlFileOutput Complex Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : XmlFileOutput Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of BaseFileOutput Complex Type

Overview

XmlFileOutput Extension of BaseFileOutput Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string

Used By

xml Element

Attributes

Name | Type | Use | Default | Fixed | Description
level | LoggerVerbosity Simple Type | required |  |  |
file | xs:string | optional |  |  |
relative-to | OutputRelative Simple Type | optional | csbuild.exe |  |
path | xs:string | optional |  |  |

Source

<xs:complexType name="XmlFileOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="BaseFileOutput" />
  </xs:complexContent>
</xs:complexType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
BuildPlatforms Simple Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : BuildPlatforms Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

BuildPlatforms Restriction of xs:string

Facets

Enumeration | AnyCPU
Enumeration | x86
Enumeration | Itanium
Enumeration | x64

Source

<xs:simpleType name="BuildPlatforms" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:enumeration value="AnyCPU" />
    <xs:enumeration value="x86" />
    <xs:enumeration value="Itanium" />
    <xs:enumeration value="x64" />
  </xs:restriction>
</xs:simpleType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
FrameworkVersions Simple Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : FrameworkVersions Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

FrameworkVersions Restriction of xs:string

Facets

Enumeration | v2.0
Enumeration | v3.0
Enumeration | v3.5
Enumeration | v4.0
Enumeration | v4.5

Source

<xs:simpleType name="FrameworkVersions" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:enumeration value="v2.0" />
    <xs:enumeration value="v3.0" />
    <xs:enumeration value="v3.5" />
    <xs:enumeration value="v4.0" />
    <xs:enumeration value="v4.5" />
  </xs:restriction>
</xs:simpleType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
LoggerVerbosity Simple Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : LoggerVerbosity Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

LoggerVerbosity Restriction of xs:string

Facets

Enumeration | Quiet
Enumeration | Minimal
Enumeration | Normal
Enumeration | Detailed
Enumeration | Diagnostic

Source

<xs:simpleType name="LoggerVerbosity" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:enumeration value="Quiet" />
    <xs:enumeration value="Minimal" />
    <xs:enumeration value="Normal" />
    <xs:enumeration value="Detailed" />
    <xs:enumeration value="Diagnostic" />
  </xs:restriction>
</xs:simpleType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
OutputRelative Simple Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : OutputRelative Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

OutputRelative Restriction of xs:string

Facets

Enumeration | none
Enumeration | absolute-path
Enumeration | csbuild.exe
Enumeration | working-folder

Source

<xs:simpleType name="OutputRelative" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:enumeration value="none" />
    <xs:enumeration value="absolute-path" />
    <xs:enumeration value="csbuild.exe" />
    <xs:enumeration value="working-folder" />
  </xs:restriction>
</xs:simpleType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
TraceLevel Simple Type
See Also Send Feedback Download Help File
CSBuild.xsd Schema : TraceLevel Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

TraceLevel Restriction of xs:string

Facets

Enumeration | Off
Enumeration | Error
Enumeration | Warning
Enumeration | Info
Enumeration | Verbose

Source

<xs:simpleType name="TraceLevel" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:enumeration value="Off" />
    <xs:enumeration value="Error" />
    <xs:enumeration value="Warning" />
    <xs:enumeration value="Info" />
    <xs:enumeration value="Verbose" />
  </xs:restriction>
</xs:simpleType>

See Also

CSBuild.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
TunnelConfig Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : TunnelConfig Element

Glossary Item Box

Namespace (none)

Type

TunnelConfig Complex Type

Diagram

listener Element demultiplexer Element multiplexer Element Choice Sequence TunnelConfig Element

Overview

TunnelConfig TunnelConfig Complex Type
Sequence
Choice 0..∞
multiplexer optional TunnelMultiplexer Complex Type
ip optional xs:string
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
add 0..∞ AddPort Complex Type
target optional TunnelSender Complex Type
demultiplexer optional TunnelDemultiplexer Complex Type
ip optional xs:string
port required xs:int
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
target 0..∞ TunnelSenderFromPort Complex Type
listener optional TunnelListener Complex Type
ip optional xs:string
port required xs:int
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
target optional TunnelSender Complex Type

Source

<xs:element name="TunnelConfig" nillable="true" type="TunnelConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
AddPort Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : AddPort Complex Type

Glossary Item Box

Namespace (none)

Overview

AddPort
port required xs:int

Used By

add Element

Attributes

Name | Type | Use | Default | Fixed | Description
port | xs:int | required |  |  |

Source

<xs:complexType name="AddPort" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="port" type="xs:int" use="required" />
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
ExpectedCertificate Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : ExpectedCertificate Complex Type

Glossary Item Box

Namespace (none)

Overview

ExpectedCertificate
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Used By

accept Element
accept Element
accept Element
expect Element
expect Element
accept Element

Attributes

Name | Type | Use | Default | Fixed | Description
issuedTo | xs:string | optional |  |  |
hash | xs:string | optional |  |  |
publicKey | xs:string | optional |  |  |
ignoreErrors | IgnorePolicyErrors Simple Type | optional | None |  |

Source

<xs:complexType name="ExpectedCertificate" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:attribute name="issuedTo" type="xs:string" />
  <xs:attribute name="hash" type="xs:string" />
  <xs:attribute name="publicKey" type="xs:string" />
  <xs:attribute default="None" name="ignoreErrors" type="IgnorePolicyErrors" />
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
TunnelConfig Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : TunnelConfig Complex Type

Glossary Item Box

Namespace (none)

Diagram

listener Element demultiplexer Element multiplexer Element Choice Sequence TunnelConfig Complex Type

Overview

TunnelConfig
Sequence
Choice 0..∞
multiplexer optional TunnelMultiplexer Complex Type
ip optional xs:string
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
add 0..∞ AddPort Complex Type
target optional TunnelSender Complex Type
demultiplexer optional TunnelDemultiplexer Complex Type
ip optional xs:string
port required xs:int
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
target 0..∞ TunnelSenderFromPort Complex Type
listener optional TunnelListener Complex Type
ip optional xs:string
port required xs:int
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
target optional TunnelSender Complex Type

Used By

TunnelConfig Element

Source

<xs:complexType name="TunnelConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element minOccurs="0" maxOccurs="1" name="multiplexer" type="TunnelMultiplexer" />
      <xs:element minOccurs="0" maxOccurs="1" name="demultiplexer" type="TunnelDemultiplexer" />
      <xs:element minOccurs="0" maxOccurs="1" name="listener" type="TunnelListener" />
    </xs:choice>
  </xs:sequence>
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
TunnelDemultiplexer Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : TunnelDemultiplexer Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of TunnelListenerBase Complex Type

Diagram

Sequence target Element accept Element Sequence TunnelDemultiplexer Complex Type

Overview

TunnelDemultiplexer Extension of TunnelListenerBase Complex Type
ip optional xs:string
port required xs:int
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type
target 0..∞ TunnelSenderFromPort Complex Type
forwardingPort required xs:int
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type

Used By

demultiplexer Element

Attributes

Name | Type | Use | Default | Fixed | Description
ip | xs:string | optional |  |  |
port | xs:int | required |  |  |
serverCertFile | xs:string | optional |  |  |
serverCertPassword | xs:string | optional |  |  |
loggingDirectory | xs:string | optional |  |  |

Source

<xs:complexType name="TunnelDemultiplexer" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="TunnelListenerBase">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="target" type="TunnelSenderFromPort" />
      </xs:sequence>
      <xs:attribute name="ip" type="xs:string" />
      <xs:attribute name="port" type="xs:int" use="required" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
TunnelListener Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : TunnelListener Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of TunnelListenerBase Complex Type

Diagram

Sequence target Element accept Element Sequence TunnelListener Complex Type

Overview

TunnelListener Extension of TunnelListenerBase Complex Type
ip optional xs:string
port required xs:int
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type
target optional TunnelSender Complex Type
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type

Used By

listener Element

Attributes

Name | Type | Use | Default | Fixed | Description
ip | xs:string | optional |  |  |
port | xs:int | required |  |  |
serverCertFile | xs:string | optional |  |  |
serverCertPassword | xs:string | optional |  |  |
loggingDirectory | xs:string | optional |  |  |

Source

<xs:complexType name="TunnelListener" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="TunnelListenerBase">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="target" type="TunnelSender" />
      </xs:sequence>
      <xs:attribute name="ip" type="xs:string" />
      <xs:attribute name="port" type="xs:int" use="required" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
TunnelListenerBase Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : TunnelListenerBase Complex Type

Glossary Item Box

Namespace (none)

Diagram

accept Element Sequence TunnelListenerBase Complex Type

Overview

TunnelListenerBase
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Attributes

Name | Type | Use | Default | Fixed | Description
serverCertFile | xs:string | optional |  |  |
serverCertPassword | xs:string | optional |  |  |
loggingDirectory | xs:string | optional |  |  |

Source

<xs:complexType name="TunnelListenerBase" abstract="true" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="accept" type="ExpectedCertificate" />
  </xs:sequence>
  <xs:attribute name="serverCertFile" type="xs:string" />
  <xs:attribute name="serverCertPassword" type="xs:string" />
  <xs:attribute name="loggingDirectory" type="xs:string" />
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
TunnelMultiplexer Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : TunnelMultiplexer Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of TunnelListenerBase Complex Type

Diagram

Sequence target Element add Element accept Element Sequence TunnelMultiplexer Complex Type

Overview

TunnelMultiplexer Extension of TunnelListenerBase Complex Type
ip optional xs:string
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type
add 0..∞ AddPort Complex Type
port required xs:int
target optional TunnelSender Complex Type
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type

Used By

multiplexer Element

Attributes

Name | Type | Use | Default | Fixed | Description
ip | xs:string | optional |  |  |
serverCertFile | xs:string | optional |  |  |
serverCertPassword | xs:string | optional |  |  |
loggingDirectory | xs:string | optional |  |  |

Source

<xs:complexType name="TunnelMultiplexer" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="TunnelListenerBase">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="add" type="AddPort" />
        <xs:element minOccurs="0" maxOccurs="1" name="target" type="TunnelSender" />
      </xs:sequence>
      <xs:attribute name="ip" type="xs:string" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
TunnelSender Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : TunnelSender Complex Type

Glossary Item Box

Namespace (none)

Diagram

expect Element Sequence TunnelSender Complex Type

Overview

TunnelSender
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Used By

target Element
target Element

Attributes

Name | Type | Use | Default | Fixed | Description
ip | xs:string | optional |  |  |
port | xs:int | required |  |  |
clientCertFile | xs:string | optional |  |  |
clientCertPassword | xs:string | optional |  |  |
ssl | xs:boolean | optional | false |  |

Source

<xs:complexType name="TunnelSender" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1" name="expect" type="ExpectedCertificate" />
  </xs:sequence>
  <xs:attribute name="ip" type="xs:string" />
  <xs:attribute name="port" type="xs:int" use="required" />
  <xs:attribute name="clientCertFile" type="xs:string" />
  <xs:attribute name="clientCertPassword" type="xs:string" />
  <xs:attribute default="false" name="ssl" type="xs:boolean" />
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
TunnelSenderFromPort Complex Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : TunnelSenderFromPort Complex Type

Glossary Item Box

Namespace (none)

Base Type

Extension of TunnelSender Complex Type

Diagram

expect Element Sequence TunnelSenderFromPort Complex Type

Overview

TunnelSenderFromPort Extension of TunnelSender Complex Type
forwardingPort required xs:int
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Used By

target Element

Attributes

Name | Type | Use | Default | Fixed | Description
forwardingPort | xs:int | required |  |  |
ip | xs:string | optional |  |  |
port | xs:int | required |  |  |
clientCertFile | xs:string | optional |  |  |
clientCertPassword | xs:string | optional |  |  |
ssl | xs:boolean | optional | false |  |

Source

<xs:complexType name="TunnelSenderFromPort" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexContent mixed="false">
    <xs:extension base="TunnelSender">
      <xs:attribute name="forwardingPort" type="xs:int" use="required" />
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
IgnorePolicyErrors Simple Type
See Also Send Feedback Download Help File
SslTunnel.xsd Schema : IgnorePolicyErrors Simple Type

Glossary Item Box

Namespace (none)

Type

Restriction of xs:string

Overview

IgnorePolicyErrors Restriction of xs:string

Facets

Enumeration | None
Enumeration | NameMismatch
Enumeration | ChainErrors
Enumeration | All

Source

<xs:simpleType name="IgnorePolicyErrors" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:restriction base="xs:string">
    <xs:enumeration value="None" />
    <xs:enumeration value="NameMismatch" />
    <xs:enumeration value="ChainErrors" />
    <xs:enumeration value="All" />
  </xs:restriction>
</xs:simpleType>

See Also

SslTunnel.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
match Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > CmdToolConfig Complex Type : match Element

Glossary Item Box

Namespace (none)

Type

FileMatch Complex Type

Diagram

Sequence generator Element applies-to Element Sequence match Element

Overview

match 0..∞ FileMatch Complex Type
filespec required FileMatchPattern Simple Type
stop optional xs:boolean
Sequence
applies-to 0..∞ MatchAppliesTo Complex Type
folder required FilePathPattern Simple Type
generator 1..∞ GeneratorConfig Complex Type
debug optional xs:boolean
Sequence
Choice
script GeneratorScript Complex Type
execute GeneratorExec Complex Type
arg 0..∞ GeneratorArgument Complex Type
std-input optional GeneratorInput Complex Type
std-output optional GeneratorOutput Complex Type
output 0..∞ GeneratorOutput Complex Type

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="match" type="FileMatch" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

CmdToolConfig Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
applies-to Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > FileMatch Complex Type : applies-to Element

Glossary Item Box

Namespace (none)

Type

MatchAppliesTo Complex Type

Overview

applies-to 0..∞ MatchAppliesTo Complex Type
folder required FilePathPattern Simple Type

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="applies-to" type="MatchAppliesTo" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

FileMatch Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
generator Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > FileMatch Complex Type : generator Element

Glossary Item Box

Namespace (none)

Type

GeneratorConfig Complex Type

Diagram

output Element std-output Element std-input Element arg Element execute Element script Element Choice Sequence generator Element

Overview

generator 1..∞ GeneratorConfig Complex Type
debug optional xs:boolean
Sequence
Choice
script GeneratorScript Complex Type
type required GeneratorScriptType Simple Type
src optional FilePathPattern Simple Type
execute GeneratorExec Complex Type
exe required FilePathPattern Simple Type
arg 0..∞ GeneratorArgument Complex Type
value required xs:string
std-input optional GeneratorInput Complex Type
redirect required xs:boolean
std-output optional GeneratorOutput Complex Type
extension required xs:string
output 0..∞ GeneratorOutput Complex Type
extension required xs:string

Source

<xs:element minOccurs="1" maxOccurs="unbounded" name="generator" type="GeneratorConfig" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

FileMatch Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
arg Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > GeneratorConfig Complex Type : arg Element

Glossary Item Box

Namespace (none)

Type

GeneratorArgument Complex Type

Overview

arg 0..∞ GeneratorArgument Complex Type
value required xs:string

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="arg" type="GeneratorArgument" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

GeneratorConfig Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
output Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > GeneratorConfig Complex Type : output Element

Glossary Item Box

Namespace (none)

Type

GeneratorOutput Complex Type

Overview

output 0..∞ GeneratorOutput Complex Type
extension required xs:string

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="output" type="GeneratorOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

GeneratorConfig Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
std-input Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > GeneratorConfig Complex Type : std-input Element

Glossary Item Box

Namespace (none)

Type

GeneratorInput Complex Type

Overview

std-input optional GeneratorInput Complex Type
redirect required xs:boolean

Source

<xs:element minOccurs="0" maxOccurs="1" name="std-input" type="GeneratorInput" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

GeneratorConfig Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
std-output Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > GeneratorConfig Complex Type : std-output Element

Glossary Item Box

Namespace (none)

Type

GeneratorOutput Complex Type

Overview

std-output optional GeneratorOutput Complex Type
extension required xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="std-output" type="GeneratorOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

GeneratorConfig Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
execute Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > GeneratorConfig Complex Type : execute Element

Glossary Item Box

Namespace (none)

Type

GeneratorExec Complex Type

Overview

execute GeneratorExec Complex Type
exe required FilePathPattern Simple Type

Source

<xs:element minOccurs="1" maxOccurs="1" name="execute" type="GeneratorExec" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

GeneratorConfig Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CmdTool.xsd Schema
script Element
See Also Send Feedback Download Help File
CmdTool.xsd Schema > GeneratorConfig Complex Type : script Element

Glossary Item Box

Namespace (none)

Type

GeneratorScript Complex Type

Overview

script GeneratorScript Complex Type
type required GeneratorScriptType Simple Type
src optional FilePathPattern Simple Type

Source

<xs:element minOccurs="1" maxOccurs="1" name="script" type="GeneratorScript" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

GeneratorConfig Complex Type | CmdTool.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
dependsOn Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > AddProjects Complex Type : dependsOn Element

Glossary Item Box

Namespace (none)

Type

DependsUpon Complex Type

Overview

dependsOn 0..∞ DependsUpon Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="dependsOn" type="DependsUpon" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

AddProjects Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
console Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : console Element

Glossary Item Box

Namespace (none)

Type

ConsoleOutputLevel Complex Type

Overview

console optional ConsoleOutputLevel Complex Type
enabled optional xs:boolean
level optional LoggerVerbosity Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="console" type="ConsoleOutputLevel" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
continue-on-error Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : continue-on-error Element

Glossary Item Box

Namespace (none)

Type

BuildContinueOnError Complex Type

Overview

continue-on-error optional BuildContinueOnError Complex Type
enabled optional xs:boolean

Source

<xs:element minOccurs="0" maxOccurs="1" name="continue-on-error" type="BuildContinueOnError" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
force-file-references Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : force-file-references Element

Glossary Item Box

Namespace (none)

Type

ProjectReferencesToFile Complex Type

Overview

force-file-references optional ProjectReferencesToFile Complex Type
enabled optional xs:boolean

Source

<xs:element minOccurs="0" maxOccurs="1" name="force-file-references" type="ProjectReferencesToFile" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
global-property Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : global-property Element

Glossary Item Box

Namespace (none)

Type

BuildProperty Complex Type

Overview

global-property optional BuildProperty Complex Type
global optional xs:boolean
name optional xs:string
value optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="global-property" type="BuildProperty" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
import Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : import Element

Glossary Item Box

Namespace (none)

Type

ImportOptionsPath Complex Type

Overview

import optional ImportOptionsPath Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="import" type="ImportOptionsPath" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
logfile Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : logfile Element

Glossary Item Box

Namespace (none)

Type

LogFilePath Complex Type

Overview

logfile optional LogFilePath Complex Type
enabled optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="logfile" type="LogFilePath" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
no-standard-references Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : no-standard-references Element

Glossary Item Box

Namespace (none)

Type

NoStdReferences Complex Type

Overview

no-standard-references optional NoStdReferences Complex Type
enabled optional xs:boolean

Source

<xs:element minOccurs="0" maxOccurs="1" name="no-standard-references" type="NoStdReferences" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
save-project-changes Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : save-project-changes Element

Glossary Item Box

Namespace (none)

Type

SaveProjectChanges Complex Type

Overview

save-project-changes optional SaveProjectChanges Complex Type
enabled required xs:boolean
level optional TraceLevel Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="save-project-changes" type="SaveProjectChanges" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
strict-references Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildOptions Complex Type : strict-references Element

Glossary Item Box

Namespace (none)

Type

BuildStrictReferences Complex Type

Overview

strict-references optional BuildStrictReferences Complex Type
enabled optional xs:boolean

Source

<xs:element minOccurs="0" maxOccurs="1" name="strict-references" type="BuildStrictReferences" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildOptions Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
add Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : add Element

Glossary Item Box

Namespace (none)

Type

AddProjects Complex Type

Diagram

dependsOn Element Sequence add Element

Overview

add optional AddProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
Sequence
dependsOn 0..∞ DependsUpon Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="add" type="AddProjects" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
define Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : define Element

Glossary Item Box

Namespace (none)

Type

BuildDefineConst Complex Type

Overview

define optional BuildDefineConst Complex Type
value optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="define" type="BuildDefineConst" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
framework Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : framework Element

Glossary Item Box

Namespace (none)

Type

TargetFramework Complex Type

Overview

framework optional TargetFramework Complex Type
version required FrameworkVersions Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="framework" type="TargetFramework" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
intermediateFiles Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : intermediateFiles Element

Glossary Item Box

Namespace (none)

Type

BuildIntermediateFiles Complex Type

Overview

intermediateFiles optional BuildIntermediateFiles Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="intermediateFiles" type="BuildIntermediateFiles" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
log Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : log Element

Glossary Item Box

Namespace (none)

Type

LogFileOutput Complex Type

Overview

log optional LogFileOutput Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="log" type="LogFileOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
output Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : output Element

Glossary Item Box

Namespace (none)

Type

BuildOutput Complex Type

Overview

output optional BuildOutput Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="output" type="BuildOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
property Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : property Element

Glossary Item Box

Namespace (none)

Type

BuildProperty Complex Type

Overview

property optional BuildProperty Complex Type
global optional xs:boolean
name optional xs:string
value optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="property" type="BuildProperty" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
reference Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : reference Element

Glossary Item Box

Namespace (none)

Type

ReferenceFolder Complex Type

Overview

reference optional ReferenceFolder Complex Type
recursive optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="reference" type="ReferenceFolder" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
remove Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : remove Element

Glossary Item Box

Namespace (none)

Type

RemoveProjects Complex Type

Overview

remove optional RemoveProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="remove" type="RemoveProjects" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
save-project-changes Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : save-project-changes Element

Glossary Item Box

Namespace (none)

Type

SaveProjectChanges Complex Type

Overview

save-project-changes optional SaveProjectChanges Complex Type
enabled required xs:boolean
level optional TraceLevel Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="save-project-changes" type="SaveProjectChanges" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
xml Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > BuildTarget Complex Type : xml Element

Glossary Item Box

Namespace (none)

Type

XmlFileOutput Complex Type

Overview

xml optional XmlFileOutput Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="xml" type="XmlFileOutput" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

BuildTarget Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
options Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > CSBuildConfig Complex Type : options Element

Glossary Item Box

Namespace (none)

Type

BuildOptions Complex Type

Diagram

console Element save-project-changes Element continue-on-error Element force-file-references Element no-standard-references Element global-property Element import Element strict-references Element logfile Element Choice Sequence options Element

Overview

options optional BuildOptions Complex Type
timeout-hours optional xs:int
Sequence
Choice 0..∞
logfile optional LogFilePath Complex Type
enabled optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string
strict-references optional BuildStrictReferences Complex Type
enabled optional xs:boolean
import optional ImportOptionsPath Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
global-property optional BuildProperty Complex Type
global optional xs:boolean
name optional xs:string
value optional xs:string
no-standard-references optional NoStdReferences Complex Type
enabled optional xs:boolean
force-file-references optional ProjectReferencesToFile Complex Type
enabled optional xs:boolean
continue-on-error optional BuildContinueOnError Complex Type
enabled optional xs:boolean
save-project-changes optional SaveProjectChanges Complex Type
enabled required xs:boolean
level optional TraceLevel Simple Type
console optional ConsoleOutputLevel Complex Type
enabled optional xs:boolean
level optional LoggerVerbosity Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="options" type="BuildOptions" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

CSBuildConfig Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
projects Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > CSBuildConfig Complex Type : projects Element

Glossary Item Box

Namespace (none)

Type

ProjectIncludes Complex Type

Diagram

add Element reference Element remove Element Choice Sequence projects Element

Overview

projects optional ProjectIncludes Complex Type
Sequence
Choice 0..∞
remove optional RemoveProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
reference optional ReferenceFolder Complex Type
recursive optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string
add optional AddProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
Sequence
dependsOn 0..∞ DependsUpon Complex Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="projects" type="ProjectIncludes" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

CSBuildConfig Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
target Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > CSBuildConfig Complex Type : target Element

Glossary Item Box

Namespace (none)

Type

BuildTarget Complex Type

Diagram

log Element remove Element xml Element add Element framework Element save-project-changes Element intermediateFiles Element property Element output Element reference Element define Element Choice Sequence target Element

Overview

target optional BuildTarget Complex Type
tools optional FrameworkVersions Simple Type
group optional xs:string
platform optional BuildPlatforms Simple Type
configuration optional xs:string
Sequence
Choice 0..∞
define optional BuildDefineConst Complex Type
value optional xs:string
reference optional ReferenceFolder Complex Type
recursive optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string
output optional BuildOutput Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
property optional BuildProperty Complex Type
global optional xs:boolean
name optional xs:string
value optional xs:string
intermediateFiles optional BuildIntermediateFiles Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
save-project-changes optional SaveProjectChanges Complex Type
enabled required xs:boolean
level optional TraceLevel Simple Type
framework optional TargetFramework Complex Type
version required FrameworkVersions Simple Type
add optional AddProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
Sequence
dependsOn 0..∞ DependsUpon Complex Type
xml optional XmlFileOutput Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string
remove optional RemoveProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
log optional LogFileOutput Complex Type
level required LoggerVerbosity Simple Type
file optional xs:string
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="target" type="BuildTarget" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

CSBuildConfig Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
add Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > ProjectIncludes Complex Type : add Element

Glossary Item Box

Namespace (none)

Type

AddProjects Complex Type

Diagram

dependsOn Element Sequence add Element

Overview

add optional AddProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string
Sequence
dependsOn 0..∞ DependsUpon Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="add" type="AddProjects" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

ProjectIncludes Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
reference Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > ProjectIncludes Complex Type : reference Element

Glossary Item Box

Namespace (none)

Type

ReferenceFolder Complex Type

Overview

reference optional ReferenceFolder Complex Type
recursive optional xs:boolean
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="reference" type="ReferenceFolder" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

ProjectIncludes Complex Type | CSBuild.xsd Schema


%%LocalItemTitle%%

CSBuild.xsd Schema
remove Element
See Also Send Feedback Download Help File
CSBuild.xsd Schema > ProjectIncludes Complex Type : remove Element

Glossary Item Box

Namespace (none)

Type

RemoveProjects Complex Type

Overview

remove optional RemoveProjects Complex Type
relative-to optional OutputRelative Simple Type
path optional xs:string

Source

<xs:element minOccurs="0" maxOccurs="1" name="remove" type="RemoveProjects" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

ProjectIncludes Complex Type | CSBuild.xsd Schema


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
AssertionFailedException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : AssertionFailedException Class

Glossary Item Box

For a list of all members of this type, see AssertionFailedException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

AssertionFailedException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
BaseAssertionException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : BaseAssertionException Class

Glossary Item Box

For a list of all members of this type, see BaseAssertionException members.

Public Methods

 | Name | Description
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

BaseAssertionException Class
CSharpTest.Net Namespace


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
BaseAssertionException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : BaseAssertionException Class

Glossary Item Box

For a list of all members of this type, see BaseAssertionException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

BaseAssertionException Class
CSharpTest.Net Namespace


%%PageItemTitle%%

[image]
CSharpTest.Net
Print Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Print Method

Glossary Item Box

Prints the entire tree to the text writer

Overload List

Overload | Description
Print | Prints the entire tree to the text writer

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Validate Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : Validate Method

Glossary Item Box

Forces a top-down, depth-first, crawl of the entire tree in which every node and every link or key is checked for accuracy. Throws on error.

Overload List

Overload | Description
Validate | Forces a top-down, depth-first, crawl of the entire tree in which every node and every link or key is checked for accuracy. Throws on error.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BPlusTree<TKey,TValue> Class
BPlusTree<TKey,TValue> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
TruncateLog Method
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > TransactionLog<TKey,TValue> Class : TruncateLog Method

Glossary Item Box

Truncate the log and remove all existing entries

Overload List

Overload | Description
TruncateLog | Truncate the log and remove all existing entries

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

TransactionLog<TKey,TValue> Class
TransactionLog<TKey,TValue> Members


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Collections Namespace (CSharpTest.Net.BPlusTree) Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly : CSharpTest.Net.Collections Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BPlusTree<TKey,TValue>
CSharpTest.Net.Collections.BPlusTreeOptions<TKey,TValue>
CSharpTest.Net.Collections.BPlusTree`2.Options<TKey,TValue>
CSharpTest.Net.Collections.BPlusTree`2.OptionsV2<TKey,TValue>
CSharpTest.Net.Collections.BulkInsertOptions
CSharpTest.Net.Collections.TransactionLog<TKey,TValue>
CSharpTest.Net.Collections.TransactionLogOptions<TKey,TValue>
System.ValueType
CSharpTest.Net.Collections.TransactionToken

See Also

Reference

CSharpTest.Net.BPlusTree Assembly


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DeadlockException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : DeadlockException Class

Glossary Item Box

For a list of all members of this type, see DeadlockException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

DeadlockException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DuplicateKeyException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : DuplicateKeyException Class

Glossary Item Box

For a list of all members of this type, see DuplicateKeyException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

DuplicateKeyException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
InvalidConfigurationValueException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : InvalidConfigurationValueException Class

Glossary Item Box

For a list of all members of this type, see InvalidConfigurationValueException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | ParamName | Gets the name of the parameter that causes this exception. (Inherited from System.ArgumentException)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

InvalidConfigurationValueException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
InvalidNodeHandleException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net Namespace : InvalidNodeHandleException Class

Glossary Item Box

For a list of all members of this type, see InvalidNodeHandleException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

InvalidNodeHandleException Class
CSharpTest.Net Namespace

Source Code

BPlusTree/Resources.Designer.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net Namespace (CSharpTest.Net.BPlusTree) Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly : CSharpTest.Net Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
System.ApplicationException
System.Exception
CSharpTest.Net.BaseAssertionException
CSharpTest.Net.AssertionFailedException
CSharpTest.Net.DeadlockException
CSharpTest.Net.InvalidNodeHandleException
CSharpTest.Net.DuplicateKeyException
System.ArgumentException
System.SystemException
System.Exception
CSharpTest.Net.InvalidConfigurationValueException

See Also

Reference

CSharpTest.Net.BPlusTree Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

(Global) Namespace (CSharpTest.Net.Library) Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : (Global) Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
Check

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSection Class : Item Property

Glossary Item Box

Gets or sets a key/value pair in the collection of settings

Overload List

Overload | Description
Item | Gets or sets a key/value pair in the collection of settings

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingsSection Class
UserSettingsSection Members

Source Code

Library/AppConfig/UserSettingsSection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : Item Property

Glossary Item Box

Returns the specified collection by name if it exists, or null if not found

Overload List

Overload | Description
Item | Returns the specified collection by name if it exists, or null if not found

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingsSubSectionCollection Class
UserSettingsSubSectionCollection Members
UserSettingsSubSection

Used By

UserSettingsSubSectionCollection.CopyFrom(UserSettingsSubSectionCollection)

Source Code

Library/AppConfig/UserSettingsSubSectionCollection.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Item Property
See Also Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSection Class : Item Property

Glossary Item Box

Gets or sets a key/value pair in the collection of settings

Overload List

Overload | Description
Item | Gets or sets a key/value pair in the collection of settings

Example

Library/Library.Test/TestUserSettings.cs

C# Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NET Copy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

UserSettingsSubSection Class
UserSettingsSubSection Members

Source Code

Library/AppConfig/UserSettingsSubSection.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.AppConfig Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.AppConfig Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
System.Configuration.ConfigurationElement
CSharpTest.Net.AppConfig.UserSettingsSubSection
System.Configuration.ConfigurationElementCollection
System.Configuration.ConfigurationElement
CSharpTest.Net.AppConfig.UserSettingsSubSectionCollection
System.Configuration.ConfigurationSection
System.Configuration.ConfigurationElement
CSharpTest.Net.AppConfig.UserSettingsSection

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Comparable<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace : Comparable<T> Class

Glossary Item Box

For a list of all members of this type, see Comparable<T> members.

Protected Properties

 | Name | Description
Protected Property | HashCode | Extracts the correct hash code (Inherited from CSharpTest.Net.Bases.Equatable<T>)
Top

See Also

Reference

Comparable<T> Class
CSharpTest.Net.Bases Namespace

Source Code

Library/Bases/Comparable.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Bases Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Bases Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Disposable
CSharpTest.Net.IO.BackgroundWriter
CSharpTest.Net.IO.StreamCache
CSharpTest.Net.Bases.Equatable<T>
CSharpTest.Net.Bases.Comparable<T>
CSharpTest.Net.Crypto.Hash
CSharpTest.Net.Crypto.PasswordHash
CSharpTest.Net.Crypto.Salt
System.Collections.Generic.Comparer<T>
CSharpTest.Net.Bases.Comparable`1.EqualityComparer<T>
System.Collections.Generic.EqualityComparer<T>
CSharpTest.Net.Bases.Equatable`1.EqualityComparer<T>

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
MemberwiseClone Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : MemberwiseClone Class

Glossary Item Box

For a list of all members of this type, see MemberwiseClone members.

Public Properties

 | Name | Description
Public Property | Graph | Add or Remove instances from the object graph, by adding this.Graph[o] = o; the instance 'o' will not be duplicated. (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

See Also

Reference

MemberwiseClone Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/MemberwiseClone.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SerializerClone Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Cloning Namespace : SerializerClone Class

Glossary Item Box

For a list of all members of this type, see SerializerClone members.

Public Properties

 | Name | Description
Public Property | Graph | Add or Remove instances from the object graph, by adding this.Graph[o] = o; the instance 'o' will not be duplicated. (Inherited from CSharpTest.Net.Cloning.ObjectCloner)
Top

See Also

Reference

SerializerClone Class
CSharpTest.Net.Cloning Namespace

Source Code

Library/Cloning/SerializerClone.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Cloning Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Cloning Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Cloning.ClonableExtensions
CSharpTest.Net.Cloning.ObjectCloner
CSharpTest.Net.Cloning.MemberwiseClone
CSharpTest.Net.Cloning.SerializerClone
CSharpTest.Net.Cloning.ReferenceEqualityComparer

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
Add Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Add Method

Glossary Item Box

Adds an element with the provided value to the IList.

Overload List

Overload | Description
Add | Adds an element with the provided value to the IList.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Remove Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : Remove Method

Glossary Item Box

Removes the element with the specified value from the IList.

Overload List

Overload | Description
Remove | Removes the element with the specified value from the IList.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

BTreeList<T> Class
BTreeList<T> Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DisposingList Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DisposingList Class

Glossary Item Box

For a list of all members of this type, see DisposingList members.

Public Methods

 | Name | Description
Public Method | Add | Adds an object to the end of the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | AddRange | Adds the elements of the specified collection to the end of the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | AsReadOnly | Returns a read-only IList wrapper for the current collection. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | BinarySearch | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Clear | Removes all elements from the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Contains | Determines whether an element is in the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | ConvertAll | Converts the elements in the current List to another type, and returns a list containing the converted elements. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | CopyTo | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Dispose | Disposes of each element in the collection when the collection is disposed. (Inherited from CSharpTest.Net.Collections.DisposingList<IDisposable>)
Public Method | Exists | Determines whether the List contains elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Find | Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | FindAll | Retrieves all the elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | FindIndex | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | FindLast | Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | FindLastIndex | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | ForEach | Performs the specified action on each element of the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | GetRange | Creates a shallow copy of a range of elements in the source List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | IndexOf | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Insert | Inserts an element into the List at the specified index. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | InsertRange | Inserts the elements of a collection into the List at the specified index. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | LastIndexOf | Overloaded. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Remove | Removes the first occurrence of a specific object from the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | RemoveAll | Removes all the elements that match the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | RemoveAt | Removes the element at the specified index of the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | RemoveRange | Removes a range of elements from the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Reverse | Overloaded. Reverses the order of the elements in the entire List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | Sort | Overloaded. Sorts the elements in the entire List using the default comparer. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | ToArray | Copies the elements of the List to a new array. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | TrimExcess | Sets the capacity to the actual number of elements in the List, if that number is less than a threshold value. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Method | TrueForAll | Determines whether every element in the List matches the conditions defined by the specified predicate. (Inherited from System.Collections.Generic.List<IDisposable>)
Top

See Also

Reference

DisposingList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DisposingList Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DisposingList Class

Glossary Item Box

For a list of all members of this type, see DisposingList members.

Public Properties

 | Name | Description
Public Property | Capacity | Gets or sets the total number of elements the internal data structure can hold without resizing. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Property | Count | Gets the number of elements actually contained in the List. (Inherited from System.Collections.Generic.List<IDisposable>)
Public Property | Item | Gets or sets the element at the specified index. (Inherited from System.Collections.Generic.List<IDisposable>)
Top

See Also

Reference

DisposingList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DisposingList<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : DisposingList<T> Class

Glossary Item Box

For a list of all members of this type, see DisposingList<T> members.

Public Properties

 | Name | Description
Public Property | Capacity | Gets or sets the total number of elements the internal data structure can hold without resizing. (Inherited from System.Collections.Generic.List<T>)
Public Property | Count | Gets the number of elements actually contained in the List. (Inherited from System.Collections.Generic.List<T>)
Public Property | Item | Gets or sets the element at the specified index. (Inherited from System.Collections.Generic.List<T>)
Top

See Also

Reference

DisposingList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/DisposingList.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LListNode.LList Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList Class

Glossary Item Box

For a list of all members of this type, see LListNode.LList members.

Public Methods

 | Name | Description
Public Method | AddFirst | Adds the node to the front of the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Method | AddLast | Adds the node to the end of the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Method | Clear | Remvoes all the nodes from the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Method | GetEnumerator | Returns an enumerator that iterates through the collection. (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Method | Remove | Remvoes the node from the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Top

See Also

Reference

LListNode.LList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LListNode.LList Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList Class

Glossary Item Box

For a list of all members of this type, see LListNode.LList members.

Public Properties

 | Name | Description
Public Property | Count | Returns the number of items in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Property | First | Returns the first node in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Property | IsEmpty | Returns true if the list is empty (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Public Property | Last | Returns the last node in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode>)
Top

See Also

Reference

LListNode.LList Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LListNode.LList<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode.LList<T> Class

Glossary Item Box

For a list of all members of this type, see LListNode.LList<T> members.

Public Properties

 | Name | Description
Public Property | Count | Returns the number of items in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Property | First | Returns the first node in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Property | IsEmpty | Returns true if the list is empty (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Public Property | Last | Returns the last node in the list (Inherited from CSharpTest.Net.Collections.LListNode.LList<LListNode<T>>)
Top

See Also

Reference

LListNode.LList<T> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/LListNode.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : OrderedKeyValuePairs<TKey,TValue> Class

Glossary Item Box

For a list of all members of this type, see OrderedKeyValuePairs<TKey,TValue> members.

Public Properties

 | Name | Description
Public Property | Comparer | Gets or sets the comparer to use when ordering the items. (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
Public Property | DuplicateHandling | Gets or sets the duplicate item handling policy (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
Public Property | InMemoryLimit | Gets or sets the number of instances to keep in memory before sorting/paging to disk. (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
Public Property | Serializer | Gets or sets the serializer to use when paging to disk. (Inherited from CSharpTest.Net.Collections.OrderedEnumeration<KeyValuePair<TKey,TValue>>)
Top

See Also

Reference

OrderedKeyValuePairs<TKey,TValue> Class
CSharpTest.Net.Collections Namespace

Source Code

Library/Collections/OrderedKeyValuePairs.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Collections Namespace (CSharpTest.Net.Library) Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Collections Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Collections.BTreeDictionary<TKey,TValue>
CSharpTest.Net.Collections.BTreeList<T>
CSharpTest.Net.Collections.HashUtilities
CSharpTest.Net.Collections.KeyValueComparer<TKey,TValue>
CSharpTest.Net.Collections.LListNode
CSharpTest.Net.Collections.LListNode<T>
CSharpTest.Net.Collections.LListNode.LList<TNode>
CSharpTest.Net.Collections.LListNode`1.LList<T>
CSharpTest.Net.Collections.LListNode.LList
CSharpTest.Net.Collections.LurchTable<TKey,TValue>
CSharpTest.Net.Collections.LurchTable`2.KeyCollection<TKey,TValue>
CSharpTest.Net.Collections.LurchTable`2.ValueCollection<TKey,TValue>
CSharpTest.Net.Collections.MergeSort
CSharpTest.Net.Collections.OrderedEnumeration<T>
CSharpTest.Net.Collections.OrderedKeyValuePairs<TKey,TValue>
CSharpTest.Net.Collections.OrdinalList
CSharpTest.Net.Collections.ReadOnlyList<T>
CSharpTest.Net.Collections.SetList<T>
CSharpTest.Net.Collections.SynchronizedDictionary<TKey,TValue>
CSharpTest.Net.Collections.SynchronizedList<T>
System.Collections.Generic.List<T>
CSharpTest.Net.Collections.DisposingList<T>
CSharpTest.Net.Collections.DisposingList
System.ValueType
CSharpTest.Net.Collections.LurchTable`2.Enumerator<TKey,TValue>
CSharpTest.Net.Collections.LurchTable`2.KeyCollection.Enumerator<TKey,TValue>
CSharpTest.Net.Collections.LurchTable`2.ValueCollection.Enumerator<TKey,TValue>

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AliasNameAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : AliasNameAttribute Class

Glossary Item Box

For a list of all members of this type, see AliasNameAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

AliasNameAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
AllArgumentsAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : AllArgumentsAttribute Class

Glossary Item Box

For a list of all members of this type, see AllArgumentsAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

AllArgumentsAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
AllArgumentsAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : AllArgumentsAttribute Class

Glossary Item Box

For a list of all members of this type, see AllArgumentsAttribute members.

Public Properties

 | Name | Description
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

AllArgumentsAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ArgumentAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ArgumentAttribute Class

Glossary Item Box

For a list of all members of this type, see ArgumentAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

ArgumentAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ArgumentAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ArgumentAttribute Class

Glossary Item Box

For a list of all members of this type, see ArgumentAttribute members.

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DefaultValue | Gets/sets the default value for the option (Inherited from CSharpTest.Net.Commands.DisplayInfoAndValueAttribute)
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Top

See Also

Reference

ArgumentAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
CommandAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandAttribute Class

Glossary Item Box

For a list of all members of this type, see CommandAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

CommandAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
CommandAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandAttribute Class

Glossary Item Box

For a list of all members of this type, see CommandAttribute members.

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Top

See Also

Reference

CommandAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
CommandFilterAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : CommandFilterAttribute Class

Glossary Item Box

For a list of all members of this type, see CommandFilterAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

CommandFilterAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DisplayInfoAndValueAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DisplayInfoAndValueAttribute Class

Glossary Item Box

For a list of all members of this type, see DisplayInfoAndValueAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

DisplayInfoAndValueAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DisplayInfoAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : DisplayInfoAttribute Class

Glossary Item Box

For a list of all members of this type, see DisplayInfoAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

DisplayInfoAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HttpHeaderBindingAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpHeaderBindingAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpHeaderBindingAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpHeaderBindingAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HttpIgnoreAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpIgnoreAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpIgnoreAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpIgnoreAttribute Class
CSharpTest.Net.Commands Namespace


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HttpRequestFileAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpRequestFileAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpRequestFileAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpRequestFileAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HttpResponseFileAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpResponseFileAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpResponseFileAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpResponseFileAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HttpResponseTypeAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : HttpResponseTypeAttribute Class

Glossary Item Box

For a list of all members of this type, see HttpResponseTypeAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

HttpResponseTypeAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/HttpCommands.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
IgnoreMemberAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IgnoreMemberAttribute Class

Glossary Item Box

For a list of all members of this type, see IgnoreMemberAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

IgnoreMemberAttribute Class
CSharpTest.Net.Commands Namespace

Used By

CommandInterpreter.AddHandler(T)

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
IgnoreMemberAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : IgnoreMemberAttribute Class

Glossary Item Box

For a list of all members of this type, see IgnoreMemberAttribute members.

Public Properties

 | Name | Description
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

IgnoreMemberAttribute Class
CSharpTest.Net.Commands Namespace

Used By

CommandInterpreter.AddHandler(T)

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
InterpreterException Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : InterpreterException Class

Glossary Item Box

For a list of all members of this type, see InterpreterException members.

Public Methods

 | Name | Description
Public Method | GetBaseException | When overridden in a derived class, returns the System.Exception that is the root cause of one or more subsequent exceptions. (Inherited from System.Exception)
Public Method | GetObjectData | When overridden in a derived class, sets the System.Runtime.Serialization.SerializationInfo with information about the exception. (Inherited from System.Exception)
Public Method | GetType | Gets the runtime type of the current instance. (Inherited from System.Exception)
Top

See Also

Reference

InterpreterException Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Exceptions.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
InterpreterException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : InterpreterException Class

Glossary Item Box

For a list of all members of this type, see InterpreterException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

InterpreterException Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Exceptions.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
OptionAttribute Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : OptionAttribute Class

Glossary Item Box

For a list of all members of this type, see OptionAttribute members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

OptionAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
OptionAttribute Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : OptionAttribute Class

Glossary Item Box

For a list of all members of this type, see OptionAttribute members.

Public Properties

 | Name | Description
Public Property | AliasNames | Just the alias names (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | AllNames | Returns the name list (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | Category | Returns the Category (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DefaultValue | Gets/sets the default value for the option (Inherited from CSharpTest.Net.Commands.DisplayInfoAndValueAttribute)
Public Property | Description | Returns the Description (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | DisplayName | Returns the DisplayName (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Public Property | Visible | Returns the visibility of the command (Inherited from CSharpTest.Net.Commands.DisplayInfoAttribute)
Top

See Also

Reference

OptionAttribute Class
CSharpTest.Net.Commands Namespace

Source Code

Library/Commands/Attributes.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Commands Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Commands Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Commands.CommandInterpreter
CSharpTest.Net.Commands.ServiceCommands
CSharpTest.Net.Commands.ServiceCommands.Installation
System.ApplicationException
System.Exception
CSharpTest.Net.Commands.InterpreterException
System.Attribute
CSharpTest.Net.Commands.AliasNameAttribute
CSharpTest.Net.Commands.AllArgumentsAttribute
CSharpTest.Net.Commands.DisplayInfoAttribute
CSharpTest.Net.Commands.CommandAttribute
CSharpTest.Net.Commands.CommandFilterAttribute
CSharpTest.Net.Commands.DisplayInfoAndValueAttribute
CSharpTest.Net.Commands.ArgumentAttribute
CSharpTest.Net.Commands.OptionAttribute
CSharpTest.Net.Commands.HttpHeaderBindingAttribute
CSharpTest.Net.Commands.HttpIgnoreAttribute
CSharpTest.Net.Commands.HttpRequestFileAttribute
CSharpTest.Net.Commands.HttpResponseFileAttribute
CSharpTest.Net.Commands.HttpResponseTypeAttribute
CSharpTest.Net.Commands.IgnoreMemberAttribute

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
ModifiedRijndael Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : ModifiedRijndael Class

Glossary Item Box

For a list of all members of this type, see ModifiedRijndael members.

Protected Fields

 | Name | Description
Protected Field | BlockSizeValue | Represents the block size, in bits, of the cryptographic operation. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | FeedbackSizeValue | Represents the feedback size, in bits, of the cryptographic operation. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | IVValue | Represents the initialization vector (System.Security.Cryptography.SymmetricAlgorithm.IV) for the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | KeySizeValue | Represents the size, in bits, of the secret key used by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | KeyValue | Represents the secret key for the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | LegalBlockSizesValue | Specifies the block sizes, in bits, that are supported by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | LegalKeySizesValue | Specifies the key sizes, in bits, that are supported by the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | ModeValue | Represents the cipher mode used in the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Protected Field | PaddingValue | Represents the padding mode used in the symmetric algorithm. (Inherited from System.Security.Cryptography.SymmetricAlgorithm)
Top

See Also

Reference

ModifiedRijndael Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/ModifiedRijndael.cs

Used By

ModifiedRijndael ModifiedRijndael.Create(String)


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
PBKDF2 Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : PBKDF2 Class

Glossary Item Box

For a list of all members of this type, see PBKDF2 members.

Public Properties

 | Name | Description
Public Property | IterationCount | Gets or sets the number of iterations for the operation. (Inherited from System.Security.Cryptography.Rfc2898DeriveBytes)
Public Property | Salt | Gets or sets the key salt value for the operation. (Inherited from System.Security.Cryptography.Rfc2898DeriveBytes)
Top

See Also

Reference

PBKDF2 Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/PBKDF2.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SecureStringStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : SecureStringStream Class

Glossary Item Box

For a list of all members of this type, see SecureStringStream members.

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

SecureStringStream Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/SecureStringStream.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SecureStringStream Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SecureStringStream Class : SecureStringStream Constructor

Glossary Item Box

Overload List

Overload | Description
SecureStringStream Constructor | Creates a stream from the provided SecureString's contents, use UTF16 to decode text

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SecureStringStream Class
SecureStringStream Members


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
WhirlpoolManaged Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : WhirlpoolManaged Class

Glossary Item Box

For a list of all members of this type, see WhirlpoolManaged members.

Protected Fields

 | Name | Description
Protected Field | HashSizeValue | Represents the size, in bits, of the computed hash code. (Inherited from System.Security.Cryptography.HashAlgorithm)
Protected Field | State | Represents the state of the hash computation. (Inherited from System.Security.Cryptography.HashAlgorithm)
Top

See Also

Reference

WhirlpoolManaged Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/WhirlpoolManaged.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
WhirlpoolManaged Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : WhirlpoolManaged Class

Glossary Item Box

For a list of all members of this type, see WhirlpoolManaged members.

Public Properties

 | Name | Description
Public Property | CanReuseTransform | Gets a value indicating whether the current transform can be reused. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | CanTransformMultipleBlocks | When overridden in a derived class, gets a value indicating whether multiple blocks can be transformed. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | Hash | Gets the value of the computed hash code. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | HashSize | Gets the size, in bits, of the computed hash code. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | InputBlockSize | When overridden in a derived class, gets the input block size. (Inherited from System.Security.Cryptography.HashAlgorithm)
Public Property | OutputBlockSize | When overridden in a derived class, gets the output block size. (Inherited from System.Security.Cryptography.HashAlgorithm)
Top

See Also

Reference

WhirlpoolManaged Class
CSharpTest.Net.Crypto Namespace

Source Code

Library/Crypto/WhirlpoolManaged.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Crypto Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Crypto Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Comparable<T>
CSharpTest.Net.Bases.Equatable<T>
CSharpTest.Net.Crypto.Hash
CSharpTest.Net.Crypto.PasswordHash
CSharpTest.Net.Bases.Equatable<T>
CSharpTest.Net.Crypto.Salt
CSharpTest.Net.Crypto.AsciiEncoder
CSharpTest.Net.Crypto.BinaryComparer
CSharpTest.Net.Crypto.CryptoKey
CSharpTest.Net.Crypto.AESCryptoKey
CSharpTest.Net.Crypto.AsymmetricKey
CSharpTest.Net.Crypto.LocalHostKey
CSharpTest.Net.Crypto.RSAPublicKey
CSharpTest.Net.Crypto.RSAPrivateKey
CSharpTest.Net.Crypto.RtlProcessKey
CSharpTest.Net.Crypto.PasswordKey
CSharpTest.Net.Crypto.Password
CSharpTest.Net.Crypto.Encryption
CSharpTest.Net.Crypto.SaltedData
CSharpTest.Net.Crypto.SecureStringUtils
CSharpTest.Net.Crypto.SecureTransfer
CSharpTest.Net.Crypto.SecureTransfer.Client
CSharpTest.Net.Crypto.SecureTransfer.Server
CSharpTest.Net.IO.AggregateStream
System.IO.Stream
System.MarshalByRefObject
CSharpTest.Net.Crypto.HashStream
CSharpTest.Net.IO.MarshallingStream
CSharpTest.Net.IO.BaseStream
System.IO.Stream
System.MarshalByRefObject
CSharpTest.Net.Crypto.SecureStringStream
System.Collections.Generic.EqualityComparer<T>
CSharpTest.Net.Crypto.Password.EqualityComparer
System.EventArgs
CSharpTest.Net.Crypto.SecureTransfer.BeginTransferEventArgs
CSharpTest.Net.Crypto.SecureTransfer.BytesReceivedEventArgs
CSharpTest.Net.Crypto.SecureTransfer.CompleteTransferEventArgs
CSharpTest.Net.Crypto.SecureTransfer.DownloadBytesEventArgs
System.IO.TextReader
System.MarshalByRefObject
CSharpTest.Net.Crypto.UnicodeReader
System.Security.Cryptography.DeriveBytes
CSharpTest.Net.Crypto.HashDerivedBytes<THash>
System.Security.Cryptography.HashAlgorithm
CSharpTest.Net.Crypto.WhirlpoolManaged
System.Security.Cryptography.Rfc2898DeriveBytes
System.Security.Cryptography.DeriveBytes
CSharpTest.Net.Crypto.PBKDF2
System.Security.Cryptography.SymmetricAlgorithm
CSharpTest.Net.Crypto.ModifiedRijndael

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Data Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Data Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Data.CsvReader
CSharpTest.Net.Data.DbGuid.DbGuidComparer
System.ValueType
CSharpTest.Net.Data.DbGuid

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DebugAssertionFailedException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : DebugAssertionFailedException Class

Glossary Item Box

For a list of all members of this type, see DebugAssertionFailedException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

DebugAssertionFailedException Class
CSharpTest.Net Namespace

Source Code

Library/Resources.Designer.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
EventHandlerForActiveControl<TEventArgs> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForActiveControl<TEventArgs> Class

Glossary Item Box

For a list of all members of this type, see EventHandlerForActiveControl<TEventArgs> members.

Protected Fields

 | Name | Description
Protected Field | _control | The control who's thread we will use for the invoke (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Protected Field | _delegate | The delegate to invoke on the control (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Top

See Also

Reference

EventHandlerForActiveControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
ForcedEventHandlerForControl<TEventArgs> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : ForcedEventHandlerForControl<TEventArgs> Class

Glossary Item Box

For a list of all members of this type, see ForcedEventHandlerForControl<TEventArgs> members.

Protected Fields

 | Name | Description
Protected Field | _control | The control who's thread we will use for the invoke (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Protected Field | _delegate | The delegate to invoke on the control (Inherited from CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>)
Top

See Also

Reference

ForcedEventHandlerForControl<TEventArgs> Class
CSharpTest.Net.Delegates Namespace

Source Code

Library/Delegates/EventHandlerForControl.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Delegates Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Delegates Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Delegates.EventHandlerForControl<TEventArgs>
CSharpTest.Net.Delegates.EventHandlerForActiveControl<TEventArgs>
CSharpTest.Net.Delegates.ForcedEventHandlerForControl<TEventArgs>
CSharpTest.Net.Delegates.TimeoutAction

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Base64Stream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Base64Stream Class

Glossary Item Box

For a list of all members of this type, see Base64Stream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.CryptoStream. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | FlushFinalBlock | Updates the underlying data source or repository with the current state of the buffer, then clears the buffer. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

Base64Stream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Base64Stream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Base64Stream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Base64Stream Class

Glossary Item Box

For a list of all members of this type, see Base64Stream members.

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

Base64Stream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Base64Stream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
HexStream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexStream Class

Glossary Item Box

For a list of all members of this type, see HexStream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.CryptoStream. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | FlushFinalBlock | Updates the underlying data source or repository with the current state of the buffer, then clears the buffer. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

HexStream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HexStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : HexStream Class

Glossary Item Box

For a list of all members of this type, see HexStream members.

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

HexStream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/HexStream.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
Safe64Stream Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Stream Class

Glossary Item Box

For a list of all members of this type, see Safe64Stream members.

Public Methods

 | Name | Description
Public Method | BeginRead | Begins an asynchronous read operation. (Inherited from System.IO.Stream)
Public Method | BeginWrite | Begins an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Clear | Releases all resources used by the System.Security.Cryptography.CryptoStream. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | Close | Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. (Inherited from System.IO.Stream)
Public Method | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from System.MarshalByRefObject)
Public Method | Dispose | Overloaded. Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources. (Inherited from System.IO.Stream)
Public Method | EndRead | Waits for the pending asynchronous read to complete. (Inherited from System.IO.Stream)
Public Method | EndWrite | Ends an asynchronous write operation. (Inherited from System.IO.Stream)
Public Method | Flush | When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from System.IO.Stream)
Public Method | FlushFinalBlock | Updates the underlying data source or repository with the current state of the buffer, then clears the buffer. (Inherited from System.Security.Cryptography.CryptoStream)
Public Method | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from System.MarshalByRefObject)
Public Method | Read | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from System.IO.Stream)
Public Method | ReadByte | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Inherited from System.IO.Stream)
Public Method | Seek | When overridden in a derived class, sets the position within the current stream. (Inherited from System.IO.Stream)
Public Method | SetLength | When overridden in a derived class, sets the length of the current stream. (Inherited from System.IO.Stream)
Public Method | Write | When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from System.IO.Stream)
Public Method | WriteByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. (Inherited from System.IO.Stream)
Top

Protected Methods

 | Name | Description
Protected Method | MemberwiseClone | Overloaded. Creates a shallow copy of the current System.MarshalByRefObject object. (Inherited from System.MarshalByRefObject)
Top

See Also

Reference

Safe64Stream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Stream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
Safe64Stream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Formatting Namespace : Safe64Stream Class

Glossary Item Box

For a list of all members of this type, see Safe64Stream members.

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

Safe64Stream Class
CSharpTest.Net.Formatting Namespace

Source Code

Library/Formatting/Safe64Stream.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Formatting Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Formatting Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Formatting.Base64Stream.Transform
CSharpTest.Net.Formatting.ByteEncoding
CSharpTest.Net.Formatting.HexEncoding
CSharpTest.Net.Formatting.HexStream.Transform
CSharpTest.Net.Formatting.Safe64Encoding
CSharpTest.Net.Formatting.Safe64Stream.Transform
System.Security.Cryptography.CryptoStream
System.IO.Stream
System.MarshalByRefObject
CSharpTest.Net.Formatting.Base64Stream
CSharpTest.Net.Formatting.HexStream
CSharpTest.Net.Formatting.Safe64Stream

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
HtmlLightDocument Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : HtmlLightDocument Class

Glossary Item Box

For a list of all members of this type, see HtmlLightDocument members.

Public Fields

 | Name | Description
Public Field | Attributes | Returns the attributes of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Field | Children | Returns the children of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Field | Root | Returns the root element (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Top

Protected Fields

 | Name | Description
Protected Field | _parserStack | Stores the current node stack while parsing documents (Inherited from CSharpTest.Net.Html.XmlLightDocument)
Top

See Also

Reference

HtmlLightDocument Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
HtmlLightDocument Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : HtmlLightDocument Class

Glossary Item Box

For a list of all members of this type, see HtmlLightDocument members.

Public Properties

 | Name | Description
Public Property | ClosingTagWhitespace | Whitespace appearing before the close of the end tag (</div >) (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Document | Returns the root-level node (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | InnerText | Returns the inner text of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | InnerXml | Returns the re-constructed innerHTML in a well-formed Xml format (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsComment | Returns true if the node is a comment (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsEmpty | Returns true if the node is self-closing (i.e. ends with '/>') (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsSpecialTag | Returns true if the node is not a normal element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsText | Returns true if the node has a textual value, i.e. text or cdata (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | LocalName | Returns the name without the namespace prefix (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Namespace | Returns the namespace or empty string (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | NamespaceOrNull | Returns the namespace or null (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | NextSibling | Returns the next sibling element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | OpeningTagWhitespace | Whitespace appearing before the close of the start tag (<div >) (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | OriginalTag | Returns the text in it's original format. Where IsSpecial == true, this is used to rewrite the content. (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Parent | Returns the parent (if any) of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | PrevSibling | Returns the previous sibling element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | TagName | Returns the tag name of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Value | Returns the value (if any) of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

See Also

Reference

HtmlLightDocument Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/HtmlLightDocument.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
XmlLightDocument Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace : XmlLightDocument Class

Glossary Item Box

For a list of all members of this type, see XmlLightDocument members.

Public Properties

 | Name | Description
Public Property | ClosingTagWhitespace | Whitespace appearing before the close of the end tag (</div >) (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Document | Returns the root-level node (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | InnerText | Returns the inner text of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | InnerXml | Returns the re-constructed innerHTML in a well-formed Xml format (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsComment | Returns true if the node is a comment (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsEmpty | Returns true if the node is self-closing (i.e. ends with '/>') (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsSpecialTag | Returns true if the node is not a normal element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | IsText | Returns true if the node has a textual value, i.e. text or cdata (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | LocalName | Returns the name without the namespace prefix (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Namespace | Returns the namespace or empty string (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | NamespaceOrNull | Returns the namespace or null (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | NextSibling | Returns the next sibling element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | OpeningTagWhitespace | Whitespace appearing before the close of the start tag (<div >) (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | OriginalTag | Returns the text in it's original format. Where IsSpecial == true, this is used to rewrite the content. (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Parent | Returns the parent (if any) of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | PrevSibling | Returns the previous sibling element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | TagName | Returns the tag name of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Public Property | Value | Returns the value (if any) of this html element (Inherited from CSharpTest.Net.Html.XmlLightElement)
Top

See Also

Reference

XmlLightDocument Class
CSharpTest.Net.Html Namespace

Source Code

Library/Html/XmlLightDocument.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
XmlLightElement Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : XmlLightElement Constructor

Glossary Item Box

Overload List

Overload | Description
XmlLightElement Constructor | Creates a new xml element

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members


%%PageItemTitle%%

[image]
CSharpTest.Net
WriteText Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : WriteText Method

Glossary Item Box

Writes the text to the xml writer while preserving entities and still ensuring the remainder of the text is properly encoded.

Overload List

Overload | Description
WriteText | Writes the text to the xml writer while preserving entities and still ensuring the remainder of the text is properly encoded.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightElement Class
XmlLightElement Members


%%PageItemTitle%%

[image]
CSharpTest.Net
ParseText Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class : ParseText Method

Glossary Item Box

Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">

Overload List

Overload | Description
ParseText | Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

XmlLightParser Class
XmlLightParser Members


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Html Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Html Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Html.XhtmlValidation
CSharpTest.Net.Html.XmlLightAttributes
CSharpTest.Net.Html.XmlLightElement
CSharpTest.Net.Html.XmlLightDocument
CSharpTest.Net.Html.HtmlLightDocument
CSharpTest.Net.Html.XmlLightParser
System.ValueType
CSharpTest.Net.Html.XmlLightAttribute
CSharpTest.Net.Html.XmlTagInfo

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Http Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Http Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Http.HttpServer
CSharpTest.Net.Http.MimeMessagePart
CSharpTest.Net.Http.MimeMultiPartData
System.EventArgs
CSharpTest.Net.Http.HttpContextEventArgs

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Interfaces Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Interfaces Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Interfaces.DelegateFactory<T>
CSharpTest.Net.Interfaces.InstanceFactory<T>
CSharpTest.Net.Interfaces.NewFactory<T>
CSharpTest.Net.Interfaces.Singleton<T>

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
BackgroundWriter Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : BackgroundWriter Class

Glossary Item Box

For a list of all members of this type, see BackgroundWriter members.

Public Events

 | Name | Description
Public Event | Disposed | Raised when the object is disposed (Inherited from CSharpTest.Net.Bases.Disposable)
Top

See Also

Reference

BackgroundWriter Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/BackgroundWriter.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DisposingStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : DisposingStream Class

Glossary Item Box

For a list of all members of this type, see DisposingStream members.

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Protected Properties

 | Name | Description
Protected Property | Stream | Allows modifying the underlying stream (Inherited from CSharpTest.Net.IO.AggregateStream)
Top

See Also

Reference

DisposingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/DisposingStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
NonClosingStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : NonClosingStream Class

Glossary Item Box

For a list of all members of this type, see NonClosingStream members.

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

Protected Properties

 | Name | Description
Protected Property | Stream | Allows modifying the underlying stream (Inherited from CSharpTest.Net.IO.AggregateStream)
Top

See Also

Reference

NonClosingStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/NonClosingStream.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SharedMemoryStream Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : SharedMemoryStream Class

Glossary Item Box

For a list of all members of this type, see SharedMemoryStream members.

Public Properties

 | Name | Description
Public Property | CanRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. (Inherited from System.IO.Stream)
Public Property | CanSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. (Inherited from System.IO.Stream)
Public Property | CanTimeout | Gets a value that determines whether the current stream can time out. (Inherited from System.IO.Stream)
Public Property | CanWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. (Inherited from System.IO.Stream)
Public Property | Length | When overridden in a derived class, gets the length in bytes of the stream. (Inherited from System.IO.Stream)
Public Property | Position | When overridden in a derived class, gets or sets the position within the current stream. (Inherited from System.IO.Stream)
Public Property | ReadTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out. (Inherited from System.IO.Stream)
Public Property | WriteTimeout | Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out. (Inherited from System.IO.Stream)
Top

See Also

Reference

SharedMemoryStream Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/SharedMemoryStream.cs


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
StreamCache Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : StreamCache Class

Glossary Item Box

For a list of all members of this type, see StreamCache members.

Public Events

 | Name | Description
Public Event | Disposed | Raised when the object is disposed (Inherited from CSharpTest.Net.Bases.Disposable)
Top

See Also

Reference

StreamCache Class
CSharpTest.Net.IO Namespace

Source Code

Library/IO/StreamCache.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.IO Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.IO Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Bases.Disposable
CSharpTest.Net.IO.BackgroundWriter
CSharpTest.Net.IO.StreamCache
CSharpTest.Net.IO.FileStreamFactory
CSharpTest.Net.IO.FindFile
CSharpTest.Net.IO.FragmentedFile
CSharpTest.Net.IO.IOStream
CSharpTest.Net.IO.TcpServer
CSharpTest.Net.IO.TempDirectory
CSharpTest.Net.IO.TempFile
CSharpTest.Net.IO.ReplaceFile
CSharpTest.Net.IO.TransactFile
CSharpTest.Net.IO.TransactedCompoundFile
CSharpTest.Net.IO.TransactedCompoundFile.Options
System.EventArgs
CSharpTest.Net.IO.FindFile.FileFoundEventArgs
CSharpTest.Net.IO.TcpClientEventArgs
System.IO.Stream
System.MarshalByRefObject
CSharpTest.Net.IO.AggregateStream
CSharpTest.Net.Crypto.HashStream
CSharpTest.Net.IO.DisposingStream
CSharpTest.Net.IO.NonClosingStream
CSharpTest.Net.IO.BaseStream
CSharpTest.Net.IO.CombinedStream
CSharpTest.Net.IO.MarshallingStream
CSharpTest.Net.Crypto.SecureStringStream
CSharpTest.Net.IO.ClampedStream
CSharpTest.Net.IO.SegmentedMemoryStream
CSharpTest.Net.IO.SharedMemoryStream
System.ValueType
CSharpTest.Net.IO.Crc32
CSharpTest.Net.IO.Crc64
CSharpTest.Net.IO.FindFile.Info

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.IpcChannel Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.IpcChannel Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.IpcChannel.IpcChannelRegistrar
CSharpTest.Net.IpcChannel.IpcEvent
CSharpTest.Net.IpcChannel.IpcEventChannel
System.EventArgs
CSharpTest.Net.IpcChannel.IpcSignalEventArgs

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
LurchTableCorruptionException Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net Namespace : LurchTableCorruptionException Class

Glossary Item Box

For a list of all members of this type, see LurchTableCorruptionException members.

Public Properties

 | Name | Description
Public Property | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from System.Exception)
Public Property | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from System.Exception)
Public Property | InnerException | Gets the System.Exception instance that caused the current exception. (Inherited from System.Exception)
Public Property | Message | Gets a message that describes the current exception. (Inherited from System.Exception)
Public Property | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from System.Exception)
Public Property | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from System.Exception)
Public Property | TargetSite | Gets the method that throws the current exception. (Inherited from System.Exception)
Top

Protected Properties

 | Name | Description
Protected Property | HResult | Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from System.Exception)
Top

See Also

Reference

LurchTableCorruptionException Class
CSharpTest.Net Namespace

Source Code

Library/Resources.Designer.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Processes Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Processes Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Processes.AssemblyRunner
CSharpTest.Net.Processes.ProcessRunner
CSharpTest.Net.Processes.ScriptEngine
CSharpTest.Net.Processes.ScriptRunner
System.EventArgs
CSharpTest.Net.Processes.ProcessExitedEventArgs
CSharpTest.Net.Processes.ProcessOutputEventArgs

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ObjectSerializer Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : ObjectSerializer Class

Glossary Item Box

For a list of all members of this type, see ObjectSerializer members.

Public Properties

 | Name | Description
Public Property | ContinueOnError | Gets or sets a value that controls whether exceptions are swallowed and logged durring serialization or deserialization routines. (Inherited from CSharpTest.Net.Reflection.PropertySerializer)
Top

See Also

Reference

ObjectSerializer Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/ObjectSerializer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
PropertySerializer<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertySerializer<T> Class

Glossary Item Box

For a list of all members of this type, see PropertySerializer<T> members.

Public Properties

 | Name | Description
Public Property | ContinueOnError | Gets or sets a value that controls whether exceptions are swallowed and logged durring serialization or deserialization routines. (Inherited from CSharpTest.Net.Reflection.PropertySerializer)
Top

See Also

Reference

PropertySerializer<T> Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertySerializer.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
Deserialize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer<T> Class : Deserialize Method

Glossary Item Box

Reads all properties from the specified proeprty serialization

Overload List

Overload | Description
Deserialize | Reads all properties from the specified proeprty serialization

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer<T> Class
PropertySerializer<T> Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Serialize Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace > PropertySerializer<T> Class : Serialize Method

Glossary Item Box

Writes all properties to the specified proeprty serialization

Overload List

Overload | Description
Serialize | Writes all properties to the specified proeprty serialization

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PropertySerializer<T> Class
PropertySerializer<T> Members


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
PropertyValue<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Reflection Namespace : PropertyValue<T> Class

Glossary Item Box

For a list of all members of this type, see PropertyValue<T> members.

Public Methods

 | Name | Description
Public Method | GetCustomAttributes | Overloaded. Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes. (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | GetValue | Returns the value of the property for the specified instance (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | IsDefined | Indicates whether one or more instance of attributeType is defined on this member. (Inherited from CSharpTest.Net.Reflection.PropertyType)
Public Method | SetValue | Sets the specified value for the instance supplied (Inherited from CSharpTest.Net.Reflection.PropertyType)
Top

See Also

Reference

PropertyValue<T> Class
CSharpTest.Net.Reflection Namespace

Source Code

Library/Reflection/PropertyValue.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Reflection Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Reflection Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Reflection.PropertySerializer
CSharpTest.Net.Reflection.ObjectSerializer
CSharpTest.Net.Reflection.PropertySerializer<T>
CSharpTest.Net.Reflection.PropertyType
CSharpTest.Net.Reflection.PropertyValue
CSharpTest.Net.Reflection.PropertyValue<T>

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Serialization.StorageClasses Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Serialization.StorageClasses Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.StorageClasses.AppSettingStorage
CSharpTest.Net.Serialization.StorageClasses.UserSettingStorage
CSharpTest.Net.Serialization.StorageClasses.DictionaryStorage
CSharpTest.Net.Serialization.StorageClasses.FileStorage
CSharpTest.Net.Serialization.StorageClasses.IsolatedStorage
CSharpTest.Net.Serialization.StorageClasses.RegistryStorage

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Serialization Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Serialization Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Serialization.BytesSerializer
CSharpTest.Net.Serialization.KeyValueSerializer<TKey,TValue>
CSharpTest.Net.Serialization.LimitedSerializer
CSharpTest.Net.Serialization.PrimitiveSerializer
CSharpTest.Net.Serialization.SerializerExtensions
CSharpTest.Net.Serialization.Storage
CSharpTest.Net.Serialization.VariantNumberSerializer

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ServiceAccessEntry Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : ServiceAccessEntry Class

Glossary Item Box

For a list of all members of this type, see ServiceAccessEntry members.

Public Methods

 | Name | Description
Public Method | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from System.Attribute)
Public Method | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from System.Attribute)
Top

See Also

Reference

ServiceAccessEntry Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/ServiceAccessRights.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ServiceAccessEntry Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Services Namespace : ServiceAccessEntry Class

Glossary Item Box

For a list of all members of this type, see ServiceAccessEntry members.

Public Properties

 | Name | Description
Public Property | TypeId | When implemented in a derived class, gets a unique identifier for this System.Attribute. (Inherited from System.Attribute)
Top

See Also

Reference

ServiceAccessEntry Class
CSharpTest.Net.Services Namespace

Source Code

Library/Services/ServiceAccessRights.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Services Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Services Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Services.SvcControlManager
CSharpTest.Net.Services.SvcControlManager.NT_AUTHORITY
System.Attribute
CSharpTest.Net.Services.ServiceAccessEntry

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
DebugLockFactory Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory Class

Glossary Item Box

For a list of all members of this type, see DebugLockFactory members.

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxReaderCount | Returns the highest number of concurrent reads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count) (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalReaderCount | Returns the total number of read locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalWriterCount | Returns the total number of write locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Top

See Also

Reference

DebugLockFactory Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
DebugLockFactory<T> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory<T> Class

Glossary Item Box

For a list of all members of this type, see DebugLockFactory<T> members.

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxReaderCount | Returns the highest number of concurrent reads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count) (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalReaderCount | Returns the total number of read locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalWriterCount | Returns the total number of write locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Top

See Also

Reference

DebugLockFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DebugLockFactory<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory<T> Class

Glossary Item Box

For a list of all members of this type, see DebugLockFactory<T> members.

Public Methods

 | Name | Description
Public Method | Create | Constructs the lock wrapped in a DebugLocking instance (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Method | GlobalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by any thread (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Method | LocalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by this thread (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Top

See Also

Reference

DebugLockFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DebugLockFactory<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLockFactory<T> Class

Glossary Item Box

For a list of all members of this type, see DebugLockFactory<T> members.

Public Properties

 | Name | Description
Public Property | CaptureStack | Toggle if the entire stack is captured on lock aquisition/release for newly created locks (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | ConcurrentReads | Toggle if reads are allowed even if write lock was acquired (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LimitNestedReaders | Reader nesting limit for newly created locks (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LimitNestedWriters | Writer nesting limit for newly created locks (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LimitTimeout | Timeout limit for newly created locks (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LocalReaderCount | Returns the total number of current readers for this thread (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Public Property | LocalWriterCount | Returns the total number of current writers for this thread (Inherited from CSharpTest.Net.Synchronization.DebugLockFactory)
Top

See Also

Reference

DebugLockFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLockFactory.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
DebugLocking<T> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking<T> Class

Glossary Item Box

For a list of all members of this type, see DebugLocking<T> members.

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | MaxReaderCount | Returns the highest number of concurrent reads (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count) (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | TotalReaderCount | Returns the total number of read locks acquired (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Field | TotalWriterCount | Returns the total number of write locks acquired (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Top

See Also

Reference

DebugLocking<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
DebugLocking<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking<T> Class

Glossary Item Box

For a list of all members of this type, see DebugLocking<T> members.

Public Methods

 | Name | Description
Public Method | Dispose | Disposes of this lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | ReleaseRead | Releases a read lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | ReleaseWrite | Releases a writer lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | TryWrite | Returns true if the lock was successfully obtained within the timeout specified (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Method | Write | Overloaded. Returns a read and write lock (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Top

See Also

Reference

DebugLocking<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
DebugLocking<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : DebugLocking<T> Class

Glossary Item Box

For a list of all members of this type, see DebugLocking<T> members.

Public Properties

 | Name | Description
Public Property | CaptureStack | Capture the stack on every lock aquisition and release (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Property | LocalReaderCount | Returns the total number of current readers for this thread (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Property | LocalWriterCount | Returns the total number of current writers for this thread (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued. (Inherited from CSharpTest.Net.Synchronization.DebugLocking)
Top

See Also

Reference

DebugLocking<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/DebugLocking.cs


%%PageItemTitle%% $$Fields$$

[image]
CSharpTest.Net
LockCounterFactory<T> Class Fields
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockCounterFactory<T> Class

Glossary Item Box

For a list of all members of this type, see LockCounterFactory<T> members.

Public Fields

 | Name | Description
Public Field | CurrentReaderCount | Returns the total number of current readers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | CurrentWriterCount | Returns the total number of current writers for all threads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxReaderCount | Returns the highest number of concurrent reads (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | MaxWriterCount | Returns the highest number of concurrent writes (aka max recursive count) (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalReaderCount | Returns the total number of read locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Field | TotalWriterCount | Returns the total number of write locks acquired (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Top

See Also

Reference

LockCounterFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
LockCounterFactory<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : LockCounterFactory<T> Class

Glossary Item Box

For a list of all members of this type, see LockCounterFactory<T> members.

Public Methods

 | Name | Description
Public Method | Create | Constructs the lock wrapped in a DebugLocking instance (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Public Method | GlobalAssertNoLocks | Asserts that none of the locks handed out are currently locked for read or write by any thread (Inherited from CSharpTest.Net.Synchronization.LockCounterFactory)
Top

See Also

Reference

LockCounterFactory<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/LockCounterFactory.cs


%%PageItemTitle%% $$Methods$$

[image]
CSharpTest.Net
ReservedWriteLocking<T> Class Methods
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReservedWriteLocking<T> Class

Glossary Item Box

For a list of all members of this type, see ReservedWriteLocking<T> members.

Public Methods

 | Name | Description
Public Method | Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | Read | Overloaded. Returns a reader lock that can be elevated to a write lock (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | ReleaseRead | Releases a read lock (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | ReleaseWrite | Releases a writer lock (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | TryRead | Returns true if the lock was successfully obtained within the timeout specified (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | TryWrite | The first call reserves the Write lock for the current thread but does not stop reader access until the write lock is acquired again. (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Public Method | Write | Overloaded. Returns a read and write lock (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Top

See Also

Reference

ReservedWriteLocking<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
ReservedWriteLocking<T> Class Properties
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace : ReservedWriteLocking<T> Class

Glossary Item Box

For a list of all members of this type, see ReservedWriteLocking<T> members.

Public Properties

 | Name | Description
Public Property | WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued. (Inherited from CSharpTest.Net.Synchronization.ReservedWriteLocking)
Top

See Also

Reference

ReservedWriteLocking<T> Class
CSharpTest.Net.Synchronization Namespace

Source Code

Library/Synchronization/ReservedWriteLocking.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Synchronization Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Synchronization Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Synchronization.DebugLocking
CSharpTest.Net.Synchronization.DebugLocking<T>
CSharpTest.Net.Synchronization.ExclusiveLocking
CSharpTest.Net.Synchronization.IgnoreLockFactory
CSharpTest.Net.Synchronization.IgnoreLocking
CSharpTest.Net.Synchronization.LockCounterFactory
CSharpTest.Net.Synchronization.DebugLockFactory
CSharpTest.Net.Synchronization.DebugLockFactory<T>
CSharpTest.Net.Synchronization.LockCounterFactory<T>
CSharpTest.Net.Synchronization.LockFactory<T>
CSharpTest.Net.Synchronization.MutexLock
CSharpTest.Net.Synchronization.ReaderWriterLocking
CSharpTest.Net.Synchronization.ReservedWriteLocking
CSharpTest.Net.Synchronization.ReservedWriteLocking<T>
CSharpTest.Net.Synchronization.SimpleReadWriteLocking
CSharpTest.Net.Synchronization.WriterOnlyLocking
System.ValueType
CSharpTest.Net.Synchronization.ReadLock
CSharpTest.Net.Synchronization.SafeLock
CSharpTest.Net.Synchronization.SafeLock<TException>
CSharpTest.Net.Synchronization.WriteLock

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
WorkQueue Class Events
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace : WorkQueue Class

Glossary Item Box

For a list of all members of this type, see WorkQueue members.

Public Events

 | Name | Description
Public Event | OnError | Raised when a task fails to handle an error (Inherited from CSharpTest.Net.Threading.WorkQueue<Action>)
Top

See Also

Reference

WorkQueue Class
CSharpTest.Net.Threading Namespace

Source Code

Library/Threading/WorkQueue.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Threading Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Threading Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Threading.CallsPerSecondCounter
CSharpTest.Net.Threading.UsageCounter
CSharpTest.Net.Threading.WaitAndContinueList
CSharpTest.Net.Threading.WaitAndContinueWorker
CSharpTest.Net.Threading.WorkQueue<T>
CSharpTest.Net.Threading.WorkQueue

See Also

Reference

CSharpTest.Net.Library Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
ArgumentList.Item Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ArgumentList.Item Class : ArgumentList.Item Constructor

Glossary Item Box

Overload List

Overload | Description
ArgumentList.Item Constructor | Constructs an item for the name and values provided.

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ArgumentList.Item Class
ArgumentList.Item Members


%%PageItemTitle%%

[image]
CSharpTest.Net
Tick Method
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class : Tick Method

Glossary Item Box

Can be called periodically by external threads to ensure cleanup instead of depending upon calls to Add()

Overload List

Overload | Description
Tick | Can be called periodically by external threads to ensure cleanup instead of depending upon calls to Add()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

ObjectKeepAlive Class
ObjectKeepAlive Members


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Utils Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.Utils Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Utils.FileUtils
CSharpTest.Net.Utils.ObjectKeepAlive
CSharpTest.Net.Utils.ProcessInfo
CSharpTest.Net.Utils.RegexPatterns
CSharpTest.Net.Utils.StringConverter
CSharpTest.Net.Utils.StringUtils
System.Collections.ObjectModel.Collection<T>
CSharpTest.Net.Utils.ArgumentList.Item
System.Collections.ObjectModel.KeyedCollection<TKey,TItem>
System.Collections.ObjectModel.Collection<T>
CSharpTest.Net.Utils.ArgumentList
CSharpTest.Net.Utils.FileList
System.Configuration.ConfigurationSection
System.Configuration.ConfigurationElement
CSharpTest.Net.Utils.XmlConfiguration<T>
System.EventArgs
CSharpTest.Net.Utils.FileList.FileFoundEventArgs
System.WeakReference
CSharpTest.Net.Utils.WeakReference<T>

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.WinForms Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net.WinForms Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.WinForms.Win32Window

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net Namespace (CSharpTest.Net.Library) Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Library Assembly : CSharpTest.Net Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Constants
System.ApplicationException
System.Exception
CSharpTest.Net.DebugAssertionFailedException
CSharpTest.Net.LurchTableCorruptionException

See Also

Reference

CSharpTest.Net.Library Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

(Global) Namespace (CSharpTest.Net.Logging) Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly : (Global) Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
Log
Log.Config

See Also

Reference

CSharpTest.Net.Logging Assembly


%%PageItemTitle%%

[image]
CSharpTest.Net
EventData Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > EventData Class : EventData Constructor

Glossary Item Box

Overload List

Overload | Description
EventData Constructor | /// Serialization Constructor for ISerializable ///

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

EventData Class
EventData Members


%%PageItemTitle%%

[image]
CSharpTest.Net
LogEventArgs Constructor
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly > CSharpTest.Net.Logging Namespace > LogEventArgs Class : LogEventArgs Constructor

Glossary Item Box

Overload List

Overload | Description
LogEventArgs Constructor | /// Serialization Constructor for ISerializable ///

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

LogEventArgs Class
LogEventArgs Members


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.Logging Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.Logging Assembly : CSharpTest.Net.Logging Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.Logging.EventData
System.EventArgs
CSharpTest.Net.Logging.LogEventArgs

See Also

Reference

CSharpTest.Net.Logging Assembly


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.RpcLibrary Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
CSharpTest.Net.RpcLibrary Assembly : CSharpTest.Net.RpcLibrary Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.RpcLibrary.RpcClientApi
CSharpTest.Net.RpcLibrary.RpcServerApi
System.ComponentModel.Win32Exception
System.Runtime.InteropServices.ExternalException
System.SystemException
System.Exception
CSharpTest.Net.RpcLibrary.RpcException

See Also

Reference

CSharpTest.Net.RpcLibrary Assembly


%%ItemTitle%%

License
See Also Send Feedback Download Help File

Glossary Item Box

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/
   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
   1. Definitions.
      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.
      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.
      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.
      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.
      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.
      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.
      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).
      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.
      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."
      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.
   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.
   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.
   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:
      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and
      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and
      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and
      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.
      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.
   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.
   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.
   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.
   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.
   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.
   END OF TERMS AND CONDITIONS
   APPENDIX: How to apply the Apache License to your work.
      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.
   Copyright [yyyy] [name of copyright owner]
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

See Also

http://www.apache.org/licenses/LICENSE-2.0


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
SslClient Class Properties
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslClient Class

Glossary Item Box

For a list of all members of this type, see SslClient members.

Public Properties

 | Name | Description
Public Property | Client | Returns the underlying client soket after a call to Connect() (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Public Property | ServerName | Returns the server name that this client connects to (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Public Property | ServerPort | Returns the port that this client connects to (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Public Property | Stream | Returns the network stream after a call to Connect() (Inherited from CSharpTest.Net.SslTunnel.TcpClient)
Top

See Also

Reference

SslClient Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslClient.cs


%%PageItemTitle%%

[image]
CSharpTest.Net
SslClient Constructor
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace > SslClient Class : SslClient Constructor

Glossary Item Box

Overload List

Overload | Description
SslClient Constructor | Creates the client with the specified client certificiate and the expected server information

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

SslClient Class
SslClient Members


%%PageItemTitle%% $$Events$$

[image]
CSharpTest.Net
SslServer Class Events
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : SslServer Class

Glossary Item Box

For a list of all members of this type, see SslServer members.

Public Events

 | Name | Description
Public Event | Connected | Raised when a client establishes a connection. (Inherited from CSharpTest.Net.SslTunnel.TcpServer)
Top

See Also

Reference

SslServer Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/SslServer.cs


%%PageItemTitle%% $$Properties$$

[image]
CSharpTest.Net
TunnelSenderFromPort Class Properties
See Also Send Feedback Download Help File
SslTunnel.Library Assembly > CSharpTest.Net.SslTunnel Namespace : TunnelSenderFromPort Class

Glossary Item Box

For a list of all members of this type, see TunnelSenderFromPort members.

Public Properties

 | Name | Description
Public Property | UseSsl | (Inherited from CSharpTest.Net.SslTunnel.TunnelSender)
Top

See Also

Reference

TunnelSenderFromPort Class
CSharpTest.Net.SslTunnel Namespace

Source Code

SslTunnel/Library/TunnelConfig.cs


%%ItemTitle%% $$INHERITANCE_HIERARCHY$$

CSharpTest.Net.SslTunnel Namespace Inheritance Hierarchy
See Also Send Feedback Download Help File
SslTunnel.Library Assembly : CSharpTest.Net.SslTunnel Namespace

Glossary Item Box

Inheritance Hierarchy

System.Object
CSharpTest.Net.SslTunnel.AddPort
CSharpTest.Net.SslTunnel.ExpectedCertificate
CSharpTest.Net.SslTunnel.SslCertValidator
CSharpTest.Net.SslTunnel.StreamRedirect
CSharpTest.Net.SslTunnel.TcpClient
CSharpTest.Net.SslTunnel.SslClient
CSharpTest.Net.SslTunnel.TcpForwardingBase
CSharpTest.Net.SslTunnel.TcpRedirector
CSharpTest.Net.SslTunnel.TcpServer
CSharpTest.Net.SslTunnel.SslServer
CSharpTest.Net.SslTunnel.TcpSettings
CSharpTest.Net.SslTunnel.TunnelConfig
CSharpTest.Net.SslTunnel.TunnelListenerBase
CSharpTest.Net.SslTunnel.TunnelDemultiplexer
CSharpTest.Net.SslTunnel.TunnelListener
CSharpTest.Net.SslTunnel.TunnelMultiplexer
CSharpTest.Net.SslTunnel.TunnelSender
CSharpTest.Net.SslTunnel.TunnelSenderFromPort
System.EventArgs
CSharpTest.Net.SslTunnel.TcpServer.ConnectedEventArgs

See Also

Reference

SslTunnel.Library Assembly


%%LocalItemTitle%%

SslTunnel.xsd Schema
demultiplexer Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelConfig Complex Type : demultiplexer Element

Glossary Item Box

Namespace (none)

Type

TunnelDemultiplexer Complex Type

Diagram

Sequence target Element accept Element Sequence demultiplexer Element

Overview

demultiplexer optional TunnelDemultiplexer Complex Type
ip optional xs:string
port required xs:int
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type
target 0..∞ TunnelSenderFromPort Complex Type
forwardingPort required xs:int
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="demultiplexer" type="TunnelDemultiplexer" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelConfig Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
listener Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelConfig Complex Type : listener Element

Glossary Item Box

Namespace (none)

Type

TunnelListener Complex Type

Diagram

Sequence target Element accept Element Sequence listener Element

Overview

listener optional TunnelListener Complex Type
ip optional xs:string
port required xs:int
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type
target optional TunnelSender Complex Type
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="listener" type="TunnelListener" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelConfig Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
multiplexer Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelConfig Complex Type : multiplexer Element

Glossary Item Box

Namespace (none)

Type

TunnelMultiplexer Complex Type

Diagram

Sequence target Element add Element accept Element Sequence multiplexer Element

Overview

multiplexer optional TunnelMultiplexer Complex Type
ip optional xs:string
serverCertFile optional xs:string
serverCertPassword optional xs:string
loggingDirectory optional xs:string
Sequence
accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type
add 0..∞ AddPort Complex Type
port required xs:int
target optional TunnelSender Complex Type
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="multiplexer" type="TunnelMultiplexer" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelConfig Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
accept Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelDemultiplexer Complex Type : accept Element

Glossary Item Box

Namespace (none)

Type

ExpectedCertificate Complex Type

Overview

accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="accept" type="ExpectedCertificate" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelDemultiplexer Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
target Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelDemultiplexer Complex Type : target Element

Glossary Item Box

Namespace (none)

Type

TunnelSenderFromPort Complex Type

Diagram

expect Element Sequence target Element

Overview

target 0..∞ TunnelSenderFromPort Complex Type
forwardingPort required xs:int
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="target" type="TunnelSenderFromPort" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelDemultiplexer Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
accept Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelListenerBase Complex Type : accept Element

Glossary Item Box

Namespace (none)

Type

ExpectedCertificate Complex Type

Overview

accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="accept" type="ExpectedCertificate" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelListenerBase Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
accept Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelListener Complex Type : accept Element

Glossary Item Box

Namespace (none)

Type

ExpectedCertificate Complex Type

Overview

accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="accept" type="ExpectedCertificate" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelListener Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
target Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelListener Complex Type : target Element

Glossary Item Box

Namespace (none)

Type

TunnelSender Complex Type

Diagram

expect Element Sequence target Element

Overview

target optional TunnelSender Complex Type
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="target" type="TunnelSender" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelListener Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
accept Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelMultiplexer Complex Type : accept Element

Glossary Item Box

Namespace (none)

Type

ExpectedCertificate Complex Type

Overview

accept 0..∞ ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="accept" type="ExpectedCertificate" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelMultiplexer Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
add Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelMultiplexer Complex Type : add Element

Glossary Item Box

Namespace (none)

Type

AddPort Complex Type

Overview

add 0..∞ AddPort Complex Type
port required xs:int

Source

<xs:element minOccurs="0" maxOccurs="unbounded" name="add" type="AddPort" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelMultiplexer Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
target Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelMultiplexer Complex Type : target Element

Glossary Item Box

Namespace (none)

Type

TunnelSender Complex Type

Diagram

expect Element Sequence target Element

Overview

target optional TunnelSender Complex Type
ip optional xs:string
port required xs:int
clientCertFile optional xs:string
clientCertPassword optional xs:string
ssl optional xs:boolean
Sequence
expect optional ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="target" type="TunnelSender" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelMultiplexer Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
expect Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelSenderFromPort Complex Type : expect Element

Glossary Item Box

Namespace (none)

Type

ExpectedCertificate Complex Type

Overview

expect optional ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="expect" type="ExpectedCertificate" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelSenderFromPort Complex Type | SslTunnel.xsd Schema


%%LocalItemTitle%%

SslTunnel.xsd Schema
expect Element
See Also Send Feedback Download Help File
SslTunnel.xsd Schema > TunnelSender Complex Type : expect Element

Glossary Item Box

Namespace (none)

Type

ExpectedCertificate Complex Type

Overview

expect optional ExpectedCertificate Complex Type
issuedTo optional xs:string
hash optional xs:string
publicKey optional xs:string
ignoreErrors optional IgnorePolicyErrors Simple Type

Source

<xs:element minOccurs="0" maxOccurs="1" name="expect" type="ExpectedCertificate" xmlns:xs="http://www.w3.org/2001/XMLSchema" />

See Also

TunnelSender Complex Type | SslTunnel.xsd Schema