Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions LiveSDKHelper.Test/ExtensionMethodsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,14 @@ public void MustReturnPipeSeparatedValuesWithSurroundingSpaceFromListOfStrings()
[TestMethod]
public void MustReturnSpaceSeparatedValuesFromListOfScopes()
{
var list = new List<Scope> { Scope.SignIn, Scope.Basic, Scope.SkyDrive };
var list = new List<string> { 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);
}
}
}
}
48 changes: 18 additions & 30 deletions LiveSDKHelper.Test/ScopeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scope>().ToList();
[TestClass]
public class ScopeTest
{
[TestMethod]
public void MustEachHaveUniqueScopeName()
{
FieldInfo[] fieldinfoArray = typeof(Scope).GetFields(System.Reflection.BindingFlags.Static);
List<string> fieldInfoNames = new List<string>();
foreach (var fi in fieldinfoArray)
{
fieldInfoNames.Add(fi.GetRawConstantValue().ToString());
}

var scopesWithName = new List<Scope>(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<Scope>().ToList();

var scopeNames = new List<string>();
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);
}
}
}
8 changes: 5 additions & 3 deletions LiveSDKHelper.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}"
Expand Down
7 changes: 0 additions & 7 deletions LiveSDKHelper/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ public static string ToConcatenatedString<T>(this IEnumerable<T> source,
return b.ToString().Trim(separator.ToCharArray());
}

public static string ToStringScope(this Scope scope)
{
var scopeName = scope.GetAttribute<ScopeNameAttribute>();

return scopeName == null ? string.Empty : scopeName.ScopeName;
}

internal static UriBuilder SetQueryParam(this UriBuilder uri, string key, string value)
{
var collection = uri.ParseQuery();
Expand Down
7 changes: 6 additions & 1 deletion LiveSDKHelper/LiveSDKHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
<RootNamespace>LiveSDKHelper</RootNamespace>
<AssemblyName>LiveSDKHelper</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile104</TargetFrameworkProfile>
<TargetFrameworkProfile>Profile158</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<NuSpecFile>LiveSDKHelper.nuspec</NuSpecFile>
<BuildPackage>true</BuildPackage>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
144 changes: 67 additions & 77 deletions LiveSDKHelper/Scope.cs
Original file line number Diff line number Diff line change
@@ -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
/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.basic")]
Basic,
public const string Basic = "wl.basic";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.offline_access")]
OfflineAccess,
public const string OfflineAccess = "wl.offline_access";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.signin")]
SignIn,
public const string SignIn = "wl.signin";
#endregion

#region Extended Scopes
/// <summary>
/// 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.
/// </summary>
public const string Applications = "wl.applications";

/// <summary>
/// Creation of new client IDs on behalf of a developer.
/// Superset for: Scope.Applications
/// </summary>
public const string ApplicationsCreate = "wl.applications_create";

/// <summary>
/// Enables read access to a user's birthday info including birth day, month, and year.
/// </summary>
[ScopeName("wl.birthday")]
Birthday,
public const string Birthday = "wl.birthday";

/// <summary>
/// Read access to a user's calendars and events.
/// Enables read access to a user's calendars and events.
/// </summary>
[ScopeName("wl.calendars")]
Calendars,
public const string Calendars = "wl.calendars";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.calendars_update")]
CalendarsUpdate,
public const string CalendarsUpdate = "wl.calendars_update";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.contacts_birthday")]
ContactsBirthday,
public const string ContactsBirthday = "wl.contacts_birthday";

/// <summary>
/// Creation of new contacts in the user's address book.
/// Enables creation of new contacts in the user's address book.
/// </summary>
[ScopeName("wl.contacts_create")]
ContactsCreate,
public const string ContactsCreate = "wl.contacts_create";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.contacts_calendars")]
ContactsCalendars,
public const string ContactsCalendars = "wl.contacts_calendars";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.contacts_photos")]
ContactsPhotos,
public const string ContactsEmails = "wl.contacts_emails";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.contacts_skydrive")]
ContactsSkyDrive,
public const string ContactsPhotos = "wl.contacts_photos";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.emails")]
Emails,
public const string ContactsSkyDrive = "wl.contacts_skydrive";

/// <summary>
/// Creation of events on the user's default calendar.
/// Enables read access to a user's personal, preferred, and business email addresses.
/// </summary>
[ScopeName("wl.events_create")]
EventsCreate,
public const string Emails = "wl.emails";

/// <summary>
/// Enables creation of events on the user's default calendar.
/// </summary>
public const string EventsCreate = "wl.events_create";

/// <summary>
/// Enables signing in to the Windows Live Messenger Extensible Messaging and Presence Protocol (XMPP) service.
/// </summary>
[ScopeName("wl.messenger")]
Messenger,
public const string Messenger = "wl.messenger";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.phone_numbers")]
PhoneNumbers,
public const string IMAP = "wl.imap";

/// <summary>
/// Read access to a user's photos, videos, audio, and albums.
/// Enables read access to a user's personal, business, and mobile phone numbers.
/// </summary>
[ScopeName("wl.photos")]
Photos,
public const string PhoneNumbers = "wl.phone_numbers";

/// <summary>
/// Read access to a user's postal addresses.
/// Enables read access to a user's photos, videos, audio, and albums.
/// </summary>
[ScopeName("wl.postal_addresses")]
PostalAddresses,
public const string Photos = "wl.photos";

/// <summary>
/// Enables updating a user's status message.
/// Enables read access to a user's postal addresses.
/// </summary>
[ScopeName("wl.share")]
Share,
public const string PostalAddresses = "wl.postal_addresses";

/// <summary>
/// Read access to a user's files stored in SkyDrive.
/// Enables updating a user's status message.
/// </summary>
[ScopeName("wl.skydrive")]
SkyDrive,
public const string Share = "wl.share";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.skydrive_update")]
SkyDriveUpdate,
public const string SkyDrive = "wl.skydrive";

/// <summary>
/// Read access to a user's employer and work position information.
/// Enables read and write access to a user's files stored in OneDrive.
/// </summary>
[ScopeName("wl.work_profile")]
WorkProfile,
public const string SkyDriveUpdate = "wl.skydrive_update";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.applications")]
Applications,
public const string WorkProfile = "wl.work_profile";

/// <summary>
/// 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.
/// </summary>
[ScopeName("wl.applications_create")]
ApplicationsCreate,
public const string OnenoteCreate = "office.onenote_create";
#endregion
}
}
6 changes: 3 additions & 3 deletions LiveSDKHelperPlayground8/LiveSDKHelperPlayground8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Live">
<HintPath>..\packages\LiveSDK.5.3\lib\WindowsPhone8\Microsoft.Live.dll</HintPath>
<HintPath>..\packages\LiveSDK.5.6.1\lib\WindowsPhone8\Microsoft.Live.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Live.Controls">
<HintPath>..\packages\LiveSDK.5.3\lib\WindowsPhone8\Microsoft.Live.Controls.dll</HintPath>
<HintPath>..\packages\LiveSDK.5.6.1\lib\WindowsPhone8\Microsoft.Live.Controls.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.5\lib\portable-net45+wp80+win8\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
Expand Down
4 changes: 2 additions & 2 deletions LiveSDKHelperPlayground8/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public MainPage()
InitializeComponent();

//wl.basic wl.signin wl.offline_access wl.skydrive_update wl.calendars
var scopes = new List<Scope>
var scopes = new List<string>
{
Scope.Basic,
Scope.SignIn,
Expand All @@ -29,7 +29,7 @@ public MainPage()
};

SignInButton.Scopes = scopes.ToConcatenatedString(
scope => scope.ToStringScope(),
scope => scope,
" ");

SignedInAs.Text = "Not signed in";
Expand Down
Loading