summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth/CommonConsumers/CommonConsumerBase.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-11-02 22:05:41 -0800
committerAndrew <andrewarnott@gmail.com>2008-11-02 22:05:41 -0800
commit8969dfec9e4e4ecc45f909137dc3a23d7af0bee8 (patch)
treec903f51425a18182463965093ac3791f98c75145 /src/DotNetOAuth/CommonConsumers/CommonConsumerBase.cs
parent71e99449ee02155f34bb4928313c2200246b8a78 (diff)
downloadDotNetOpenAuth-8969dfec9e4e4ecc45f909137dc3a23d7af0bee8.zip
DotNetOpenAuth-8969dfec9e4e4ecc45f909137dc3a23d7af0bee8.tar.gz
DotNetOpenAuth-8969dfec9e4e4ecc45f909137dc3a23d7af0bee8.tar.bz2
Second stab at app-specific consumer classes.
Refactored to be a static class that operates on some consumer object so that desktop and web consumer alike can use it.
Diffstat (limited to 'src/DotNetOAuth/CommonConsumers/CommonConsumerBase.cs')
-rw-r--r--src/DotNetOAuth/CommonConsumers/CommonConsumerBase.cs61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/DotNetOAuth/CommonConsumers/CommonConsumerBase.cs b/src/DotNetOAuth/CommonConsumers/CommonConsumerBase.cs
deleted file mode 100644
index c3f9209..0000000
--- a/src/DotNetOAuth/CommonConsumers/CommonConsumerBase.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="CommonConsumerBase.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.CommonConsumers {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOAuth.ChannelElements;
-
- /// <summary>
- /// A useful base class to derive from for Consumers written against a specific Service Provider.
- /// </summary>
- public abstract class CommonConsumerBase {
- /// <summary>
- /// Initializes a new instance of the <see cref="CommonConsumerBase"/> class.
- /// </summary>
- /// <param name="serviceDescription">The service description.</param>
- /// <param name="tokenManager">The token manager.</param>
- /// <param name="consumerKey">The consumer key.</param>
- protected CommonConsumerBase(ServiceProviderDescription serviceDescription, ITokenManager tokenManager, string consumerKey) {
- if (serviceDescription == null) {
- throw new ArgumentNullException("serviceDescription");
- }
- if (tokenManager == null) {
- throw new ArgumentNullException("tokenManager");
- }
- if (consumerKey == null) {
- throw new ArgumentNullException("consumerKey");
- }
- this.Consumer = new WebConsumer(serviceDescription, tokenManager) {
- ConsumerKey = consumerKey,
- };
- }
-
- /// <summary>
- /// Gets the consumer.
- /// </summary>
- protected WebConsumer Consumer { get; private set; }
-
- /// <summary>
- /// Enumerates through the individual set bits in a flag enum.
- /// </summary>
- /// <param name="flags">The flags enum value.</param>
- /// <returns>An enumeration of just the <i>set</i> bits in the flags enum.</returns>
- protected static IEnumerable<long> GetIndividualFlags(Enum flags) {
- long flagsLong = Convert.ToInt64(flags);
- for (int i = 0; i < sizeof(long) * 8; i++) { // long is the type behind the largest enum
- // Select an individual application from the scopes.
- long individualFlagPosition = (long)Math.Pow(2, i);
- long individualFlag = flagsLong & individualFlagPosition;
- if (individualFlag == individualFlagPosition) {
- yield return individualFlag;
- }
- }
- }
- }
-}