Skip to content

Commit 847107e

Browse files
committed
Merge pull request #99 from rackspace/master
Updated documenation
2 parents 7d286a4 + 83365b3 commit 847107e

36 files changed

+832
-61
lines changed

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))

src/corelib/Core/Exceptions/CDNNotEnabledException.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
11
using System;
22
using System.Runtime.Serialization;
3+
using net.openstack.Core.Providers;
34

45
namespace net.openstack.Core.Exceptions
56
{
7+
/// <summary>
8+
/// The exception that is thrown when an attempt is made to modify CDN properties
9+
/// of a container which is not CDN-enabled.
10+
/// </summary>
11+
/// <seealso cref="IObjectStorageProvider"/>
612
[Serializable]
7-
public class CDNNotEnabledException : Exception
13+
public class CDNNotEnabledException : InvalidOperationException
814
{
9-
public CDNNotEnabledException() { }
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="CDNNotEnabledException"/> class.
17+
/// </summary>
18+
public CDNNotEnabledException()
19+
: base("The specified container is not CDN-enabled.")
20+
{
21+
}
1022

11-
public CDNNotEnabledException(string message) : base(message) { }
23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="CDNNotEnabledException"/> class
25+
/// with the specified error message.
26+
/// </summary>
27+
/// <param name="message">The message that describes the error.</param>
28+
public CDNNotEnabledException(string message)
29+
: base(message)
30+
{
31+
}
1232

33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="CDNNotEnabledException"/> class with
35+
/// serialized data.
36+
/// </summary>
37+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
38+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
39+
/// <exception cref="ArgumentNullException">If <paramref name="info"/> is <c>null</c>.</exception>
1340
protected CDNNotEnabledException(SerializationInfo info, StreamingContext context)
1441
: base(info, context)
1542
{

src/corelib/Core/Exceptions/CidrFormatException.cs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
11
using System;
22
using System.Runtime.Serialization;
3+
using net.openstack.Core.Validators;
34

45
namespace net.openstack.Core.Exceptions
56
{
7+
/// <summary>
8+
/// Represents errors that occur while validating a CIDR.
9+
/// </summary>
10+
/// <seealso cref="INetworksValidator.ValidateCidr"/>
611
[Serializable]
7-
public class CidrFormatException : Exception
12+
public class CidrFormatException : FormatException
813
{
9-
public CidrFormatException() { }
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="CidrFormatException"/> class.
16+
/// </summary>
17+
public CidrFormatException()
18+
: base("The specified CIDR is not in the correct format.")
19+
{
20+
}
1021

11-
public CidrFormatException(string message) : base(message) { }
22+
/// <summary>
23+
/// Initializes a new instance of the <see cref="CidrFormatException"/> class
24+
/// with the specified error message.
25+
/// </summary>
26+
/// <param name="message">The message that describes the error.</param>
27+
public CidrFormatException(string message)
28+
: base(message)
29+
{
30+
}
1231

32+
/// <summary>
33+
/// Initializes a new instance of the <see cref="CidrFormatException"/> class with
34+
/// serialized data.
35+
/// </summary>
36+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
37+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
38+
/// <exception cref="ArgumentNullException">If <paramref name="info"/> is <c>null</c>.</exception>
1339
protected CidrFormatException(SerializationInfo info, StreamingContext context)
1440
: base(info, context)
1541
{

src/corelib/Core/Exceptions/ContainerNameException.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
11
using System;
22
using System.Runtime.Serialization;
3+
using net.openstack.Core.Providers;
4+
using net.openstack.Core.Validators;
35

46
namespace net.openstack.Core.Exceptions
57
{
8+
/// <summary>
9+
/// Represents errors that occur while validating a container name for an <see cref="IObjectStorageProvider"/>.
10+
/// </summary>
11+
/// <seealso cref="IObjectStorageValidator.ValidateContainerName"/>
612
[Serializable]
7-
public class ContainerNameException : Exception
13+
public class ContainerNameException : ArgumentException
814
{
9-
public ContainerNameException() { }
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="ContainerNameException"/> class.
17+
/// </summary>
18+
public ContainerNameException()
19+
: base("The specified container name is not valid.")
20+
{
21+
}
1022

11-
public ContainerNameException(string message) : base(message) { }
23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="ContainerNameException"/> class
25+
/// with the specified error message.
26+
/// </summary>
27+
/// <param name="message">The message that describes the error.</param>
28+
public ContainerNameException(string message)
29+
: base(message)
30+
{
31+
}
1232

33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="ContainerNameException"/> class with
35+
/// serialized data.
36+
/// </summary>
37+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
38+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
39+
/// <exception cref="ArgumentNullException">If <paramref name="info"/> is <c>null</c>.</exception>
1340
protected ContainerNameException(SerializationInfo info, StreamingContext context)
1441
: base(info, context)
1542
{

src/corelib/Core/Exceptions/InvalidCloudIdentityException.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
using System;
22
using System.Runtime.Serialization;
3+
using net.openstack.Core.Domain;
34

45
namespace net.openstack.Core.Exceptions
56
{
7+
/// <summary>
8+
/// The exception thrown when the <see cref="CloudIdentity"/> instance passed
9+
/// to a provider method is not supported by that provider.
10+
/// </summary>
611
[Serializable]
7-
internal class InvalidCloudIdentityException : Exception
12+
internal class InvalidCloudIdentityException : NotSupportedException
813
{
9-
public InvalidCloudIdentityException(string message) : base(message) {}
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="InvalidCloudIdentityException"/> class
16+
/// with the specified error message.
17+
/// </summary>
18+
/// <param name="message">The message that describes the error.</param>
19+
public InvalidCloudIdentityException(string message)
20+
: base(message)
21+
{
22+
}
1023

24+
/// <summary>
25+
/// Initializes a new instance of the <see cref="InvalidCloudIdentityException"/> class with
26+
/// serialized data.
27+
/// </summary>
28+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
29+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
30+
/// <exception cref="ArgumentNullException">If <paramref name="info"/> is <c>null</c>.</exception>
1131
protected InvalidCloudIdentityException(SerializationInfo info, StreamingContext context)
1232
: base(info, context)
1333
{

src/corelib/Core/Exceptions/NoDefaultRegionSetException.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,30 @@
33

44
namespace net.openstack.Core.Exceptions
55
{
6+
/// <summary>
7+
/// The exception that is thrown when a service endpoint could not be obtained because
8+
/// no region was specified and no default region is available for the provider.
9+
/// </summary>
610
[Serializable]
7-
public class NoDefaultRegionSetException : Exception
11+
public class NoDefaultRegionSetException : InvalidOperationException
812
{
9-
public NoDefaultRegionSetException(string message) : base(message)
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="NoDefaultRegionSetException"/> class
15+
/// with the specified error message.
16+
/// </summary>
17+
/// <param name="message">The message that describes the error.</param>
18+
public NoDefaultRegionSetException(string message)
19+
: base(message)
1020
{
1121
}
1222

23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="NoDefaultRegionSetException"/> class with
25+
/// serialized data.
26+
/// </summary>
27+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
28+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
29+
/// <exception cref="ArgumentNullException">If <paramref name="info"/> is <c>null</c>.</exception>
1330
protected NoDefaultRegionSetException(SerializationInfo info, StreamingContext context)
1431
: base(info, context)
1532
{

0 commit comments

Comments
 (0)