Skip to content

Commit ff621e5

Browse files
committed
Updated documentation and examples for the Queueing Service
1 parent 0a8e747 commit ff621e5

15 files changed

Lines changed: 618 additions & 13 deletions

src/Documentation/Documentation.v3.5.shfbproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@
143143
<Folder Include="Content" />
144144
<Folder Include="Content\Authentication\" />
145145
</ItemGroup>
146+
<ItemGroup>
147+
<Tokens Include="SharedTokens.tokens" />
148+
</ItemGroup>
146149
<!-- Import the SHFB build targets -->
147150
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
148151
</Project>

src/Documentation/Documentation.v4.0.shfbproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@
6262
<output includeNamespaces="false" namespacesFile="Namespaces" folder="{@OutputFolder}\..\..\Api\v4.0" />
6363
</component>
6464
</ComponentConfig>
65+
<ComponentConfig id="Code Block Component" enabled="True">
66+
<component id="Code Block Component" type="SandcastleBuilder.Components.CodeBlockComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
67+
<basePath value="{@HtmlEncProjectFolder}" />
68+
<outputPaths>{@HelpFormatOutputPaths}</outputPaths>
69+
<allowMissingSource value="false" />
70+
<removeRegionMarkers value="false" />
71+
<colorizer syntaxFile="{@SHFBFolder}Colorizer\highlight.xml" styleFile="{@SHFBFolder}Colorizer\highlight.xsl" stylesheet="{@SHFBFolder}Colorizer\highlight.css" scriptFile="{@SHFBFolder}Colorizer\highlight.js" language="cs" tabSize="0" numberLines="false" outlining="false" keepSeeTags="false" defaultTitle="true" />
72+
</component>
73+
</ComponentConfig>
74+
<ComponentConfig id="API Token Resolution" enabled="True">
75+
<component id="API Token Resolution" type="Microsoft.Ddue.Tools.SharedContentComponent" assembly="{@SandcastlePath}ProductionTools\BuildComponents.dll">
76+
{@TokenFiles}
77+
<replace elements="/*//token" item="string(.)" /></component>
78+
</ComponentConfig>
6579
</ComponentConfigurations>
6680
<CatalogName>VisualStudio11</CatalogName>
6781
<TocParentId>-1</TocParentId>
@@ -137,6 +151,9 @@
137151
<Folder Include="Content" />
138152
<Folder Include="Content\Authentication" />
139153
</ItemGroup>
154+
<ItemGroup>
155+
<Tokens Include="SharedTokens.tokens" />
156+
</ItemGroup>
140157
<!-- Import the SHFB build targets -->
141158
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
142159
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<content
3+
xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5"
4+
xmlns:xlink="http://www.w3.org/1999/xlink">
5+
6+
<!--
7+
The following items can only be used in <token> elements that appear in the XML documentation comments.
8+
-->
9+
10+
<item id="TaskParallelLibrary">
11+
<see href="http://msdn.microsoft.com/en-us/library/dd460717.aspx">Task Parallel Library</see>
12+
</item>
13+
14+
<item id="AsyncAwaitExample">
15+
<note>
16+
<para>
17+
The following code uses the <see langword="async/await"/> operators. For more information
18+
about using these operators in your code, see <conceptualLink target="32cc6156-3b31-4450-b209-b55fcfc0a210"/>.
19+
</para>
20+
</note>
21+
</item>
22+
23+
<item id="TplExample">
24+
<para>
25+
The following code shows demonstrates the same example using the <token>TaskParallelLibrary</token>
26+
instead of the <see langword="async/await"/> operators.
27+
</para>
28+
</item>
29+
</content>

src/Samples/CPPCodeSamples/CPPCodeSamples.vcxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@
7171
</Link>
7272
</ItemDefinitionGroup>
7373
<ItemGroup>
74+
<Reference Include="Newtonsoft.Json">
75+
<HintPath>..\..\packages\Newtonsoft.Json.5.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
76+
</Reference>
7477
<Reference Include="System" />
78+
<Reference Include="System.Core" />
7579
<Reference Include="System.Data" />
7680
<Reference Include="System.Xml" />
7781
</ItemGroup>
@@ -81,6 +85,7 @@
8185
</ItemGroup>
8286
<ItemGroup>
8387
<ClCompile Include="AssemblyInfo.cpp" />
88+
<ClCompile Include="QueueingServiceExamples.cpp" />
8489
<ClCompile Include="Stdafx.cpp">
8590
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
8691
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>

src/Samples/CPPCodeSamples/CPPCodeSamples.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
<ClCompile Include="Stdafx.cpp">
3030
<Filter>Source Files</Filter>
3131
</ClCompile>
32+
<ClCompile Include="QueueingServiceExamples.cpp">
33+
<Filter>Source Files</Filter>
34+
</ClCompile>
3235
</ItemGroup>
3336
<ItemGroup>
3437
<Text Include="ReadMe.txt" />
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#include "Stdafx.h"
2+
3+
using namespace net::openstack::Core;
4+
using namespace net::openstack::Core::Collections;
5+
using namespace net::openstack::Core::Domain;
6+
using namespace net::openstack::Core::Providers;
7+
using namespace net::openstack::Core::Domain::Queues;
8+
using namespace net::openstack::Providers::Rackspace;
9+
using namespace System;
10+
using namespace System::Collections::ObjectModel;
11+
using namespace System::Threading;
12+
using namespace System::Threading::Tasks;
13+
14+
ref class QueueingServiceExamples
15+
{
16+
private:
17+
static CloudIdentity^ identity = gcnew CloudIdentity();
18+
static String^ region = nullptr;
19+
static Guid clientId = Guid::NewGuid();
20+
static bool internalUrl = false;
21+
static IIdentityProvider^ identityProvider = nullptr;
22+
23+
public:
24+
void GetHome()
25+
{
26+
#pragma region GetHomeAsync (TPL)
27+
IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
28+
Task<HomeDocument^>^ task = queueingService->GetHomeAsync(CancellationToken::None);
29+
#pragma endregion
30+
}
31+
32+
void GetNodeHealth()
33+
{
34+
#pragma region GetNodeHealthAsync (TPL)
35+
IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
36+
Task^ task = queueingService->GetNodeHealthAsync(CancellationToken::None);
37+
#pragma endregion
38+
}
39+
40+
void CreateQueue()
41+
{
42+
#pragma region CreateQueueAsync (TPL)
43+
IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
44+
QueueName^ queueName = gcnew QueueName("ExampleQueue");
45+
Task<bool>^ task = queueingService->CreateQueueAsync(queueName, CancellationToken::None);
46+
#pragma endregion
47+
}
48+
49+
void DeleteQueue()
50+
{
51+
#pragma region DeleteQueueAsync (TPL)
52+
IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
53+
QueueName^ queueName = gcnew QueueName("ExampleQueue");
54+
Task^ task = queueingService->DeleteQueueAsync(queueName, CancellationToken::None);
55+
#pragma endregion
56+
}
57+
58+
#pragma region ListQueuesAsync (TPL)
59+
void ListQueues()
60+
{
61+
IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
62+
Task<ReadOnlyCollectionPage<CloudQueue^>^>^ queuesPageTask = queueingService->ListQueuesAsync(nullptr, Nullable<int>(), true, CancellationToken::None);
63+
auto func = gcnew Func<Task<ReadOnlyCollectionPage<CloudQueue^>^>^, Task<ReadOnlyCollection<CloudQueue^>^>^>(GetAllPagesContinuationAsync<CloudQueue^>);
64+
Task<ReadOnlyCollection<CloudQueue^>^>^ queuesTask = TaskExtensions::Unwrap(queuesPageTask->ContinueWith(func));
65+
}
66+
67+
generic<class T>
68+
static Task<ReadOnlyCollection<T>^>^ GetAllPagesContinuationAsync(Task<ReadOnlyCollectionPage<T>^>^ pageTask)
69+
{
70+
return ReadOnlyCollectionPageExtensions::GetAllPagesAsync(pageTask->Result, CancellationToken::None, static_cast<IProgress<ReadOnlyCollectionPage<T>^>^>(nullptr));
71+
}
72+
#pragma endregion
73+
74+
void QueueExists()
75+
{
76+
#pragma region QueueExistsAsync (TPL)
77+
IQueueingService^ queueingService = gcnew CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
78+
QueueName^ queueName = gcnew QueueName("ExampleQueue");
79+
Task<bool>^ task = queueingService->QueueExistsAsync(queueName, CancellationToken::None);
80+
#pragma endregion
81+
}
82+
};

src/Samples/CSharpCodeSamples/CSharpCodeSamples.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
</ItemGroup>
4444
<ItemGroup>
4545
<Compile Include="Properties\AssemblyInfo.cs" />
46+
<Compile Include="QueueingServiceExamples.cs" />
4647
</ItemGroup>
4748
<ItemGroup>
4849
<ProjectReference Include="..\..\corelib\corelib.v4.0.csproj">
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
namespace CSharpCodeSamples
2+
{
3+
using System;
4+
using System.Collections.ObjectModel;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using net.openstack.Core;
8+
using net.openstack.Core.Collections;
9+
using net.openstack.Core.Domain;
10+
using net.openstack.Core.Domain.Queues;
11+
using net.openstack.Core.Providers;
12+
using net.openstack.Providers.Rackspace;
13+
14+
public class QueueingServiceExamples
15+
{
16+
CloudIdentity identity =
17+
new CloudIdentity()
18+
{
19+
Username = "MyUser",
20+
APIKey = "API_KEY_HERE"
21+
};
22+
// use the default region for the account
23+
string region = null;
24+
// create a new client ID for this instance
25+
Guid clientId = Guid.NewGuid();
26+
// access Cloud Queues over the public Internet
27+
bool internalUrl = false;
28+
// use a default CloudIdentityProvider for authentication
29+
IIdentityProvider identityProvider = null;
30+
31+
public async Task GetHomeAsyncAwait()
32+
{
33+
#region GetHomeAsync (await)
34+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
35+
HomeDocument createdQueue = await queueingService.GetHomeAsync(CancellationToken.None);
36+
#endregion
37+
}
38+
39+
public void GetHome()
40+
{
41+
#region GetHomeAsync (TPL)
42+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
43+
Task<HomeDocument> task = queueingService.GetHomeAsync(CancellationToken.None);
44+
#endregion
45+
}
46+
47+
public async Task GetNodeHealthAsyncAwait()
48+
{
49+
#region GetNodeHealthAsync (await)
50+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
51+
await queueingService.GetNodeHealthAsync(CancellationToken.None);
52+
#endregion
53+
}
54+
55+
public void GetNodeHealth()
56+
{
57+
#region GetNodeHealthAsync (TPL)
58+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
59+
Task task = queueingService.GetNodeHealthAsync(CancellationToken.None);
60+
#endregion
61+
}
62+
63+
public async Task CreateQueueAsyncAwait()
64+
{
65+
#region CreateQueueAsync (await)
66+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
67+
QueueName queueName = new QueueName("ExampleQueue");
68+
bool createdQueue = await queueingService.CreateQueueAsync(queueName, CancellationToken.None);
69+
#endregion
70+
}
71+
72+
public void CreateQueue()
73+
{
74+
#region CreateQueueAsync (TPL)
75+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
76+
QueueName queueName = new QueueName("ExampleQueue");
77+
Task<bool> task = queueingService.CreateQueueAsync(queueName, CancellationToken.None);
78+
#endregion
79+
}
80+
81+
public async Task DeleteQueueAsyncAwait()
82+
{
83+
#region DeleteQueueAsync (await)
84+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
85+
QueueName queueName = new QueueName("ExampleQueue");
86+
await queueingService.DeleteQueueAsync(queueName, CancellationToken.None);
87+
#endregion
88+
}
89+
90+
public void DeleteQueue()
91+
{
92+
#region DeleteQueueAsync (TPL)
93+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
94+
QueueName queueName = new QueueName("ExampleQueue");
95+
Task task = queueingService.DeleteQueueAsync(queueName, CancellationToken.None);
96+
#endregion
97+
}
98+
99+
public async Task ListQueuesAsyncAwait()
100+
{
101+
#region ListQueuesAsync (await)
102+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
103+
ReadOnlyCollectionPage<CloudQueue> queuesPage = await queueingService.ListQueuesAsync(null, null, true, CancellationToken.None);
104+
ReadOnlyCollection<CloudQueue> queues = await queuesPage.GetAllPagesAsync(CancellationToken.None, null);
105+
#endregion
106+
}
107+
108+
public void ListQueues()
109+
{
110+
#region ListQueuesAsync (TPL)
111+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
112+
Task<ReadOnlyCollectionPage<CloudQueue>> queuesPageTask = queueingService.ListQueuesAsync(null, null, true, CancellationToken.None);
113+
Task<ReadOnlyCollection<CloudQueue>> queuesTask =
114+
queuesPageTask
115+
.ContinueWith(task => task.Result.GetAllPagesAsync(CancellationToken.None, null))
116+
.Unwrap();
117+
#endregion
118+
}
119+
120+
public async Task QueueExistsAsyncAwait()
121+
{
122+
#region QueueExistsAsync (await)
123+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
124+
QueueName queueName = new QueueName("ExampleQueue");
125+
bool exists = await queueingService.QueueExistsAsync(queueName, CancellationToken.None);
126+
#endregion
127+
}
128+
129+
public void QueueExists()
130+
{
131+
#region QueueExistsAsync (TPL)
132+
IQueueingService queueingService = new CloudQueuesProvider(identity, region, clientId, internalUrl, identityProvider);
133+
QueueName queueName = new QueueName("ExampleQueue");
134+
Task<bool> task = queueingService.QueueExistsAsync(queueName, CancellationToken.None);
135+
#endregion
136+
}
137+
}
138+
}

src/Samples/FSharpCodeSamples/FSharpCodeSamples.fsproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
<Reference Include="System.Core" />
4242
<Reference Include="System.Numerics" />
4343
</ItemGroup>
44-
<ItemGroup>
45-
<None Include="Script.fsx" />
46-
</ItemGroup>
4744
<ItemGroup>
4845
<ProjectReference Include="..\..\corelib\corelib.v4.0.csproj">
4946
<Name>corelib.v4.0</Name>
@@ -54,6 +51,9 @@
5451
<PropertyGroup>
5552
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
5653
</PropertyGroup>
54+
<ItemGroup>
55+
<Compile Include="QueueingServiceExamples.fs" />
56+
</ItemGroup>
5757
<Choose>
5858
<When Condition="'$(VisualStudioVersion)' == '11.0'">
5959
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">

0 commit comments

Comments
 (0)