diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-11-03 07:30:06 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-11-03 07:30:06 -0800 |
commit | f1794fc8779ae39ac3d5bc6e8b811523e62ca482 (patch) | |
tree | 47fc2cc84483e4864c016542938937c172b22cca /samples/DotNetOAuth.ApplicationBlock/Util.cs | |
parent | 8cc2fa50f05f4b3cc30856b40336e9fd8ee85e33 (diff) | |
download | DotNetOpenAuth-f1794fc8779ae39ac3d5bc6e8b811523e62ca482.zip DotNetOpenAuth-f1794fc8779ae39ac3d5bc6e8b811523e62ca482.tar.gz DotNetOpenAuth-f1794fc8779ae39ac3d5bc6e8b811523e62ca482.tar.bz2 |
Moved the Google Consumer app-specific class into a new "sample" project.
Diffstat (limited to 'samples/DotNetOAuth.ApplicationBlock/Util.cs')
-rw-r--r-- | samples/DotNetOAuth.ApplicationBlock/Util.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/samples/DotNetOAuth.ApplicationBlock/Util.cs b/samples/DotNetOAuth.ApplicationBlock/Util.cs new file mode 100644 index 0000000..387a4c0 --- /dev/null +++ b/samples/DotNetOAuth.ApplicationBlock/Util.cs @@ -0,0 +1,31 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using DotNetOAuth.Messaging;
+
+namespace DotNetOAuth.ApplicationBlock {
+ internal class Util {
+ /// <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>
+ internal 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;
+ }
+ }
+ }
+
+ internal static Uri GetCallbackUrlFromContext() {
+ Uri callback = MessagingUtilities.GetRequestUrlFromContext().StripQueryArgumentsWithPrefix("oauth_");
+ return callback;
+ }
+ }
+}
|