This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #123 - Release Evernote plugin
- Loading branch information
1 parent
c75df55
commit 851b039
Showing
14 changed files
with
151 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/Plugins/Probel.Lanceur.Plugin.Evernote/Services/Configurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Probel.Lanceur.Plugin.Evernote.Services | ||
{ | ||
internal class Configurator | ||
{ | ||
#region Fields | ||
|
||
private readonly string _parameters; | ||
private Dictionary<string, string> _configuration = null; | ||
private Regex _regex = new Regex(@"^(?<key>(key|host|server)):(?<value>.*)"); | ||
|
||
#endregion Fields | ||
|
||
#region Constructors | ||
|
||
public Configurator(string parameters) | ||
{ | ||
this._parameters = parameters; | ||
} | ||
|
||
#endregion Constructors | ||
|
||
#region Properties | ||
|
||
public string Host => Get("host"); | ||
|
||
public string Key => Get("key"); | ||
|
||
public string Server => Get("server"); | ||
|
||
#endregion Properties | ||
|
||
#region Methods | ||
|
||
public bool IsValid() => _parameters.StartsWith("-c") || _parameters.StartsWith("config"); | ||
|
||
private string Get(string key) | ||
{ | ||
LoadConfiguration(); | ||
return _configuration.ContainsKey(key) | ||
? _configuration[key] | ||
: string.Empty; | ||
} | ||
|
||
private string[] GetSplits() => _parameters.Split(' '); | ||
|
||
private void LoadConfiguration() | ||
{ | ||
if (_configuration == null) | ||
{ | ||
_configuration = new Dictionary<string, string>(); | ||
var splits = GetSplits(); | ||
|
||
foreach (var split in splits) | ||
{ | ||
var groups = _regex.Match(split)?.Groups; | ||
var key = groups["key"].Value; | ||
var value = groups["value"].Value; | ||
|
||
if (_configuration.ContainsKey(key)) { throw new ArgumentException($"Evernote configuration is not valid. Configuration key '{key}' is already set."); } | ||
else { _configuration.Add(key, value); } | ||
} | ||
} | ||
} | ||
|
||
#endregion Methods | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyVersion("0.7.0.31")] | ||
[assembly: AssemblyVersion("0.7.0.33")] | ||
[assembly: AssemblyFileVersion("0.7.0.0")] | ||
[assembly: AssemblyInformationalVersion("0.7.0-beta.31+Branch.develop.Sha.38aa982a498a90e6c3b9b09fe0bbd3b7396061eb")] | ||
[assembly: AssemblyInformationalVersion("0.7.0-beta.33+Branch.develop.Sha.96c0c8a18271dba2eb2832c80947f729c65f048f")] | ||
|