Guest User

Untitled

a guest
Dec 17th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.74 KB | None | 0 0
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Modified : 17-December-2015
  4. ' ***********************************************************************
  5.  
  6. #Region " Imports "
  7.  
  8. Imports System
  9. Imports System.ComponentModel
  10. Imports System.Diagnostics
  11. Imports System.Linq
  12.  
  13. #End Region
  14.  
  15. #Region " INI Key "
  16.  
  17. Namespace Types
  18.  
  19.     ''' ----------------------------------------------------------------------------------------------------
  20.     ''' <summary>
  21.     ''' Represents a initialization file (INI) key.
  22.     ''' </summary>
  23.     ''' ----------------------------------------------------------------------------------------------------
  24.     Public NotInheritable Class IniKey
  25.  
  26. #Region " Properties "
  27.  
  28.         ''' ----------------------------------------------------------------------------------------------------
  29.         ''' <summary>
  30.         ''' Gets or sets the key name.
  31.         ''' </summary>
  32.         ''' ----------------------------------------------------------------------------------------------------
  33.         ''' <value>
  34.         ''' The key name.
  35.         ''' </value>
  36.         ''' ----------------------------------------------------------------------------------------------------
  37.         Public Property Name As String
  38.  
  39.         ''' ----------------------------------------------------------------------------------------------------
  40.         ''' <summary>
  41.         ''' Gets or sets the key value.
  42.         ''' </summary>
  43.         ''' ----------------------------------------------------------------------------------------------------
  44.         ''' <value>
  45.         ''' The key value.
  46.         ''' </value>
  47.         ''' ----------------------------------------------------------------------------------------------------
  48.         Public Property Value As String
  49.  
  50.         ''' ----------------------------------------------------------------------------------------------------
  51.         ''' <summary>
  52.         ''' Gets or sets the key comment-line.
  53.         ''' </summary>
  54.         ''' ----------------------------------------------------------------------------------------------------
  55.         ''' <value>
  56.         ''' The key comment-line.
  57.         ''' </value>
  58.         ''' ----------------------------------------------------------------------------------------------------
  59.         Public Property CommentLine As String
  60.  
  61. #End Region
  62.  
  63. #Region " Constructors "
  64.  
  65.         ''' ----------------------------------------------------------------------------------------------------
  66.         ''' <summary>
  67.         ''' Prevents a default instance of the <see cref="IniKey"/> class from being created.
  68.         ''' </summary>
  69.         ''' ----------------------------------------------------------------------------------------------------
  70.         <DebuggerNonUserCode>
  71.         Private Sub New()
  72.         End Sub
  73.  
  74.         ''' ----------------------------------------------------------------------------------------------------
  75.         ''' <summary>
  76.         ''' Initializes a new instance of the <see cref="IniKey"/> class.
  77.         ''' </summary>
  78.         ''' ----------------------------------------------------------------------------------------------------
  79.         ''' <param name="name">
  80.         ''' The key name.
  81.         ''' </param>
  82.         ''' ----------------------------------------------------------------------------------------------------
  83.         <DebuggerStepThrough>
  84.         Public Sub New(ByVal name As String)
  85.  
  86.             Me.New(name, "", "")
  87.  
  88.         End Sub
  89.  
  90.         ''' ----------------------------------------------------------------------------------------------------
  91.         ''' <summary>
  92.         ''' Initializes a new instance of the <see cref="IniKey"/> class.
  93.         ''' </summary>
  94.         ''' ----------------------------------------------------------------------------------------------------
  95.         ''' <param name="name">
  96.         ''' The key name.
  97.         ''' </param>
  98.         '''
  99.         ''' <param name="value">
  100.         ''' The key value.
  101.         ''' </param>
  102.         '''
  103.         ''' <param name="comment">
  104.         ''' The key commentary-line.
  105.         ''' </param>
  106.         ''' ----------------------------------------------------------------------------------------------------
  107.         ''' <exception cref="System.ArgumentNullException">
  108.         ''' name
  109.         ''' </exception>
  110.         '''
  111.         ''' <exception cref="System.ArgumentException">
  112.         ''' The key name cannot contain the ';' symbol because it identifies a commentary line.,name
  113.         ''' or
  114.         ''' The key name cannot contain the '=' symbol because it delimits the name from the value.,name
  115.         ''' </exception>
  116.         ''' ----------------------------------------------------------------------------------------------------
  117.         <DebuggerStepThrough>
  118.         Public Sub New(ByVal name As String, ByVal value As String, Optional ByVal comment As String = "")
  119.  
  120.             If (String.IsNullOrEmpty(name)) Then
  121.                 Throw New ArgumentNullException(paramName:="name")
  122.  
  123.             ElseIf (name.Contains(";"c)) Then
  124.                 Throw New ArgumentException(
  125.                     message:="The key name cannot contain the ';' symbol because it identifies a commentary line.",
  126.                     paramName:="name")
  127.  
  128.             ElseIf (name.Contains("="c)) Then
  129.                 Throw New ArgumentException(
  130.                     message:="The key name cannot contain the '=' symbol because it delimits the name from the value.",
  131.                     paramName:="name")
  132.  
  133.             Else
  134.                 Me.Name = name
  135.                 Me.Value = value
  136.                 Me.CommentLine = comment
  137.  
  138.             End If
  139.  
  140.         End Sub
  141.  
  142. #End Region
  143.  
  144.     End Class
  145.  
  146. End Namespace
  147.  
  148. #End Region
Add Comment
Please, Sign In to add comment