Home > Articles > Programming > C#

  • Print
  • + Share This
Like this article? We recommend

C# Code

Listing 2 illustrates a C# file called LspTypes.cs.

Listing 2 The LSP class.

namespace LspEvents
{
public class Lsp
{
public delegate void LspEventHandler(string msg);
// The Lsp can send the following events:
public event LspEventHandler FullyCongested;
public event LspEventHandler GettingCongested;
public event LspEventHandler CannotForwardData;
// Internal state data.
private string LspName;
private int SourceNode;
private int DestinationNode;
private int MaximumBandwidth; // units: megabits per second
private string PathElements;
bool LspCanForwardData;
private int _requiredBandwidth;
public int RequiredBandwidth
{
get { return _requiredBandwidth; }
set { _requiredBandwidth = value; }
}

public Lsp()
{
}

public Lsp(string lspName, int sourceNode, int destinationNode,
string path, int requiredBandwidth, int maximumBandwidth)
{
#region Constructor
#endregion
}

public void ForwardSomeData(int requiredBandwidth)
{
#region Use the LSP
#endregion
}
}
}

The Lsp class in Listing 2 includes the following definitions:

  • An event handler
  • Three domain-specific events
  • State data that describes the internal state of the LSP
  • A property for describing the required bandwidth
  • Two constructors
  • A service method for forwarding data

Notice also in Listing 2 the two methods Lsp() and ForwardSomeData(). Inside these methods, you can see that the text is just #region and #endregion, with some text in between. This is a neat feature of SharpDevelop that lets you collapse any code that’s not immediately relevant. To the left of the #region tags are buttons that allow you to expand the contained code. This feature allows me to present Listing 2 in a more condensed fashion.

  • + Share This
  • 🔖 Save To Your Account