Skip to content

Commit c697a4b

Browse files
committed
Adding reference source for part of Workflow Foundation
Adding reference source for System.Activities System.Activities.DurableInstancing System.Activities.Presentation System.Runtime.DurableInstancing System.Workflow.Activities System.Workflow.ComponentModel System.Workflow.Runtime System.WorkflowServices System.Xaml.Hosting XamlBuildTask
1 parent 6463232 commit c697a4b

File tree

1,979 files changed

+483130
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,979 files changed

+483130
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using System.Security;
5+
using System;
6+
using System.Security.Permissions;
7+
8+
// General Information about an assembly is controlled through the following
9+
// set of attributes. Change these attribute values to modify the information
10+
// associated with an assembly.
11+
12+
// Setting ComVisible to false makes the types in this assembly not visible
13+
// to COM components. If you need to access a type in this assembly from
14+
// COM, set the ComVisible attribute to true on that type.
15+
16+
// The following GUID is for the ID of the typelib if this project is exposed to COM
17+
[assembly: Guid("3C5386D5-54BD-49dc-AFCC-A46EAE3545DB")]
18+
19+
// Version information for an assembly consists of the following four values:
20+
//
21+
// Major Version
22+
// Minor Version
23+
// Build Number
24+
// Revision
25+
//
26+
// You can specify all the values or you can default the Revision and Build Numbers
27+
// by using the '*' as shown below:
28+
// Friend assemblies
29+
30+
// Partial Trust :
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
//----------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//----------------------------------------------------------------
4+
5+
namespace System.Activities.DurableInstancing
6+
{
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Diagnostics.CodeAnalysis;
10+
using System.Runtime;
11+
12+
sealed class BinaryHeap<TKey, TValue> where TKey : IComparable<TKey>
13+
{
14+
const int defaultCapacity = 128;
15+
readonly KeyValuePair<TKey, TValue> EmptyItem = new KeyValuePair<TKey, TValue>();
16+
KeyValuePair<TKey, TValue>[] items;
17+
int itemCount;
18+
19+
public BinaryHeap() :
20+
this(defaultCapacity)
21+
{
22+
}
23+
24+
public BinaryHeap(int capacity)
25+
{
26+
Fx.Assert(capacity > 0, "Capacity must be a positive value.");
27+
this.items = new KeyValuePair<TKey, TValue>[capacity];
28+
}
29+
30+
public int Count
31+
{
32+
get { return this.itemCount; }
33+
}
34+
35+
public bool IsEmpty
36+
{
37+
get { return this.itemCount == 0; }
38+
}
39+
40+
public void Clear()
41+
{
42+
this.itemCount = 0;
43+
this.items = new KeyValuePair<TKey, TValue>[defaultCapacity];
44+
}
45+
46+
public bool Enqueue(TKey key, TValue item)
47+
{
48+
if (this.itemCount == this.items.Length)
49+
{
50+
ResizeItemStore(this.items.Length * 2);
51+
}
52+
53+
this.items[this.itemCount++] = new KeyValuePair<TKey, TValue>(key, item);
54+
int position = this.BubbleUp(this.itemCount - 1);
55+
56+
return (position == 0);
57+
}
58+
59+
public KeyValuePair<TKey, TValue> Dequeue()
60+
{
61+
return Dequeue(true);
62+
}
63+
64+
KeyValuePair<TKey, TValue> Dequeue(bool shrink)
65+
{
66+
Fx.Assert(this.itemCount > 0, "Cannot dequeue empty queue.");
67+
68+
KeyValuePair<TKey, TValue> result = items[0];
69+
70+
if (this.itemCount == 1)
71+
{
72+
this.itemCount = 0;
73+
this.items[0] = this.EmptyItem;
74+
}
75+
else
76+
{
77+
--this.itemCount;
78+
this.items[0] = this.items[itemCount];
79+
this.items[itemCount] = this.EmptyItem;
80+
81+
// Keep the structure of the heap valid.
82+
this.BubbleDown(0);
83+
}
84+
85+
if (shrink)
86+
{
87+
ShrinkStore();
88+
}
89+
90+
return result;
91+
}
92+
93+
public KeyValuePair<TKey, TValue> Peek()
94+
{
95+
Fx.Assert(this.itemCount > 0, "Cannot peek at empty queue.");
96+
return this.items[0];
97+
}
98+
99+
[SuppressMessage(FxCop.Category.Design, "CA1006:DoNotNestGenericTypesInMemberSignatures",
100+
Justification = "This is an internal only API.")]
101+
[SuppressMessage(FxCop.Category.MSInternal, "CA908:UseApprovedGenericsForPrecompiledAssemblies")]
102+
public ICollection<KeyValuePair<TKey, TValue>> RemoveAll(Predicate<KeyValuePair<TKey, TValue>> func)
103+
{
104+
ICollection<KeyValuePair<TKey, TValue>> result = new List<KeyValuePair<TKey, TValue>>();
105+
106+
for (int position = 0; position < this.itemCount; position++)
107+
{
108+
while (func(this.items[position]) && position < this.itemCount)
109+
{
110+
result.Add(this.items[position]);
111+
112+
int lastItem = this.itemCount - 1;
113+
114+
while (func(this.items[lastItem]) && position < lastItem)
115+
{
116+
result.Add(this.items[lastItem]);
117+
this.items[lastItem] = EmptyItem;
118+
--lastItem;
119+
}
120+
121+
this.items[position] = this.items[lastItem];
122+
this.items[lastItem] = EmptyItem;
123+
this.itemCount = lastItem;
124+
125+
if (position < lastItem)
126+
{
127+
this.BubbleDown(this.BubbleUp(position));
128+
}
129+
}
130+
}
131+
132+
this.ShrinkStore();
133+
134+
return result;
135+
}
136+
137+
void ShrinkStore()
138+
{
139+
// If we are under half capacity and above default capacity size down.
140+
if (this.items.Length > defaultCapacity && this.itemCount < (this.items.Length >> 1))
141+
{
142+
int newSize = Math.Max(
143+
defaultCapacity, (((this.itemCount / defaultCapacity) + 1) * defaultCapacity));
144+
145+
this.ResizeItemStore(newSize);
146+
}
147+
}
148+
149+
[SuppressMessage("Microsoft.MSInternal", "CA908:UseApprovedGenericsForPrecompiledAssemblies")]
150+
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures",
151+
Justification = "This is an internal only API.")]
152+
public ICollection<KeyValuePair<TKey, TValue>> TakeWhile(Predicate<TKey> func)
153+
{
154+
ICollection<KeyValuePair<TKey, TValue>> result = new List<KeyValuePair<TKey, TValue>>();
155+
156+
while (!this.IsEmpty && func(this.Peek().Key))
157+
{
158+
result.Add(this.Dequeue(false));
159+
}
160+
161+
ShrinkStore();
162+
163+
return result;
164+
}
165+
166+
void ResizeItemStore(int newSize)
167+
{
168+
Fx.Assert(itemCount < newSize, "Shrinking now will lose data.");
169+
Fx.Assert(defaultCapacity <= newSize, "Can not shrink below the default capacity.");
170+
171+
KeyValuePair<TKey, TValue>[] temp = new KeyValuePair<TKey, TValue>[newSize];
172+
173+
Array.Copy(this.items, 0, temp, 0, this.itemCount);
174+
175+
this.items = temp;
176+
}
177+
178+
void BubbleDown(int startIndex)
179+
{
180+
int currentPosition = startIndex;
181+
int swapPosition = startIndex;
182+
183+
while (true)
184+
{
185+
int leftChildPosition = (currentPosition << 1) + 1;
186+
int rightChildPosition = leftChildPosition + 1;
187+
188+
if (leftChildPosition < itemCount)
189+
{
190+
if (this.items[currentPosition].Key.CompareTo(this.items[leftChildPosition].Key) > 0)
191+
{
192+
swapPosition = leftChildPosition;
193+
}
194+
}
195+
else
196+
{
197+
break;
198+
}
199+
200+
if (rightChildPosition < itemCount)
201+
{
202+
if (this.items[swapPosition].Key.CompareTo(this.items[rightChildPosition].Key) > 0)
203+
{
204+
swapPosition = rightChildPosition;
205+
}
206+
}
207+
208+
if (currentPosition != swapPosition)
209+
{
210+
KeyValuePair<TKey, TValue> temp = this.items[currentPosition];
211+
this.items[currentPosition] = this.items[swapPosition];
212+
this.items[swapPosition] = temp;
213+
}
214+
else
215+
{
216+
break;
217+
}
218+
219+
currentPosition = swapPosition;
220+
}
221+
}
222+
223+
int BubbleUp(int startIndex)
224+
{
225+
while (startIndex > 0)
226+
{
227+
int parent = (startIndex - 1) >> 1;
228+
229+
if (this.items[parent].Key.CompareTo(this.items[startIndex].Key) > 0)
230+
{
231+
KeyValuePair<TKey, TValue> temp = this.items[startIndex];
232+
this.items[startIndex] = this.items[parent];
233+
this.items[parent] = temp;
234+
}
235+
else
236+
{
237+
break;
238+
}
239+
240+
startIndex = parent;
241+
}
242+
243+
return startIndex;
244+
}
245+
}
246+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//-----------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
//-----------------------------------------------------------------------------
4+
5+
namespace System.Activities.DurableInstancing
6+
{
7+
enum CommandResult
8+
{
9+
Success = 0,
10+
InstanceNotFound = 1,
11+
InstanceLockNotAcquired = 2,
12+
KeyAlreadyExists = 3,
13+
KeyNotFound = 4,
14+
InstanceAlreadyExists = 5,
15+
InstanceLockLost = 6,
16+
InstanceCompleted = 7,
17+
KeyDisassociated = 8,
18+
StaleInstanceVersion = 10,
19+
HostLockExpired = 11,
20+
HostLockNotFound = 12,
21+
CleanupInProgress = 13,
22+
InstanceAlreadyLockedToOwner = 14,
23+
IdentityNotFound = 15,
24+
Unknown = 99
25+
};
26+
}

0 commit comments

Comments
 (0)