-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
2,010 additions
and
677 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
|
||
namespace Winterdom.Viasfora.Contracts { | ||
public interface ILanguageSettings { | ||
String KeyName { get; } | ||
String[] ControlFlow { get; set; } | ||
String[] Linq { get; set; } | ||
String[] Visibility { get; set; } | ||
bool Enabled { get; set; } | ||
void Load(); | ||
void Save(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using System.Windows.Media; | ||
using Microsoft.VisualStudio.Text.Classification; | ||
using Microsoft.VisualStudio.Utilities; | ||
|
||
namespace Winterdom.Viasfora.EditorFormats { | ||
[Export(typeof(EditorFormatDefinition))] | ||
[ClassificationType(ClassificationTypeNames = Constants.LINE_HIGHLIGHT)] | ||
[Name(Constants.LINE_HIGHLIGHT)] | ||
[UserVisible(true)] | ||
[Order(Before = Priority.Default)] | ||
sealed class CurrentLineFormat : ClassificationFormatDefinition { | ||
public CurrentLineFormat() { | ||
this.ForegroundColor = Colors.LightGray; | ||
this.ForegroundOpacity = 0.3; | ||
this.BackgroundOpacity = 0.3; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Linq; | ||
using Winterdom.Viasfora.Contracts; | ||
|
||
namespace Winterdom.Viasfora { | ||
public static class LanguageExtensions { | ||
private static StringComparer comparer = StringComparer.CurrentCultureIgnoreCase; | ||
|
||
public static bool IsControlFlowKeyword(this ILanguage lang, String text) { | ||
return lang.Settings.ControlFlow.Contains(lang.NormalizationFunction(text), comparer); | ||
} | ||
public static bool IsVisibilityKeyword(this ILanguage lang, String text) { | ||
return lang.Settings.Visibility.Contains(lang.NormalizationFunction(text), comparer); | ||
} | ||
public static bool IsLinqKeyword(this ILanguage lang, String text) { | ||
return lang.Settings.Linq.Contains(lang.NormalizationFunction(text), comparer); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Winterdom.Viasfora.Settings { | ||
public interface ICustomExport { | ||
IDictionary<String, object> Export(); | ||
} | ||
} |
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,10 @@ | ||
using System; | ||
|
||
namespace Winterdom.Viasfora.Settings { | ||
public interface ISettingsExport { | ||
void Export<T>(T settingsObject) where T : class; | ||
void Import(ISettingsStore store); | ||
void Load(String sourcePath); | ||
void Save(String targetPath); | ||
} | ||
} |
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,13 @@ | ||
using System; | ||
|
||
namespace Winterdom.Viasfora.Settings { | ||
public interface IStorageConversions { | ||
bool ToBoolean(String value); | ||
int ToInt32(String value); | ||
long ToInt64(String value); | ||
double ToDouble(String value); | ||
bool ToEnum<T>(String value, out T result) where T : struct; | ||
String[] ToList(String value); | ||
String ToString(object value); | ||
} | ||
} |
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,14 @@ | ||
using System; | ||
|
||
namespace Winterdom.Viasfora.Settings { | ||
public interface ITypedSettingsStore : ISettingsStore, IUpdatableSettings { | ||
String GetString(String name, String defaultValue); | ||
bool GetBoolean(String name, bool defaultValue); | ||
int GetInt32(String name, int defaultValue); | ||
long GetInt64(String name, long defaultValue); | ||
double GetDouble(String name, double defaultValue); | ||
T GetEnum<T>(String name, T defaultValue) where T : struct; | ||
String[] GetList(String name, String[] defaultValue); | ||
void SetValue(String name, object value); | ||
} | ||
} |
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,25 @@ | ||
using System; | ||
|
||
namespace Winterdom.Viasfora.Settings { | ||
public abstract class SettingsBase : IUpdatableSettings { | ||
protected ITypedSettingsStore Store { get; private set; } | ||
public event EventHandler SettingsChanged; | ||
|
||
public SettingsBase(ITypedSettingsStore store) { | ||
this.Store = store; | ||
this.Store.SettingsChanged += OnStoreChanged; | ||
} | ||
|
||
public void Load() { | ||
this.Store.Load(); | ||
} | ||
|
||
public void Save() { | ||
this.Store.Save(); | ||
} | ||
|
||
private void OnStoreChanged(object sender, EventArgs e) { | ||
SettingsChanged?.Invoke(this, EventArgs.Empty); | ||
} | ||
} | ||
} |
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,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Composition; | ||
using System.Reflection; | ||
using System.Xml; | ||
using System.Xml.Linq; | ||
|
||
namespace Winterdom.Viasfora.Settings { | ||
[Export(typeof(ISettingsExport))] | ||
public class SettingsExporter : ISettingsExport { | ||
private IDictionary<String, String> settings = new Dictionary<String, String>(); | ||
private IStorageConversions converter; | ||
|
||
[ImportingConstructor] | ||
public SettingsExporter(IStorageConversions converter) { | ||
this.converter = converter; | ||
} | ||
|
||
public void Load(String sourcePath) { | ||
settings.Clear(); | ||
XDocument doc = XDocument.Load(sourcePath); | ||
foreach ( var element in doc.Root.Elements() ) { | ||
settings[element.Name.LocalName] = element.Value; | ||
} | ||
} | ||
|
||
public void Save(String targetPath) { | ||
using ( var xw = XmlWriter.Create(targetPath) ) { | ||
xw.WriteStartElement("viasfora"); | ||
foreach ( String key in settings.Keys ) { | ||
String value = settings[key]; | ||
if ( value != null ) { | ||
xw.WriteElementString(key, settings[key]); | ||
} | ||
} | ||
xw.WriteEndElement(); | ||
} | ||
} | ||
|
||
public void Export<T>(T settingsObject) where T : class { | ||
ICustomExport exporter = settingsObject as ICustomExport; | ||
if ( exporter != null ) { | ||
CustomExport(exporter); | ||
} else { | ||
var type = typeof(T); | ||
var props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); | ||
foreach ( var prop in props ) { | ||
var value = prop.GetValue(settingsObject); | ||
if ( value == null ) { | ||
this.settings[prop.Name] = null; | ||
} else { | ||
this.settings[prop.Name] = this.converter.ToString(value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void Import(ISettingsStore store) { | ||
foreach ( var key in this.settings.Keys ) { | ||
store.Set(key, this.settings[key]); | ||
} | ||
} | ||
|
||
private void CustomExport(ICustomExport exporter) { | ||
var props = exporter.Export(); | ||
foreach ( var key in props.Keys ) { | ||
var value = props[key]; | ||
if ( value == null ) { | ||
this.settings[key] = null; | ||
} else { | ||
this.settings[key] = this.converter.ToString(value); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.