diff --git a/src/Evernote-SDK-Windows.sln b/src/Evernote-SDK-Windows.sln index d3c9826..1ed56d0 100644 --- a/src/Evernote-SDK-Windows.sln +++ b/src/Evernote-SDK-Windows.sln @@ -1,12 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.22823.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvernoteSDK", "EvernoteSDK\EvernoteSDK.csproj", "{EFB2706A-EE60-4B33-ABD4-695B509F277B}" EndProject Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "EvernoteSDK_COMSetup", "EvernoteSDK_COMSetup\EvernoteSDK_COMSetup.vdproj", "{1AB456C0-75F7-4606-A6C3-258F088D6B07}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvernoteSDK.Tests", "EvernoteSDK.Tests\EvernoteSDK.Tests.csproj", "{86794611-FE20-4267-95E7-4EF76FBB51FC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {1AB456C0-75F7-4606-A6C3-258F088D6B07}.Debug|Any CPU.Build.0 = Debug {1AB456C0-75F7-4606-A6C3-258F088D6B07}.Release|Any CPU.ActiveCfg = Release {1AB456C0-75F7-4606-A6C3-258F088D6B07}.Release|Any CPU.Build.0 = Release + {86794611-FE20-4267-95E7-4EF76FBB51FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86794611-FE20-4267-95E7-4EF76FBB51FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86794611-FE20-4267-95E7-4EF76FBB51FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86794611-FE20-4267-95E7-4EF76FBB51FC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/EvernoteSDK.Tests/App.config b/src/EvernoteSDK.Tests/App.config new file mode 100644 index 0000000..e6622ba --- /dev/null +++ b/src/EvernoteSDK.Tests/App.config @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/src/EvernoteSDK.Tests/ENSession_DeleteNote.cs b/src/EvernoteSDK.Tests/ENSession_DeleteNote.cs new file mode 100644 index 0000000..9a761d7 --- /dev/null +++ b/src/EvernoteSDK.Tests/ENSession_DeleteNote.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EvernoteSDK.Tests +{ + [TestClass] + public class ENSession_DeleteNote + { + [TestInitialize] + public void Initialize() + { + TestUtils.AuthenticateToEverNote(); + } + [TestMethod] + public void WhenNoteContainsHtml_ShoudBeAbleToDelete() + { + // Create a new note (in the user's default notebook) with some HTML content. + ENNote myFancyNote = new ENNote(); + myFancyNote.Title = "My fancy note to delete"; + myFancyNote.Content = ENNoteContent.NoteContentWithSanitizedHTML("

Hello, world - this is a fancy note - and here is a table:



RedGreen
BlueYellow
"); + ENNoteRef myFancyNoteRef = ENSession.SharedSession.UploadNote(myFancyNote, null); + + // Delete the HTML content note we just created. + ENSession.SharedSession.DeleteNote(myFancyNoteRef); + } + } +} diff --git a/src/EvernoteSDK.Tests/ENSession_DownloadNotes.cs b/src/EvernoteSDK.Tests/ENSession_DownloadNotes.cs new file mode 100644 index 0000000..4b877f3 --- /dev/null +++ b/src/EvernoteSDK.Tests/ENSession_DownloadNotes.cs @@ -0,0 +1,85 @@ +using System; +using System.Text; +using System.Collections.Generic; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EvernoteSDK.Tests +{ + /// + /// Summary description for ENSession_DownloadNotes + /// + [TestClass] + public class ENSession_DownloadNotes + { + public ENSession_DownloadNotes() + { + // + // TODO: Add constructor logic here + // + } + + private TestContext testContextInstance; + + /// + ///Gets or sets the test context which provides + ///information about and functionality for the current test run. + /// + public TestContext TestContext + { + get + { + return testContextInstance; + } + set + { + testContextInstance = value; + } + } + + #region Additional test attributes + // + // You can use the following additional attributes as you write your tests: + // + // Use ClassInitialize to run code before running the first test in the class + [ClassInitialize()] + public static void MyClassInitialize(TestContext testContext) + { + TestUtils.AuthenticateToEverNote(); + } + // + // Use ClassCleanup to run code after all tests in a class have run + // [ClassCleanup()] + // public static void MyClassCleanup() { } + // + // Use TestInitialize to run code before running each test + // [TestInitialize()] + // public void MyTestInitialize() { } + // + // Use TestCleanup to run code after each test has run + // [TestCleanup()] + // public void MyTestCleanup() { } + // + #endregion + + [TestMethod] + public void WhenDownloadForAlreadyUploadedNote_ShouldDownloadCorrectNote() + { + string textToFind = Guid.NewGuid().ToString(); + ENNote myPlainNote = new ENNote(); + myPlainNote.Title = textToFind; + myPlainNote.Content = ENNoteContent.NoteContentWithString(textToFind); + ENSession.SharedSession.UploadNote(myPlainNote, null); + + List myResultsList = ENSession.SharedSession.FindNotes(ENNoteSearch.NoteSearch(textToFind), null, ENSession.SearchScope.All, ENSession.SortOrder.RecentlyUpdated, 500); + bool contentDownloaded = false; + if (myResultsList.Count > 0) + { + // Given a NoteRef instance, download that note. + ENNote myDownloadedNote = ENSession.SharedSession.DownloadNote(myResultsList[0].NoteRef); + contentDownloaded= string.Equals(myDownloadedNote.TextContent, textToFind); + } + Assert.IsTrue(contentDownloaded, "Note able to download required note"); + } + } +} diff --git a/src/EvernoteSDK.Tests/ENSession_FindNotes.cs b/src/EvernoteSDK.Tests/ENSession_FindNotes.cs new file mode 100644 index 0000000..123e5d4 --- /dev/null +++ b/src/EvernoteSDK.Tests/ENSession_FindNotes.cs @@ -0,0 +1,88 @@ +using System; +using System.Text; +using System.Collections.Generic; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EvernoteSDK.Tests +{ + /// + /// Summary description for ENSession_FindNotes + /// + [TestClass] + public class ENSession_FindNotes + { + public ENSession_FindNotes() + { + // + // TODO: Add constructor logic here + // + } + + private TestContext testContextInstance; + + /// + ///Gets or sets the test context which provides + ///information about and functionality for the current test run. + /// + public TestContext TestContext + { + get + { + return testContextInstance; + } + set + { + testContextInstance = value; + } + } + + #region Additional test attributes + // + // You can use the following additional attributes as you write your tests: + + //Use ClassInitialize to run code before running the first test in the class + [ClassInitialize()] + public static void MyClassInitialize(TestContext testContext) + { + TestUtils.AuthenticateToEverNote(); + } + // + // Use ClassCleanup to run code after all tests in a class have run + // [ClassCleanup()] + // public static void MyClassCleanup() { } + // + // Use TestInitialize to run code before running each test + // [TestInitialize()] + // public void MyTestInitialize() { } + // + // Use TestCleanup to run code after each test has run + // [TestCleanup()] + // public void MyTestCleanup() { } + // + #endregion + + [TestMethod] + public void WhenSearchForAlreadyUploadedNote_ShouldSucceed() + { + string textToFind = Guid.NewGuid().ToString(); + ENNote myPlainNote = new ENNote(); + myPlainNote.Title = textToFind; + myPlainNote.Content = ENNoteContent.NoteContentWithString(textToFind + "My plain text note"); + ENSession.SharedSession.UploadNote(myPlainNote, null); + + List myResultsList = ENSession.SharedSession.FindNotes(ENNoteSearch.NoteSearch(textToFind), null, ENSession.SearchScope.All, ENSession.SortOrder.RecentlyUpdated, 500); + int noteCount = 0; + if (myResultsList.Count > 0) + { + foreach (ENSessionFindNotesResult result in myResultsList) + { + if(string.Equals( result.Title,textToFind)) { + noteCount += 1; + } + } + } + Assert.IsTrue(noteCount == 1, "Either search failed or returned more results."); + } + } +} diff --git a/src/EvernoteSDK.Tests/ENSession_ShareNote.cs b/src/EvernoteSDK.Tests/ENSession_ShareNote.cs new file mode 100644 index 0000000..0fd2326 --- /dev/null +++ b/src/EvernoteSDK.Tests/ENSession_ShareNote.cs @@ -0,0 +1,28 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace EvernoteSDK.Tests +{ + [TestClass] + public class ENSession_ShareNote + { + [TestInitialize] + public void Initialize() + { + TestUtils.AuthenticateToEverNote(); + } + + [TestMethod] + public void WhenSharingSimpleNote_ShouldReturnSharedNoteUrl() + { + ENNote myPlainNote = new ENNote(); + myPlainNote.Title = "My plain text note to share"; + myPlainNote.Content = ENNoteContent.NoteContentWithString("Hello, world! I am sharing"); + ENNoteRef myPlainNoteRef = ENSession.SharedSession.UploadNote(myPlainNote, null); + + // Share this new note publicly. "shareUrl" is the public URL to distribute to access the note. + string shareUrl = ENSession.SharedSession.ShareNote(myPlainNoteRef); + Assert.IsFalse(string.IsNullOrWhiteSpace(shareUrl), "Not able to obtain shared note url"); + } + } +} diff --git a/src/EvernoteSDK.Tests/ENSession_UploadNote.cs b/src/EvernoteSDK.Tests/ENSession_UploadNote.cs new file mode 100644 index 0000000..5e2a084 --- /dev/null +++ b/src/EvernoteSDK.Tests/ENSession_UploadNote.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using Microsoft.VisualStudio.TestTools.UnitTesting; +namespace EvernoteSDK.Tests +{ + [TestClass] + public class ENSession_UploadNote + { + [TestInitialize] + public void Initialize() + { + TestUtils.AuthenticateToEverNote(); + } + [TestMethod] + public void WhenContentIsSimpleText_ShouldSucceed() + { + // Get a list of all notebooks in the user's account. + List myNotebookList = ENSession.SharedSession.ListNotebooks(); + + // Create a new note (in the user's default notebook) with some plain text content. + ENNote myPlainNote = new ENNote(); + myPlainNote.Title = "My plain text note"; + myPlainNote.Content = ENNoteContent.NoteContentWithString("Hello, world!"); + ENNoteRef myPlainNoteRef = ENSession.SharedSession.UploadNote(myPlainNote, null); + } + [TestMethod] + public void WhenContentIsHtml_ShouldSucceed() + { + // Create a new note (in the user's default notebook) with some HTML content. + ENNote myFancyNote = new ENNote(); + myFancyNote.Title = "My first note"; + myFancyNote.Content = ENNoteContent.NoteContentWithSanitizedHTML("

Hello, world - this is a fancy note - and here is a table:



RedGreen
BlueYellow
"); + ENNoteRef myFancyNoteRef = ENSession.SharedSession.UploadNote(myFancyNote, null); + } + + [TestMethod] + public void WhenNoteContainsResource_ShouldSucceed() + { + // Create a new note with a resource. + ENNote myResourceNote = new ENNote(); + myResourceNote.Title = "My test note with a resource"; + myResourceNote.Content = ENNoteContent.NoteContentWithString("Hello, resource!"); + byte[] myFile = TestUtils.StreamFile(TestConfiguration.PathToJPEGFile); + ENResource myResource = new ENResource(myFile, "image/jpg", "My First Picture.jpg"); + myResourceNote.Resources.Add(myResource); + ENNoteRef myResourceRef = ENSession.SharedSession.UploadNote(myResourceNote, null); + + } + } +} diff --git a/src/EvernoteSDK.Tests/EvernoteSDK.Tests.csproj b/src/EvernoteSDK.Tests/EvernoteSDK.Tests.csproj new file mode 100644 index 0000000..afb4dd9 --- /dev/null +++ b/src/EvernoteSDK.Tests/EvernoteSDK.Tests.csproj @@ -0,0 +1,123 @@ + + + + Debug + AnyCPU + {86794611-FE20-4267-95E7-4EF76FBB51FC} + Library + Properties + EvernoteSDK.Tests + EvernoteSDK.Tests + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\assemblies\CsQuery.dll + + + ..\..\assemblies\en-html2enml.dll + + + ..\..\assemblies\Evernote.dll + + + ..\..\assemblies\EvernoteOAuthNet.dll + + + ..\..\assemblies\PreMailer.Net.dll + + + ..\..\assemblies\SgmlReaderDll.dll + + + + 3.5 + + + ..\..\assemblies\Thrift.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + {efb2706a-ee60-4b33-abd4-695b509f277b} + EvernoteSDK + + + + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/src/EvernoteSDK.Tests/Properties/AssemblyInfo.cs b/src/EvernoteSDK.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..86f0cb8 --- /dev/null +++ b/src/EvernoteSDK.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EvernoteSDK.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EvernoteSDK.Tests")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("86794611-fe20-4267-95e7-4ef76fbb51fc")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/EvernoteSDK.Tests/TestConfiguration.cs b/src/EvernoteSDK.Tests/TestConfiguration.cs new file mode 100644 index 0000000..76f124c --- /dev/null +++ b/src/EvernoteSDK.Tests/TestConfiguration.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EvernoteSDK.Tests +{ + class TestConfiguration + { + /// + /// If its true use ENSession.SetSharedSessionDeveloperToken("developer token", "note store url); + /// Else use ENSession.SetSharedSessionConsumerKey("your key", "your secret"); for authentication + /// + internal static bool ShouldUseDeveloperTokenToAuthenticate { get; }=true; + /// + /// Path and filename of a JPG file on your computer. Be sure to replace this with a real JPG file + /// + internal static string PathToJPEGFile { get; }= @""; + + // Be sure to put your own development token here. + public static string DeveloperToken { get; } = "your development token here"; + public static string NoteStoreUrl { get; } = "url to your note store"; + // Be sure to put your own consumer key and consumer secret here. + public static string SessionConsumerKey { get; }= "your key"; + public static string SessionConsumerSecret { get; }= "your secret"; + } +} diff --git a/src/EvernoteSDK.Tests/TestMemoryBasedENPreferenceStore.cs b/src/EvernoteSDK.Tests/TestMemoryBasedENPreferenceStore.cs new file mode 100644 index 0000000..b9a0f70 --- /dev/null +++ b/src/EvernoteSDK.Tests/TestMemoryBasedENPreferenceStore.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EvernoteSDK.Advanced; + +namespace EvernoteSDK.Tests +{ + public class TestMemoryBasedENPreferenceStore: ENPreferencesStore + { + private Dictionary _Store { get; set; } + public TestMemoryBasedENPreferenceStore() + { + _Store = new Dictionary(); + } + public override object ObjectForKey(string key) + { + object value = null; + _Store.TryGetValue(key, out value); + return value; + } + public override void RemoveAllObjects() + { + _Store.Clear(); + } + public override void SetObject(object objectToStore, string key) + { + if (objectToStore != null) + { + _Store[key] = objectToStore; + } + else + { + _Store.Remove(key); + } + } + } +} diff --git a/src/EvernoteSDK.Tests/TestUtils.cs b/src/EvernoteSDK.Tests/TestUtils.cs new file mode 100644 index 0000000..e79fc51 --- /dev/null +++ b/src/EvernoteSDK.Tests/TestUtils.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace EvernoteSDK.Tests +{ + internal class TestUtils + { + + // Support routine for displaying a note thumbnail. + internal static byte[] StreamFile(string filename) + { + FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); + + // Create a byte array of file stream length + byte[] ImageData = new byte[Convert.ToInt32(fs.Length - 1) + 1]; + + //Read block of bytes from stream into the byte array + fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length)); + + //Close the File Stream + fs.Close(); + //return the byte data + return ImageData; + } + + internal static void AuthenticateToEverNote() + { + if (TestConfiguration.ShouldUseDeveloperTokenToAuthenticate) + { + ENSession.SetSharedSessionDeveloperToken(TestConfiguration.DeveloperToken, TestConfiguration.NoteStoreUrl); + } + else + { + ENSession.SetSharedSessionConsumerKey(TestConfiguration.SessionConsumerKey, TestConfiguration.SessionConsumerSecret); + } + + if (ENSession.SharedSession.IsAuthenticated == false) + { + ENSession.SharedSession.AuthenticateToEvernote(); + } + } + } +} diff --git a/src/EvernoteSDK/Advanced/ENPreferencesStore.cs b/src/EvernoteSDK/Advanced/ENPreferencesStore.cs index 8e936b4..641da73 100644 --- a/src/EvernoteSDK/Advanced/ENPreferencesStore.cs +++ b/src/EvernoteSDK/Advanced/ENPreferencesStore.cs @@ -8,9 +8,13 @@ namespace EvernoteSDK { namespace Advanced { + /// + /// Preference store for Evernote SDK. + /// public class ENPreferencesStore { - private string Pathname {get; set;} + private const string ENSessionPreferencesFilename = "EvernoteSDKPrefs.bin"; + private string Pathname {get; set;} private Dictionary Store {get; set;} private static object PathnameForStoreFilename(string filename) @@ -24,7 +28,9 @@ private static object PathnameForStoreFilename(string filename) } return string.Format("{0}\\{1}\\{2}\\{3}", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), companyKey, productKey, filename); } - + public ENPreferencesStore() : this(ENSessionPreferencesFilename) + { + } public ENPreferencesStore(string filename) { Pathname = PathnameForStoreFilename(filename).ToString(); @@ -32,14 +38,14 @@ public ENPreferencesStore(string filename) Load(); } - public object ObjectForKey(string key) + public virtual object ObjectForKey(string key) { object value = null; Store.TryGetValue(key, out value); return value; } - public void SetObject(object objectToStore, string key) + public virtual void SetObject(object objectToStore, string key) { if (objectToStore != null) { @@ -66,7 +72,7 @@ private void Save() stream.Close(); } - public void RemoveAllObjects() + public virtual void RemoveAllObjects() { Store.Clear(); Save(); diff --git a/src/EvernoteSDK/Advanced/ENPreferencesStoreFactory.cs b/src/EvernoteSDK/Advanced/ENPreferencesStoreFactory.cs new file mode 100644 index 0000000..5ea9bf4 --- /dev/null +++ b/src/EvernoteSDK/Advanced/ENPreferencesStoreFactory.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using EvernoteSDK.Advanced.Utilities; +using EvernoteSDK.Configuration; + +namespace EvernoteSDK.Advanced +{ + public class ENPreferencesStoreFactory + { + private static Lazy _lazyInitializedPreferenceStore = new Lazy(() => + { + ENPreferencesStore store = ObjectFactory.CreateObject(ENSDKConfiguration.Singleton.PreferencesStoreType); + return store; + }); + public static ENPreferencesStore GetENPreferencesStore() + { + return _lazyInitializedPreferenceStore.Value; + + } + } +} diff --git a/src/EvernoteSDK/Advanced/Utilities/ObjectFactory.cs b/src/EvernoteSDK/Advanced/Utilities/ObjectFactory.cs new file mode 100644 index 0000000..676326d --- /dev/null +++ b/src/EvernoteSDK/Advanced/Utilities/ObjectFactory.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace EvernoteSDK.Advanced.Utilities +{ + internal class ObjectFactory + { + public static ObjectType CreateObject(string fullyQualifiedTypeName) + { + + Type requestedType = Type.GetType(fullyQualifiedTypeName); + ObjectType result = (ObjectType)Activator.CreateInstance(requestedType); + return result; + } + } +} diff --git a/src/EvernoteSDK/Configuration/ENSDKConfiguration.cs b/src/EvernoteSDK/Configuration/ENSDKConfiguration.cs new file mode 100644 index 0000000..8c9c2b4 --- /dev/null +++ b/src/EvernoteSDK/Configuration/ENSDKConfiguration.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; + +namespace EvernoteSDK.Configuration +{ + public class ENSDKConfiguration : ConfigurationSection + { + #region Constants + const string PreferencesStoreTypeDefault = "EvernoteSDK.Advanced.ENPreferencesStore,EvernoteSDK"; + #endregion + + private static Lazy _lazyInitializedConfig = new Lazy(() => GetFromConfigOrDefault()); + private static ENSDKConfiguration GetFromConfigOrDefault() + { + ENSDKConfiguration currentConfiguration = ConfigurationManager.GetSection("EvernoteSDK") as ENSDKConfiguration; + if (currentConfiguration == null) + { + currentConfiguration = new ENSDKConfiguration(); + } + return currentConfiguration; + } + public static ENSDKConfiguration Singleton { get { return _lazyInitializedConfig.Value; } } + [ConfigurationProperty(name: "preferencesStoreType", DefaultValue = PreferencesStoreTypeDefault)] + public string PreferencesStoreType + { + get + { + return (string)this["preferencesStoreType"]; + } + set + { + this["preferencesStoreType"] = value; + } + } + } +} diff --git a/src/EvernoteSDK/ENSession.cs b/src/EvernoteSDK/ENSession.cs index 0e8cfc9..78b2685 100644 --- a/src/EvernoteSDK/ENSession.cs +++ b/src/EvernoteSDK/ENSession.cs @@ -20,7 +20,7 @@ public class ENSession : ENBusinessNoteStoreClient.IENBusinessNoteStoreClient, E private const string ENSessionBootstrapServerBaseURLStringCN = "app.yinxiang.com"; private const string ENSessionBootstrapServerBaseURLStringUS = "www.evernote.com"; - private const string ENSessionPreferencesFilename = "EvernoteSDKPrefs.bin"; + private const string ENSessionPreferencesCredentialStore = "CredentialStore"; private const string ENSessionPreferencesCurrentProfileName = "CurrentProfileName"; private const string ENSessionPreferencesUser = "User"; @@ -354,7 +354,7 @@ private static bool CheckSharedSessionSettings() public void Startup() { Logger = new ENSessionDefaultLogger(); - _Preferences = new ENPreferencesStore(ENSessionPreferencesFilename); + _Preferences = ENPreferencesStoreFactory.GetENPreferencesStore(); AuthenticationCompleted = false; SelectInitialSessionHost(); diff --git a/src/EvernoteSDK/EvernoteSDK.csproj b/src/EvernoteSDK/EvernoteSDK.csproj index d69ccb4..d71c232 100644 --- a/src/EvernoteSDK/EvernoteSDK.csproj +++ b/src/EvernoteSDK/EvernoteSDK.csproj @@ -71,6 +71,7 @@ Support Assemblies\SgmlReaderDll.dll + @@ -100,6 +101,7 @@ + @@ -110,7 +112,9 @@ + + Code diff --git a/src/EvernoteSDK/EvernoteSDK.xml b/src/EvernoteSDK/EvernoteSDK.xml index 406f57d..5968d6d 100644 --- a/src/EvernoteSDK/EvernoteSDK.xml +++ b/src/EvernoteSDK/EvernoteSDK.xml @@ -226,13 +226,18 @@ ** Set shared notebook recipient settings. - + + + Preference store for Evernote SDK. + + + ** - + ** - + ** @@ -244,15 +249,6 @@ ** - - ** - - - ** - - - ** - ** @@ -535,6 +531,15 @@ current exception, or a null reference if no inner exception is specified + + ** + + + ** + + + ** + A strongly-typed resource class, for looking up localized strings, etc.