Advertisement
richcoleman

Process Service

Nov 28th, 2011
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.95 KB | None | 0 0
  1.  
  2. '==============================
  3. 'PROCESS.VB
  4. '==============================
  5.  
  6.     Public Class Process
  7.  
  8.         Private _isTest As Boolean
  9.         Private Property Test() As Boolean
  10.             Get
  11.                 Return _isTest
  12.             End Get
  13.             Set(ByVal value As Boolean)
  14.                 _isTest = value
  15.             End Set
  16.         End Property
  17.  
  18.         Private _timeLimitForTesting As Integer
  19.         Private Property TimeLimitForTesting() As Integer
  20.             Get
  21.                 Return _timeLimitForTesting
  22.             End Get
  23.             Set(ByVal value As Integer)
  24.                 _timeLimitForTesting = value
  25.             End Set
  26.         End Property
  27.  
  28.         Public Sub SetProcessTimeLimitForTesting(ByVal timeLimitForTesting As Integer)
  29.             _isTest = True
  30.             _timeLimitForTesting = timeLimitForTesting
  31.         End Sub
  32.  
  33.         Friend Function GetTaskCount() As Integer
  34.             Return Me.Tasks.Count
  35.         End Function
  36.  
  37.         Public Sub AddTask(ByVal name As String)
  38.             Dim newTask As New Task()
  39.             newTask.Name = name
  40.             Me.Tasks.Add(newTask)
  41.         End Sub
  42.  
  43.         Private Tasks As New TaskCollection()
  44.  
  45.     End Class
  46.  
  47.  
  48. '==============================
  49. 'TASK.VB
  50. '==============================
  51.  
  52.     Public Class Task
  53.  
  54.         Private _name As Boolean
  55.  
  56.         Public Property Name() As Boolean
  57.             Get
  58.                 Return _name
  59.             End Get
  60.             Set(ByVal value As Boolean)
  61.                 _name = value
  62.             End Set
  63.         End Property
  64.  
  65.     End Class
  66.  
  67.     Public NotInheritable Class TaskCollection
  68.         Inherits CollectionBase
  69.  
  70.         Public Sub New()
  71.  
  72.         End Sub
  73.  
  74.         Default Public ReadOnly Property Item(ByVal index As Integer) As Task
  75.             Get
  76.                 Return CType(List.Item(index), Task)
  77.             End Get
  78.         End Property
  79.  
  80.         Public Sub Add(ByVal task As Task)
  81.             List.Add(task)
  82.         End Sub
  83.  
  84.         Public Sub Remove(ByVal index As Integer)
  85.             If index > Count - 1 Or index < 0 Then
  86.                 Console.WriteLine("Can't remove this item")
  87.             Else
  88.                 List.RemoveAt(index)
  89.             End If
  90.         End Sub
  91.  
  92.     End Class
  93.  
  94. '==============================
  95. 'ICREATEPROCESS.VB
  96. '==============================
  97.  
  98.  
  99. Imports System.ServiceModel
  100.  
  101. <ServiceContract()>
  102. Public Interface ICreateProcess
  103.  
  104.     <OperationContract()>
  105.     Sub CreateNewProcess(ByVal newprocess As Process)
  106.  
  107. End Interface
  108.  
  109.  
  110.  
  111. '==============================
  112. 'CREATEPROCESS.SVC.VB
  113. '==============================
  114.  
  115.  
  116.     Public Class CreateProcess
  117.         Implements ICreateProcess
  118.  
  119.         Public Sub CreateNewProcess(ByVal newprocess As Process) Implements ICreateProcess.CreateNewProcess
  120.             'do stuff with new process
  121.             Dim iTaskCount As Integer = newprocess.GetTaskCount()
  122.         End Sub
  123.  
  124.     End Class
  125.  
  126.  
  127.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement