Skip to content

Commit 0fe2d26

Browse files
committed
Updated interface documentation for non-provider interfaces (the simple cases)
1 parent 9cde7f2 commit 0fe2d26

17 files changed

Lines changed: 281 additions & 16 deletions

src/corelib/Core/Caching/UserAccessCache.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,46 @@
55

66
namespace net.openstack.Core.Caching
77
{
8+
/// <summary>
9+
/// Provides a thread-safe cache of <see cref="UserAccess"/> objects. A default shared
10+
/// instance is available through <see cref="UserAccessCache.Instance"/>.
11+
/// </summary>
812
public class UserAccessCache : ICache<UserAccess>
913
{
1014
private static readonly Lazy<UserAccessCache> _instance = new Lazy<UserAccessCache>(CreateInstance, true);
1115

1216
private readonly ConcurrentDictionary<string, UserAccess> _tokenCache = new ConcurrentDictionary<string, UserAccess>();
1317

18+
/// <summary>
19+
/// Gets a <see cref="UserAccess"/> cached for a particular key, updating the value if necessary.
20+
/// </summary>
21+
/// <remarks>
22+
/// This method returns a previously cached <see cref="UserAccess"/> when possible. If any
23+
/// of the following conditions are met, the <paramref name="refreshCallback"/> function
24+
/// will be called to obtain a new value for <paramref name="key"/> which is then added to
25+
/// the cache, replacing any previously cached value.
26+
///
27+
/// <list type="bullet">
28+
/// <item>The cache does not contain any value associated with <paramref name="key"/>.</item>
29+
/// <item><paramref name="forceCacheRefresh"/> is <c>true</c>.</item>
30+
/// <item>The previously cached <see cref="UserAccess"/> for <paramref name="key"/> has expired
31+
/// (see <see cref="IdentityToken.IsExpired()"/>).</item>
32+
/// </list>
33+
///
34+
/// <para>If any of the above conditions is met and <paramref name="refreshCallback"/> is <c>null</c>,
35+
/// the previously cached value for <paramref name="key"/>, if any, is removed from the cache
36+
/// and the method returns <c>null</c>.</para>
37+
/// </remarks>
38+
/// <param name="key">The key.</param>
39+
/// <param name="refreshCallback">A function which returns a new value for the specified <paramref name="key"/>,
40+
/// or <c>null</c> if no update function available (see remarks). This function may perform a synchronous
41+
/// authentication to an <see cref="IIdentityProvider"/>.</param>
42+
/// <param name="forceCacheRefresh">If <c>true</c>, the value associated with <paramref name="key"/> will be always be refreshed by calling <paramref name="refreshCallback"/>, even if a value is already cached.</param>
43+
/// <returns>
44+
/// The cached <see cref="UserAccess"/> associated with the specified <paramref name="key"/>.
45+
/// If no cached value is available (see remarks), the method returns <c>null</c>.
46+
/// </returns>
47+
/// <exception cref="ArgumentNullException">If <paramref name="key"/> is <c>null</c>.</exception>
1448
public UserAccess Get(string key, Func<UserAccess> refreshCallback, bool forceCacheRefresh = false)
1549
{
1650
UserAccess userAccess;
@@ -64,6 +98,9 @@ public UserAccess Get(string key, Func<UserAccess> refreshCallback, bool forceCa
6498
return userAccess;
6599
}
66100

101+
/// <summary>
102+
/// Gets a default instance of <see cref="UserAccessCache"/>.
103+
/// </summary>
67104
public static UserAccessCache Instance
68105
{
69106
get
@@ -84,8 +121,40 @@ private static bool IsValid(UserAccess userAccess)
84121
}
85122
}
86123

124+
/// <summary>
125+
/// Represents a thread-safe cache of objects identified by string keys.
126+
/// </summary>
127+
/// <typeparam name="T">Type type of objects stored in the cache.</typeparam>
87128
public interface ICache<T>
88129
{
130+
/// <summary>
131+
/// Gets a value cached for a particular key, updating the value if necessary.
132+
/// </summary>
133+
/// <remarks>
134+
/// This method returns a previously cached value when possible. If any of the following
135+
/// conditions are met, the <paramref name="refreshCallback"/> function will be called to
136+
/// obtain a new value for <paramref name="key"/> which is then added to the cache,
137+
/// replacing any previously cached value.
138+
///
139+
/// <list type="bullet">
140+
/// <item>The cache does not contain any value associated with <paramref name="key"/>.</item>
141+
/// <item><paramref name="forceCacheRefresh"/> is <c>true</c>.</item>
142+
/// <item>The previously cached value for <paramref name="key"/> is no longer valid. The exact
143+
/// algorithm for determining whether or not a value is valid in implementation-defined.</item>
144+
/// </list>
145+
///
146+
/// <para>If any of the above conditions is met and <paramref name="refreshCallback"/> is <c>null</c>,
147+
/// the previously cached value for <paramref name="key"/>, if any, is removed from the cache
148+
/// and the default value for <typeparamref name="T"/> is returned.</para>
149+
/// </remarks>
150+
/// <param name="key">The key.</param>
151+
/// <param name="refreshCallback">A function which returns a new value for the specified <paramref name="key"/>, or <c>null</c> if no update function available (see remarks).</param>
152+
/// <param name="forceCacheRefresh">If <c>true</c>, the value associated with <paramref name="key"/> will be always be refreshed by calling <paramref name="refreshCallback"/>, even if a value is already cached.</param>
153+
/// <returns>
154+
/// The cached value associated with the specified <paramref name="key"/>. If no cached value is
155+
/// available (see remarks), the method returns the default value for <typeparamref name="T"/>.
156+
/// </returns>
157+
/// <exception cref="ArgumentNullException">If <paramref name="key"/> is <c>null</c>.</exception>
89158
T Get(string key, Func<T> refreshCallback, bool forceCacheRefresh = false);
90159
}
91160
}
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
using Newtonsoft.Json.Linq;
1+
using System;
2+
using Newtonsoft.Json.Linq;
23

34
namespace net.openstack.Core.Domain.Mapping
45
{
6+
/// <summary>
7+
/// Represents an object that can convert between generic <see cref="JObject"/> instances
8+
/// and instances of another specific type.
9+
/// </summary>
10+
/// <typeparam name="T">The type which can be converted to and from <see cref="JObject"/>.</typeparam>
511
public interface IJsonObjectMapper<T> : IObjectMapper<JObject, T>
612
{
13+
/// <summary>
14+
/// Converts a JSON string representation of <typeparamref name="T"/> to an instance
15+
/// of <typeparamref name="T"/>.
16+
/// </summary>
17+
/// <param name="rawJson">The JSON string representation.</param>
18+
/// <returns>An instance of <typeparamref name="T"/> represented by <paramref name="rawJson"/>.</returns>
19+
/// <exception cref="ArgumentNullException">If <paramref name="rawJson"/> is <c>null</c>.</exception>
20+
/// <exception cref="NotSupportedException">If the conversion cannot be performed.</exception>
721
T Map(string rawJson);
822
}
923
}
Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
11
namespace net.openstack.Core.Domain.Mapping
22
{
3+
using System;
4+
using System.ComponentModel;
5+
6+
/// <summary>
7+
/// Represents an object that can convert between instances of two specific types.
8+
/// </summary>
9+
/// <remarks>
10+
/// This interface is similar to a <see cref="TypeConverter"/> which only supports
11+
/// conversions between exactly two concrete types.
12+
/// </remarks>
13+
/// <typeparam name="TFrom">The first type.</typeparam>
14+
/// <typeparam name="TTo">The second type.</typeparam>
315
public interface IObjectMapper<TFrom, TTo>
416
{
17+
/// <summary>
18+
/// Converts an instance of <typeparamref name="TFrom"/> to an instance of <typeparamref name="TTo"/>.
19+
/// </summary>
20+
/// <remarks>
21+
/// This method provides behavior similar to a strongly-typed implementation
22+
/// of <see cref="TypeConverter.ConvertTo(object, Type)"/>.
23+
/// </remarks>
24+
/// <param name="from">The instance to convert.</param>
25+
/// <returns>The converted instance.</returns>
26+
/// <exception cref="NotSupportedException">The conversion cannot be performed.</exception>
527
TTo Map(TFrom from);
628

29+
/// <summary>
30+
/// Converts an instance of <typeparamref name="TTo"/> to an instance of <typeparamref name="TFrom"/>.
31+
/// </summary>
32+
/// <remarks>
33+
/// This method provides behavior similar to a strongly-typed implementation
34+
/// of <see cref="TypeConverter.ConvertFrom(object)"/>.
35+
/// </remarks>
36+
/// <param name="to">The instance to convert.</param>
37+
/// <returns>The converted instance.</returns>
38+
/// <exception cref="NotSupportedException">The conversion cannot be performed.</exception>
739
TFrom Map(TTo to);
840
}
9-
}
41+
}

src/corelib/Core/Domain/Mapping/NetworkResponseJsonMapper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace net.openstack.Core.Domain.Mapping
55
{
66
internal class NetworkResponseJsonMapper : IJsonObjectMapper<Network>
77
{
8+
/// <inheritdoc/>
89
public Network Map(JObject @from)
910
{
1011
if (from == null)
@@ -18,11 +19,13 @@ public Network Map(JObject @from)
1819
};
1920
}
2021

22+
/// <inheritdoc/>
2123
public JObject Map(Network to)
2224
{
2325
throw new System.NotImplementedException();
2426
}
2527

28+
/// <inheritdoc/>
2629
public Network Map(string rawJson)
2730
{
2831
if (string.IsNullOrWhiteSpace(rawJson))
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
6-
namespace net.openstack.Core
1+
namespace net.openstack.Core
72
{
3+
/// <summary>
4+
/// This interface provides methods for encoding and decoding strings which are
5+
/// embedded in the query string section of a URL.
6+
/// </summary>
87
public interface IEncodeDecodeProvider
98
{
9+
/// <summary>
10+
/// Encodes a string for inclusion in a URL.
11+
/// </summary>
12+
/// <remarks>
13+
/// The encoded string can be restored by calling <see cref="UrlDecode"/>.
14+
/// </remarks>
15+
/// <param name="stringToEncode">The string to encode.</param>
16+
/// <returns>The encoded string. If <paramref name="stringToEncode"/> is <c>null</c>, this method returns <c>null</c>.</returns>
1017
string UrlEncode(string stringToEncode);
18+
19+
/// <summary>
20+
/// Decodes a string which is embedded in a URL.
21+
/// </summary>
22+
/// <param name="stringToDecode">The string to decode.</param>
23+
/// <returns>The decoded string. If <paramref name="stringToDecode"/> is <c>null</c>, this method returns <c>null</c>.</returns>
1124
string UrlDecode(string stringToDecode);
1225
}
1326
}
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using JSIStudios.SimpleRESTServices.Client;
34

45
namespace net.openstack.Core
56
{
7+
/// <summary>
8+
/// This interface represents an object that can extract metadata information from a
9+
/// collection of HTTP headers returned from a REST request.
10+
/// </summary>
611
public interface IObjectStorageMetadataProcessor
712
{
13+
/// <summary>
14+
/// Extracts metadata information from a collection of HTTP headers. The returned collection
15+
/// may include multiple types of metadata information. The keys of the collection represent
16+
/// the type of metadata, and the values are key-value collections of the corresponding
17+
/// metadata.
18+
/// </summary>
19+
/// <param name="httpHeaders">The collection of HTTP headers.</param>
20+
/// <returns>The metadata.</returns>
21+
/// <exception cref="ArgumentNullException">If <paramref name="httpHeaders"/> is <c>null</c>.</exception>
22+
/// <exception cref="ArgumentException">If <paramref name="httpHeaders"/> contains two headers with equivalent values for <see cref="HttpHeader.Key"/> (case-insensitive).</exception>
823
Dictionary<string, Dictionary<string, string>> ProcessMetadata(IList<HttpHeader> httpHeaders);
924
}
1025
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
namespace net.openstack.Core.Validators
22
{
3+
using System;
4+
using net.openstack.Core.Providers;
5+
using net.openstack.Providers.Rackspace.Exceptions;
6+
7+
/// <summary>
8+
/// Represents an object that validates arguments for an implementation of <see cref="IBlockStorageProvider"/>
9+
/// prior to sending the calls to the underlying REST API.
10+
/// </summary>
311
public interface IBlockStorageValidator
412
{
13+
/// <summary>
14+
/// Validates the <c>size</c> parameter when creating a new block storage volume
15+
/// with <see cref="IBlockStorageProvider.CreateVolume"/>.
16+
/// </summary>
17+
/// <param name="size">The volume size in GB.</param>
18+
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="size"/> is less than 0.</exception>
19+
/// <exception cref="InvalidVolumeSizeException">If <paramref name="size"/> is not a valid volume size.</exception>
520
void ValidateVolumeSize(int size);
621
}
722
}
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
namespace net.openstack.Core.Validators
22
{
3+
using System;
4+
using net.openstack.Core.Exceptions;
5+
using net.openstack.Core.Providers;
6+
7+
/// <summary>
8+
/// Represents an object that validates arguments for an implementation of <see cref="INetworksProvider"/>
9+
/// prior to sending the calls to the underlying REST API.
10+
/// </summary>
311
public interface INetworksValidator
412
{
5-
void ValidateCidr(string cidr);
13+
/// <summary>
14+
/// Validates an IP address range (CIDR) formatted as a string.
15+
/// </summary>
16+
/// <param name="cidr">The IP address range.</param>
17+
/// <exception cref="ArgumentNullException">If <paramref name="cidr"/> is <c>null</c>.</exception>
18+
/// <exception cref="CidrFormatException">If <paramref name="cidr"/> is not in the correct format.</exception>
19+
void ValidateCidr(string cidr);
620
}
721
}
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
namespace net.openstack.Core.Validators
22
{
3+
using System;
4+
using net.openstack.Core.Exceptions;
5+
using net.openstack.Core.Providers;
6+
7+
/// <summary>
8+
/// Represents an object that validates arguments for an implementation of <see cref="IObjectStorageProvider"/>
9+
/// prior to sending the calls to the underlying REST API.
10+
/// </summary>
311
public interface IObjectStorageValidator
412
{
13+
/// <summary>
14+
/// Validates a container name for an object storage provider.
15+
/// </summary>
16+
/// <param name="containerName">The container name.</param>
17+
/// <exception cref="ArgumentNullException">If <paramref name="containerName"/> is <c>null</c>.</exception>
18+
/// <exception cref="ContainerNameException">If <paramref name="containerName"/> is not a valid container name.</exception>
519
void ValidateContainerName(string containerName);
20+
21+
/// <summary>
22+
/// Validates an object name for an object storage provider.
23+
/// </summary>
24+
/// <param name="objectName">The object name.</param>
25+
/// <exception cref="ArgumentNullException">If <paramref name="objectName"/> is <c>null</c>.</exception>
26+
/// <exception cref="ObjectNameException">If <paramref name="objectName"/> is not a valid object name.</exception>
627
void ValidateObjectName(string objectName);
728
}
8-
}
29+
}

src/corelib/Providers/Rackspace/CloudFilesMetadataProcessor.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using JSIStudios.SimpleRESTServices.Client;
34
using net.openstack.Core;
45

@@ -22,8 +23,31 @@ public static CloudFilesMetadataProcessor Default
2223
}
2324
}
2425

26+
/// <summary>
27+
/// Extracts metadata information from a collection of HTTP headers.
28+
/// </summary>
29+
/// <remarks>
30+
/// The returned collection has two keys: <see cref="CloudFilesProvider.ProcessedHeadersHeaderKey"/>
31+
/// and <see cref="CloudFilesProvider.ProcessedHeadersMetadataKey"/>.
32+
///
33+
/// <para>The value for
34+
/// <see cref="CloudFilesProvider.ProcessedHeadersMetadataKey"/> contains the processed Cloud Files
35+
/// metadata included in HTTP headers such as <strong>X-Account-Meta-*</strong>,
36+
/// <strong>X-Container-Meta-*</strong>, and <strong>X-Object-Meta-*</strong>. The metadata prefix
37+
/// has been removed from the keys stored in this value.</para>
38+
///
39+
/// <para>The value for <see cref="CloudFilesProvider.ProcessedHeadersHeaderKey"/> contains the
40+
/// HTTP headers which were not in the form of a known Cloud Files metadata prefix.</para>
41+
/// </remarks>
42+
/// <param name="httpHeaders">The collection of HTTP headers.</param>
43+
/// <returns>The metadata.</returns>
44+
/// <exception cref="ArgumentNullException">If <paramref name="httpHeaders"/> is <c>null</c>.</exception>
45+
/// <exception cref="ArgumentException">If <paramref name="httpHeaders"/> contains two headers with equivalent values for <see cref="HttpHeader.Key"/> (case-insensitive).</exception>
2546
public virtual Dictionary<string, Dictionary<string, string>> ProcessMetadata(IList<HttpHeader> httpHeaders)
2647
{
48+
if (httpHeaders == null)
49+
throw new ArgumentNullException("httpHeaders");
50+
2751
var pheaders = new Dictionary<string, string>();
2852
var metadata = new Dictionary<string, string>();
2953
foreach (var header in httpHeaders)

0 commit comments

Comments
 (0)