Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Workflow.Runtime / WorkflowEventArgs.cs
1 // ****************************************************************************
2 // Copyright (C) Microsoft Corporation.  All rights reserved.
3 //
4
5 using System;
6 using System.IO;
7 using System.Threading;
8 using System.Diagnostics;
9 using System.Globalization;
10 using System.Collections;
11 using System.Collections.Generic;
12 using System.Collections.ObjectModel;
13
14 using System.Workflow.Runtime;
15 using System.Workflow.ComponentModel;
16 using System.Workflow.Runtime.Hosting;
17
18 namespace System.Workflow.Runtime
19 {
20
21     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
22     public class WorkflowEventArgs : EventArgs
23     {
24         private WorkflowInstance _instance;
25
26         internal WorkflowEventArgs(WorkflowInstance instance)
27         {
28             _instance = instance;
29         }
30
31         public WorkflowInstance WorkflowInstance
32         {
33             get
34             {
35                 return _instance;
36             }
37         }
38     }
39
40     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
41     public class WorkflowCompletedEventArgs : WorkflowEventArgs
42     {
43         private Dictionary<String, Object> _outputParameters;
44         private Activity _originalWorkflowDefinition;
45         private Activity _workflowDefinition;
46
47         internal WorkflowCompletedEventArgs(WorkflowInstance instance, Activity workflowDefinition)
48             : base(instance)
49         {
50             this._outputParameters = new Dictionary<String, Object>();
51             this._originalWorkflowDefinition = workflowDefinition;
52             this._workflowDefinition = null;
53         }
54
55         public Dictionary<String, Object> OutputParameters
56         {
57             get
58             {
59                 return this._outputParameters;
60             }
61         }
62
63         public Activity WorkflowDefinition
64         {
65             get
66             {
67                 if (this._workflowDefinition == null)
68                 {
69                     using (new WorkflowDefinitionLock(this._originalWorkflowDefinition))
70                     {
71                         if (this._workflowDefinition == null)
72                         {
73                             // Clone the original definition after locking the
74                             // definition's sync object which was passed in
75                             // the constructor.  This is so that the host cannot
76                             // corrupt the shared definition
77                             Activity tempDefinition = this._originalWorkflowDefinition.Clone();
78                             Thread.MemoryBarrier();
79                             this._workflowDefinition = tempDefinition;
80                         }
81                     }
82                 }
83
84                 return this._workflowDefinition;
85             }
86         }
87     }
88
89     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
90     public class WorkflowSuspendedEventArgs : WorkflowEventArgs
91     {
92         private String _error;
93
94         internal WorkflowSuspendedEventArgs(WorkflowInstance instance, String error)
95             : base(instance)
96         {
97             this._error = error;
98         }
99
100         public String Error
101         {
102             get
103             {
104                 return this._error;
105             }
106         }
107     }
108
109     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
110     public class WorkflowTerminatedEventArgs : WorkflowEventArgs
111     {
112         private Exception exception;
113
114         internal WorkflowTerminatedEventArgs(WorkflowInstance instance, String error)
115             : base(instance)
116         {
117             this.exception = new WorkflowTerminatedException(error);
118         }
119         internal WorkflowTerminatedEventArgs(WorkflowInstance instance, Exception e)
120             : base(instance)
121         {
122             this.exception = e;
123         }
124
125         public Exception Exception
126         {
127             get
128             {
129                 return this.exception;
130             }
131         }
132     }
133
134     internal sealed class WorkflowDefinitionEventArgs : EventArgs
135     {
136         private Type _workflowType;
137         private byte[] _xomlHashCode;
138
139         internal WorkflowDefinitionEventArgs(Type scheduleType)
140         {
141             _workflowType = scheduleType;
142         }
143
144         internal WorkflowDefinitionEventArgs(byte[] scheduleDefHash)
145         {
146             _xomlHashCode = scheduleDefHash;
147         }
148
149         public Type WorkflowType
150         {
151             get
152             {
153                 return _workflowType;
154             }
155         }
156
157         public byte[] WorkflowDefinitionHashCode
158         {
159             get
160             {
161                 return _xomlHashCode;
162             }
163         }
164     }
165 }