1 namespace System.Workflow.ComponentModel
2 {
3     using System;
4     using System.ComponentModel;
5     using System.ComponentModel.Design;
6     using System.CodeDom;
7     using System.Collections.Generic;
8     using System.Collections.ObjectModel;
9     using System.ComponentModel.Design.Serialization;
10     using System.Workflow.ComponentModel.Design;
11     using System.Workflow.ComponentModel.Compiler;
12     using System.Workflow.ComponentModel.Serialization;
13 
14     [Browsable(true)]
15     [DesignerSerializer(typeof(DependencyObjectCodeDomSerializer), typeof(CodeDomSerializer))]
16     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
17     public sealed class WorkflowParameterBinding : DependencyObject
18     {
19         public static readonly DependencyProperty ParameterNameProperty = DependencyProperty.Register("ParameterName", typeof(string), typeof(WorkflowParameterBinding), new PropertyMetadata(DependencyPropertyOptions.Metadata));
20         public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(object), typeof(WorkflowParameterBinding));
21 
WorkflowParameterBinding()22         public WorkflowParameterBinding()
23         {
24         }
25 
WorkflowParameterBinding(string parameterName)26         public WorkflowParameterBinding(string parameterName)
27         {
28             SetValue(ParameterNameProperty, parameterName);
29         }
30 
31         [DefaultValue(null)]
32         public object Value
33         {
34             get
35             {
36                 return GetValue(ValueProperty);
37             }
38             set
39             {
40                 SetValue(ValueProperty, value);
41             }
42         }
43 
44         public string ParameterName
45         {
46             get
47             {
48                 return (string)GetValue(ParameterNameProperty);
49             }
50             set
51             {
52                 SetValue(ParameterNameProperty, value);
53             }
54         }
55     }
56 
57     [Serializable]
58     [Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
59     public sealed class WorkflowParameterBindingCollection : KeyedCollection<string, WorkflowParameterBinding>
60     {
61         private Activity ownerActivity = null;
62 
WorkflowParameterBindingCollection(Activity ownerActivity)63         public WorkflowParameterBindingCollection(Activity ownerActivity)
64         {
65             if (ownerActivity == null)
66                 throw new ArgumentNullException("ownerActivity");
67 
68             this.ownerActivity = ownerActivity;
69         }
70 
GetItem(string key)71         public WorkflowParameterBinding GetItem(string key)
72         {
73             return this[key];
74         }
75 
GetKeyForItem(WorkflowParameterBinding item)76         protected override string GetKeyForItem(WorkflowParameterBinding item)
77         {
78             return item.ParameterName;
79         }
ClearItems()80         protected override void ClearItems()
81         {
82             if (!this.ownerActivity.DesignMode)
83                 throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
84 
85             base.ClearItems();
86         }
InsertItem(int index, WorkflowParameterBinding item)87         protected override void InsertItem(int index, WorkflowParameterBinding item)
88         {
89             if (item == null)
90                 throw new ArgumentNullException("item");
91 
92             if (!this.ownerActivity.DesignMode)
93                 throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
94 
95             if (Contains(item.ParameterName))
96             {
97                 WorkflowParameterBinding oldItem = this[item.ParameterName];
98                 index = this.IndexOf(oldItem);
99                 RemoveItem(index);
100             }
101 
102             base.InsertItem(index, item);
103         }
RemoveItem(int index)104         protected override void RemoveItem(int index)
105         {
106             if (!this.ownerActivity.DesignMode)
107                 throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
108 
109             base.RemoveItem(index);
110         }
SetItem(int index, WorkflowParameterBinding item)111         protected override void SetItem(int index, WorkflowParameterBinding item)
112         {
113             if (item == null)
114                 throw new ArgumentNullException("item");
115 
116             if (!this.ownerActivity.DesignMode)
117                 throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
118 
119             base.SetItem(index, item);
120         }
121     }
122 }
123