diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-11-03 17:22:00 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-11-04 08:12:52 -0800 |
commit | 462e19abd9034c11a12cad30e9899740f2bef8ff (patch) | |
tree | e08667f1d69249f8daa6c348a919bd0fd5434415 /samples/DotNetOpenAuth.ApplicationBlock/Util.cs | |
parent | 6a79be0eca3929d8fb4e797799dac8d6f7875475 (diff) | |
download | DotNetOpenAuth-462e19abd9034c11a12cad30e9899740f2bef8ff.zip DotNetOpenAuth-462e19abd9034c11a12cad30e9899740f2bef8ff.tar.gz DotNetOpenAuth-462e19abd9034c11a12cad30e9899740f2bef8ff.tar.bz2 |
Changed namepace and project names in preparation for merge with DotNetOpenId.
Diffstat (limited to 'samples/DotNetOpenAuth.ApplicationBlock/Util.cs')
-rw-r--r-- | samples/DotNetOpenAuth.ApplicationBlock/Util.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/Util.cs b/samples/DotNetOpenAuth.ApplicationBlock/Util.cs new file mode 100644 index 0000000..5001e2e --- /dev/null +++ b/samples/DotNetOpenAuth.ApplicationBlock/Util.cs @@ -0,0 +1,29 @@ +namespace DotNetOpenAuth.ApplicationBlock { + using System; + using System.Collections.Generic; + using DotNetOpenAuth.Messaging; + + 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; + } + } +} |