diff --git a/LiveSDKHelper.Test/ExtensionMethodsTest.cs b/LiveSDKHelper.Test/ExtensionMethodsTest.cs index 8f362d8..fc45d1e 100644 --- a/LiveSDKHelper.Test/ExtensionMethodsTest.cs +++ b/LiveSDKHelper.Test/ExtensionMethodsTest.cs @@ -60,30 +60,14 @@ public void MustReturnPipeSeparatedValuesWithSurroundingSpaceFromListOfStrings() [TestMethod] public void MustReturnSpaceSeparatedValuesFromListOfScopes() { - var list = new List { Scope.SignIn, Scope.Basic, Scope.SkyDrive }; + var list = new List { Scope.SignIn, Scope.Basic, Scope.SkyDrive }; - var result = list.ToConcatenatedString(item => item.ToStringScope(), " "); + var result = list.ToConcatenatedString(item => item, " "); var expected = "wl.signin wl.basic wl.skydrive"; Assert.AreEqual(expected, result); } } - - [TestClass] - public class ToScopeMethodTest - { - [TestMethod] - public void MustReturnStringScope() - { - var scope = Scope.SkyDriveUpdate; - - var scopeName = scope.ToStringScope(); - - var expected = "wl.skydrive_update"; - - Assert.AreEqual(expected, scopeName); - } - } } } diff --git a/LiveSDKHelper.Test/ScopeTest.cs b/LiveSDKHelper.Test/ScopeTest.cs index f74a200..cdb6d8e 100644 --- a/LiveSDKHelper.Test/ScopeTest.cs +++ b/LiveSDKHelper.Test/ScopeTest.cs @@ -2,39 +2,27 @@ using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Reflection; // ReSharper disable CheckNamespace namespace LiveSDKHelper.Test.ScopeEnum { - [TestClass] - public class ScopeTest - { - [TestMethod] - public void MustAllHaveScopeNameAttribute() - { - var scopeValues = Enum.GetValues(typeof(Scope)); - var scopes = scopeValues.Cast().ToList(); + [TestClass] + public class ScopeTest + { + [TestMethod] + public void MustEachHaveUniqueScopeName() + { + FieldInfo[] fieldinfoArray = typeof(Scope).GetFields(System.Reflection.BindingFlags.Static); + List fieldInfoNames = new List(); + foreach (var fi in fieldinfoArray) + { + fieldInfoNames.Add(fi.GetRawConstantValue().ToString()); + } - var scopesWithName = new List(scopes.Where(scope => scope.ToStringScope() != string.Empty)); - - Assert.AreEqual(scopes.Count, scopesWithName.Count); - } - - [TestMethod] - public void MustEachHaveUniqueScopeName() - { - var scopeValues = Enum.GetValues(typeof(Scope)); - var scopes = scopeValues.Cast().ToList(); - - var scopeNames = new List(); - foreach (var scope in scopes) - { - if (scopeNames.Contains(scope.ToStringScope())) { continue; } - - scopeNames.Add(scope.ToStringScope()); - } - - Assert.AreEqual(scopes.Count, scopeNames.Count); - } - } + int scopesCount = fieldinfoArray.Length; + int scopesNameCount = fieldInfoNames.Distinct().Count(); + Assert.AreEqual(scopesCount, scopesNameCount); + } + } } diff --git a/LiveSDKHelper.sln b/LiveSDKHelper.sln index bfa83a1..a666713 100644 --- a/LiveSDKHelper.sln +++ b/LiveSDKHelper.sln @@ -1,8 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveSDKHelper", "LiveSDKHelper\LiveSDKHelper.csproj", "{5093B1BE-55B4-4639-9DBF-D7264A9B8324}" -EndProject +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{4B99AACB-8E5D-4E5F-9E59-E29B49D745CC}" ProjectSection(SolutionItems) = preProject .nuget\NuGet.config = .nuget\NuGet.config @@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution nuspec.2011.8.xsd = nuspec.2011.8.xsd EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveSDKHelper", "LiveSDKHelper\LiveSDKHelper.csproj", "{5093B1BE-55B4-4639-9DBF-D7264A9B8324}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveSDKHelperPlayground8", "LiveSDKHelperPlayground8\LiveSDKHelperPlayground8.csproj", "{BB28DA94-09EE-492C-9661-4A6C2F386CE7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveSDKHelper.Test", "LiveSDKHelper.Test\LiveSDKHelper.Test.csproj", "{4A7AC562-C707-4DFC-9251-C64B7532AE20}" diff --git a/LiveSDKHelper/ExtensionMethods.cs b/LiveSDKHelper/ExtensionMethods.cs index 52d8242..422204a 100644 --- a/LiveSDKHelper/ExtensionMethods.cs +++ b/LiveSDKHelper/ExtensionMethods.cs @@ -32,13 +32,6 @@ public static string ToConcatenatedString(this IEnumerable source, return b.ToString().Trim(separator.ToCharArray()); } - public static string ToStringScope(this Scope scope) - { - var scopeName = scope.GetAttribute(); - - return scopeName == null ? string.Empty : scopeName.ScopeName; - } - internal static UriBuilder SetQueryParam(this UriBuilder uri, string key, string value) { var collection = uri.ParseQuery(); diff --git a/LiveSDKHelper/LiveSDKHelper.csproj b/LiveSDKHelper/LiveSDKHelper.csproj index 9a199d2..f20588a 100644 --- a/LiveSDKHelper/LiveSDKHelper.csproj +++ b/LiveSDKHelper/LiveSDKHelper.csproj @@ -11,11 +11,16 @@ LiveSDKHelper LiveSDKHelper v4.0 - Profile104 + Profile158 512 {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} LiveSDKHelper.nuspec true + + + + + 4.0 true diff --git a/LiveSDKHelper/Scope.cs b/LiveSDKHelper/Scope.cs index 1e78407..08c5326 100644 --- a/LiveSDKHelper/Scope.cs +++ b/LiveSDKHelper/Scope.cs @@ -1,151 +1,141 @@ namespace LiveSDKHelper { - // Reference: http://msdn.microsoft.com/en-us/library/live/hh243646.aspx - public enum Scope + // Reference: https://msdn.microsoft.com/en-us/library/hh243646.aspx + public static class Scope { + #region Core Scopes /// - /// Read access to a user's basic profile info. Also enables read access to a user's list of contacts. + /// Enables read access to a user's basic profile info. Also enables read access to a user's list of contacts. /// - [ScopeName("wl.basic")] - Basic, + public const string Basic = "wl.basic"; /// - /// The ability of an app to read and update a user's info at any time. Without this scope, an app can access the user's info only while the user is signed in to Live Connect and is using your app. + /// Enables the ability of an app to read and update a user's info at any time. Without this scope, an app can access the user's info only while the user is signed in to Live Connect and is using your app. /// - [ScopeName("wl.offline_access")] - OfflineAccess, + public const string OfflineAccess = "wl.offline_access"; /// - /// Single sign-in behavior. With single sign-in, users who are already signed in to Live Connect are also signed in to your website. + /// Enables single sign-in behavior. With single sign-in, users who are already signed in to Live Connect are also signed in to your website. /// - [ScopeName("wl.signin")] - SignIn, + public const string SignIn = "wl.signin"; + #endregion + #region Extended Scopes /// - /// Read access to a user's birthday info including birth day, month, and year. + /// Read access to a developer's client IDs that have been created to work with the Live Connect APIs. + /// + public const string Applications = "wl.applications"; + + /// + /// Creation of new client IDs on behalf of a developer. + /// Superset for: Scope.Applications + /// + public const string ApplicationsCreate = "wl.applications_create"; + + /// + /// Enables read access to a user's birthday info including birth day, month, and year. /// - [ScopeName("wl.birthday")] - Birthday, + public const string Birthday = "wl.birthday"; /// - /// Read access to a user's calendars and events. + /// Enables read access to a user's calendars and events. /// - [ScopeName("wl.calendars")] - Calendars, + public const string Calendars = "wl.calendars"; /// - /// Read and write access to a user's calendars and events. - /// Superset for: Scope.Calendars + /// Enables read and write access to a user's calendars and events. /// - [ScopeName("wl.calendars_update")] - CalendarsUpdate, + public const string CalendarsUpdate = "wl.calendars_update"; /// - /// Read access to the birth day and birth month of a user's contacts. Note that this also gives read access to the user's birth day, birth month, and birth year. - /// Superset for: Scope.Birthday + /// Enables read access to the birth day and birth month of a user's contacts. Note that this also gives read access to the user's birth day, birth month, and birth year. /// - [ScopeName("wl.contacts_birthday")] - ContactsBirthday, + public const string ContactsBirthday = "wl.contacts_birthday"; /// - /// Creation of new contacts in the user's address book. + /// Enables creation of new contacts in the user's address book. /// - [ScopeName("wl.contacts_create")] - ContactsCreate, + public const string ContactsCreate = "wl.contacts_create"; /// - /// Read access to a user's calendars and events. Also enables read access to any calendars and events that other users have shared with the user - /// Superset for: Scope.Calendars + /// Enables read access to a user's calendars and events. Also enables read access to any calendars and events that other users have shared with the user. /// - [ScopeName("wl.contacts_calendars")] - ContactsCalendars, + public const string ContactsCalendars = "wl.contacts_calendars"; /// - /// Read access to a user's albums, photos, videos, and audio, and their associated comments and tags. Also enables read access to any albums, photos, videos, and audio that other users have shared with the user. - /// Superset for: Scope.Photos + /// Enables read access to a user's personal, preferred and business email addresses. Also enables read access to any personal, preferred and business email addresses that other users have shared with the user. /// - [ScopeName("wl.contacts_photos")] - ContactsPhotos, + public const string ContactsEmails = "wl.contacts_emails"; /// - /// Read access to Microsoft SkyDrive files that other users have shared with the user. Note that this also gives read access to the user's files stored in SkyDrive. - /// Superset for: Scope.SkyDrive + /// Enables read access to a user's albums, photos, videos, and audio, and their associated comments and tags. Also enables read access to any albums, photos, videos, and audio that other users have shared with the user. /// - [ScopeName("wl.contacts_skydrive")] - ContactsSkyDrive, + public const string ContactsPhotos = "wl.contacts_photos"; /// - /// Read access to a user's personal, preferred, and business email addresses. + /// Enables read access to Microsoft OneDrive files that other users have shared with the user. Note that this also gives read access to the user's files stored in OneDrive. /// - [ScopeName("wl.emails")] - Emails, + public const string ContactsSkyDrive = "wl.contacts_skydrive"; /// - /// Creation of events on the user's default calendar. + /// Enables read access to a user's personal, preferred, and business email addresses. /// - [ScopeName("wl.events_create")] - EventsCreate, + public const string Emails = "wl.emails"; + + /// + /// Enables creation of events on the user's default calendar. + /// + public const string EventsCreate = "wl.events_create"; /// /// Enables signing in to the Windows Live Messenger Extensible Messaging and Presence Protocol (XMPP) service. /// - [ScopeName("wl.messenger")] - Messenger, + public const string Messenger = "wl.messenger"; /// - /// Read access to a user's personal, business, and mobile phone numbers. + /// Enables read and write access to a user's email using IMAP, and send access using SMTP. /// - [ScopeName("wl.phone_numbers")] - PhoneNumbers, + public const string IMAP = "wl.imap"; /// - /// Read access to a user's photos, videos, audio, and albums. + /// Enables read access to a user's personal, business, and mobile phone numbers. /// - [ScopeName("wl.photos")] - Photos, + public const string PhoneNumbers = "wl.phone_numbers"; /// - /// Read access to a user's postal addresses. + /// Enables read access to a user's photos, videos, audio, and albums. /// - [ScopeName("wl.postal_addresses")] - PostalAddresses, + public const string Photos = "wl.photos"; /// - /// Enables updating a user's status message. + /// Enables read access to a user's postal addresses. /// - [ScopeName("wl.share")] - Share, + public const string PostalAddresses = "wl.postal_addresses"; /// - /// Read access to a user's files stored in SkyDrive. + /// Enables updating a user's status message. /// - [ScopeName("wl.skydrive")] - SkyDrive, + public const string Share = "wl.share"; /// - /// Read and write access to a user's files stored in SkyDrive. - /// Superset for: Scope.SkyDrive + /// Enables read access to a user's files stored in OneDrive. /// - [ScopeName("wl.skydrive_update")] - SkyDriveUpdate, + public const string SkyDrive = "wl.skydrive"; /// - /// Read access to a user's employer and work position information. + /// Enables read and write access to a user's files stored in OneDrive. /// - [ScopeName("wl.work_profile")] - WorkProfile, + public const string SkyDriveUpdate = "wl.skydrive_update"; /// - /// Read access to a developer's client IDs that have been created to work with the Live Connect APIs. + /// Enables read access to a user's employer and work position information. /// - [ScopeName("wl.applications")] - Applications, + public const string WorkProfile = "wl.work_profile"; /// - /// Creation of new client IDs on behalf of a developer. - /// Superset for: Scope.Applications + /// Enables read and write access to a user's OneNote notebooks stored in OneDrive. /// - [ScopeName("wl.applications_create")] - ApplicationsCreate, + public const string OnenoteCreate = "office.onenote_create"; + #endregion } } diff --git a/LiveSDKHelperPlayground8/LiveSDKHelperPlayground8.csproj b/LiveSDKHelperPlayground8/LiveSDKHelperPlayground8.csproj index d26cd31..116e56e 100644 --- a/LiveSDKHelperPlayground8/LiveSDKHelperPlayground8.csproj +++ b/LiveSDKHelperPlayground8/LiveSDKHelperPlayground8.csproj @@ -159,13 +159,13 @@ - ..\packages\LiveSDK.5.3\lib\WindowsPhone8\Microsoft.Live.dll + ..\packages\LiveSDK.5.6.1\lib\WindowsPhone8\Microsoft.Live.dll - ..\packages\LiveSDK.5.3\lib\WindowsPhone8\Microsoft.Live.Controls.dll + ..\packages\LiveSDK.5.6.1\lib\WindowsPhone8\Microsoft.Live.Controls.dll - ..\packages\Newtonsoft.Json.5.0.5\lib\portable-net45+wp80+win8\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.8\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll diff --git a/LiveSDKHelperPlayground8/MainPage.xaml.cs b/LiveSDKHelperPlayground8/MainPage.xaml.cs index b2f4117..db240b4 100644 --- a/LiveSDKHelperPlayground8/MainPage.xaml.cs +++ b/LiveSDKHelperPlayground8/MainPage.xaml.cs @@ -19,7 +19,7 @@ public MainPage() InitializeComponent(); //wl.basic wl.signin wl.offline_access wl.skydrive_update wl.calendars - var scopes = new List + var scopes = new List { Scope.Basic, Scope.SignIn, @@ -29,7 +29,7 @@ public MainPage() }; SignInButton.Scopes = scopes.ToConcatenatedString( - scope => scope.ToStringScope(), + scope => scope, " "); SignedInAs.Text = "Not signed in"; diff --git a/LiveSDKHelperPlayground8/packages.config b/LiveSDKHelperPlayground8/packages.config index fdc7331..0ba1f03 100644 --- a/LiveSDKHelperPlayground8/packages.config +++ b/LiveSDKHelperPlayground8/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file